id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
233,800
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php
|
ServiceOptionsMeta.reset
|
public static function reset($object)
{
if (!($object instanceof ServiceOptions)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceOptions.');
}
$object->deprecated = NULL;
$object->uninterpretedOption = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof ServiceOptions)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceOptions.');
}
$object->deprecated = NULL;
$object->uninterpretedOption = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"ServiceOptions",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\ServiceOptions.'",
")",
";",
"}",
"$",
"object",
"->",
"deprecated",
"=",
"NULL",
";",
"$",
"object",
"->",
"uninterpretedOption",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\ServiceOptions to default values
@param ServiceOptions $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceOptions",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php#L95-L102
|
233,801
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php
|
ServiceOptionsMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->deprecated)) {
hash_update($ctx, 'deprecated');
hash_update($ctx, (string)$object->deprecated);
}
if (isset($object->uninterpretedOption)) {
hash_update($ctx, 'uninterpretedOption');
foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $v0) {
UninterpretedOptionMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
php
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->deprecated)) {
hash_update($ctx, 'deprecated');
hash_update($ctx, (string)$object->deprecated);
}
if (isset($object->uninterpretedOption)) {
hash_update($ctx, 'uninterpretedOption');
foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $v0) {
UninterpretedOptionMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrCtx",
")",
";",
"}",
"else",
"{",
"$",
"ctx",
"=",
"$",
"algoOrCtx",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"deprecated",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'deprecated'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"deprecated",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"uninterpretedOption",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'uninterpretedOption'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"uninterpretedOption",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"uninterpretedOption",
":",
"(",
"array",
")",
"$",
"object",
"->",
"uninterpretedOption",
"as",
"$",
"v0",
")",
"{",
"UninterpretedOptionMeta",
"::",
"hash",
"(",
"$",
"v0",
",",
"$",
"ctx",
")",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\ServiceOptions
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceOptions"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php#L114-L139
|
233,802
|
budde377/Part
|
lib/controller/json/JSONFunctionImpl.php
|
JSONFunctionImpl.getArg
|
public function getArg($num)
{
return isset($this->args[$num]) ? $this->args[$num] : null;
}
|
php
|
public function getArg($num)
{
return isset($this->args[$num]) ? $this->args[$num] : null;
}
|
[
"public",
"function",
"getArg",
"(",
"$",
"num",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"args",
"[",
"$",
"num",
"]",
")",
"?",
"$",
"this",
"->",
"args",
"[",
"$",
"num",
"]",
":",
"null",
";",
"}"
] |
Will return argument at index given
@param $num
@return mixed
|
[
"Will",
"return",
"argument",
"at",
"index",
"given"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/json/JSONFunctionImpl.php#L58-L61
|
233,803
|
budde377/Part
|
lib/util/file/DumpFileImpl.php
|
DumpFileImpl.writeSerialized
|
public function writeSerialized($var)
{
$data = (($c = $this->getUnSerializedContent()) == ""?[]:$c);
$data[] = $var;
$this->delete();
$this->write(serialize($data));
}
|
php
|
public function writeSerialized($var)
{
$data = (($c = $this->getUnSerializedContent()) == ""?[]:$c);
$data[] = $var;
$this->delete();
$this->write(serialize($data));
}
|
[
"public",
"function",
"writeSerialized",
"(",
"$",
"var",
")",
"{",
"$",
"data",
"=",
"(",
"(",
"$",
"c",
"=",
"$",
"this",
"->",
"getUnSerializedContent",
"(",
")",
")",
"==",
"\"\"",
"?",
"[",
"]",
":",
"$",
"c",
")",
";",
"$",
"data",
"[",
"]",
"=",
"$",
"var",
";",
"$",
"this",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"write",
"(",
"serialize",
"(",
"$",
"data",
")",
")",
";",
"}"
] |
Dumps a variable to the dumpfile using serialize.
@param mixed $var
@return void
|
[
"Dumps",
"a",
"variable",
"to",
"the",
"dumpfile",
"using",
"serialize",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/DumpFileImpl.php#L18-L25
|
233,804
|
budde377/Part
|
lib/controller/ajax/ServerImpl.php
|
ServerImpl.registerHandler
|
public function registerHandler(TypeHandler $type)
{
$zeroLength = true;
foreach ($type->listTypes() as $t) {
$zeroLength = false;
$this->handlers[$t][] = $type;
$type->setUp($this, $t);
}
if ($zeroLength) {
$type->setUp($this, null);
}
}
|
php
|
public function registerHandler(TypeHandler $type)
{
$zeroLength = true;
foreach ($type->listTypes() as $t) {
$zeroLength = false;
$this->handlers[$t][] = $type;
$type->setUp($this, $t);
}
if ($zeroLength) {
$type->setUp($this, null);
}
}
|
[
"public",
"function",
"registerHandler",
"(",
"TypeHandler",
"$",
"type",
")",
"{",
"$",
"zeroLength",
"=",
"true",
";",
"foreach",
"(",
"$",
"type",
"->",
"listTypes",
"(",
")",
"as",
"$",
"t",
")",
"{",
"$",
"zeroLength",
"=",
"false",
";",
"$",
"this",
"->",
"handlers",
"[",
"$",
"t",
"]",
"[",
"]",
"=",
"$",
"type",
";",
"$",
"type",
"->",
"setUp",
"(",
"$",
"this",
",",
"$",
"t",
")",
";",
"}",
"if",
"(",
"$",
"zeroLength",
")",
"{",
"$",
"type",
"->",
"setUp",
"(",
"$",
"this",
",",
"null",
")",
";",
"}",
"}"
] |
Registers a AJAX type.
@param TypeHandler $type
@return void
|
[
"Registers",
"a",
"AJAX",
"type",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/ServerImpl.php#L54-L66
|
233,805
|
budde377/Part
|
lib/controller/ajax/ServerImpl.php
|
ServerImpl.registerHandlersFromConfig
|
public function registerHandlersFromConfig()
{
$config = $this->container->getConfigInstance();
foreach ($config->getAJAXTypeHandlers() as $handlerArray) {
if (isset($handlerArray['path'])) {
$path = $handlerArray['path'];
if (!file_exists($path)) {
throw new FileNotFoundException($path, "AJAXTypeHandler class file");
}
/** @noinspection PhpIncludeInspection */
require_once $path;
}
$className = $handlerArray['class_name'];
if (!class_exists($className)) {
throw new ClassNotDefinedException($className);
}
$handler = new $className($this->container);
if($handler instanceof TypeHandlerGenerator){
$handler = $handler->generateTypeHandler();
}
if (!($handler instanceof TypeHandler)) {
throw new ClassNotInstanceOfException($handler == null ? 'null' : get_class($handler), 'AJAXTypeHandler');
}
$this->registerHandler($handler);
}
}
|
php
|
public function registerHandlersFromConfig()
{
$config = $this->container->getConfigInstance();
foreach ($config->getAJAXTypeHandlers() as $handlerArray) {
if (isset($handlerArray['path'])) {
$path = $handlerArray['path'];
if (!file_exists($path)) {
throw new FileNotFoundException($path, "AJAXTypeHandler class file");
}
/** @noinspection PhpIncludeInspection */
require_once $path;
}
$className = $handlerArray['class_name'];
if (!class_exists($className)) {
throw new ClassNotDefinedException($className);
}
$handler = new $className($this->container);
if($handler instanceof TypeHandlerGenerator){
$handler = $handler->generateTypeHandler();
}
if (!($handler instanceof TypeHandler)) {
throw new ClassNotInstanceOfException($handler == null ? 'null' : get_class($handler), 'AJAXTypeHandler');
}
$this->registerHandler($handler);
}
}
|
[
"public",
"function",
"registerHandlersFromConfig",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"container",
"->",
"getConfigInstance",
"(",
")",
";",
"foreach",
"(",
"$",
"config",
"->",
"getAJAXTypeHandlers",
"(",
")",
"as",
"$",
"handlerArray",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"handlerArray",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"$",
"handlerArray",
"[",
"'path'",
"]",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"$",
"path",
",",
"\"AJAXTypeHandler class file\"",
")",
";",
"}",
"/** @noinspection PhpIncludeInspection */",
"require_once",
"$",
"path",
";",
"}",
"$",
"className",
"=",
"$",
"handlerArray",
"[",
"'class_name'",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"ClassNotDefinedException",
"(",
"$",
"className",
")",
";",
"}",
"$",
"handler",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"container",
")",
";",
"if",
"(",
"$",
"handler",
"instanceof",
"TypeHandlerGenerator",
")",
"{",
"$",
"handler",
"=",
"$",
"handler",
"->",
"generateTypeHandler",
"(",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"handler",
"instanceof",
"TypeHandler",
")",
")",
"{",
"throw",
"new",
"ClassNotInstanceOfException",
"(",
"$",
"handler",
"==",
"null",
"?",
"'null'",
":",
"get_class",
"(",
"$",
"handler",
")",
",",
"'AJAXTypeHandler'",
")",
";",
"}",
"$",
"this",
"->",
"registerHandler",
"(",
"$",
"handler",
")",
";",
"}",
"}"
] |
Registers the handlers from config.
@throws ClassNotDefinedException
@throws FileNotFoundException
@throws ClassNotInstanceOfException
@return void
|
[
"Registers",
"the",
"handlers",
"from",
"config",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/ServerImpl.php#L75-L107
|
233,806
|
MW-Peachy/Peachy
|
Plugins/IRC.php
|
IRC.parseRC
|
public static function parseRC( $msg ) {
if( preg_match( '/^\[\[((Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\x5d]*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?(oldid|diff)=(\d*)&(rcid|oldid)=(\d*).*|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* ([^*]*) \* (\(([^)]*)\))? (.*)$/S', $msg, $m ) ) {
$return = array();
//print_r($m);
$return['namespace'] = $m[2];
$return['pagename'] = $m[5];
$return['fullpagename'] = $m[1] . $m[5];
$return['basepagename'] = explode( '/', $return['fullpagename'] );
$return['basepagename'] = $return['basepagename'][0];
$return['subpagename'] = str_replace( $return['basepagename'] . '/', '', $return['fullpagename'] );
$return['flags'] = str_split( $m[6] );
$return['action'] = $m[6];
$return['url'] = $m[7];
$return['revid'] = $m[9];
$return['oldid'] = $m[11];
$return['username'] = $m[12];
$return['len'] = $m[14];
$return['comment'] = $m[15];
$return['timestamp'] = time();
$return['is_new'] = false;
$return['is_minor'] = false;
$return['is_bot'] = false;
$return['is_delete'] = false;
$return['actionpage'] = null;
if( in_array( 'N', $return['flags'] ) ) {
$return['is_new'] = true;
}
if( in_array( 'M', $return['flags'] ) ) {
$return['is_minor'] = true;
}
if( in_array( 'B', $return['flags'] ) ) {
$return['is_bot'] = true;
}
if( $return['action'] == 'delete' ) {
$return['is_delete'] = true;
$tmp = explode( '[[', $return['comment'] );
$tmp = explode( ']]', $tmp[1] );
$return['actionpage'] = $tmp[0];
$return['actionpageprefix'] = explode( '/', $return['actionpage'] );
$return['actionpageprefix'] = $return['actionpageprefix'][0];
}
return $return;
}
}
|
php
|
public static function parseRC( $msg ) {
if( preg_match( '/^\[\[((Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\x5d]*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?(oldid|diff)=(\d*)&(rcid|oldid)=(\d*).*|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* ([^*]*) \* (\(([^)]*)\))? (.*)$/S', $msg, $m ) ) {
$return = array();
//print_r($m);
$return['namespace'] = $m[2];
$return['pagename'] = $m[5];
$return['fullpagename'] = $m[1] . $m[5];
$return['basepagename'] = explode( '/', $return['fullpagename'] );
$return['basepagename'] = $return['basepagename'][0];
$return['subpagename'] = str_replace( $return['basepagename'] . '/', '', $return['fullpagename'] );
$return['flags'] = str_split( $m[6] );
$return['action'] = $m[6];
$return['url'] = $m[7];
$return['revid'] = $m[9];
$return['oldid'] = $m[11];
$return['username'] = $m[12];
$return['len'] = $m[14];
$return['comment'] = $m[15];
$return['timestamp'] = time();
$return['is_new'] = false;
$return['is_minor'] = false;
$return['is_bot'] = false;
$return['is_delete'] = false;
$return['actionpage'] = null;
if( in_array( 'N', $return['flags'] ) ) {
$return['is_new'] = true;
}
if( in_array( 'M', $return['flags'] ) ) {
$return['is_minor'] = true;
}
if( in_array( 'B', $return['flags'] ) ) {
$return['is_bot'] = true;
}
if( $return['action'] == 'delete' ) {
$return['is_delete'] = true;
$tmp = explode( '[[', $return['comment'] );
$tmp = explode( ']]', $tmp[1] );
$return['actionpage'] = $tmp[0];
$return['actionpageprefix'] = explode( '/', $return['actionpage'] );
$return['actionpageprefix'] = $return['actionpageprefix'][0];
}
return $return;
}
}
|
[
"public",
"static",
"function",
"parseRC",
"(",
"$",
"msg",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\[\\[((Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\\x5d]*)\\]\\] (\\S*) (http:\\/\\/en\\.wikipedia\\.org\\/w\\/index\\.php\\?(oldid|diff)=(\\d*)&(rcid|oldid)=(\\d*).*|http:\\/\\/en\\.wikipedia\\.org\\/wiki\\/\\S+)? \\* ([^*]*) \\* (\\(([^)]*)\\))? (.*)$/S'",
",",
"$",
"msg",
",",
"$",
"m",
")",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"//print_r($m);",
"$",
"return",
"[",
"'namespace'",
"]",
"=",
"$",
"m",
"[",
"2",
"]",
";",
"$",
"return",
"[",
"'pagename'",
"]",
"=",
"$",
"m",
"[",
"5",
"]",
";",
"$",
"return",
"[",
"'fullpagename'",
"]",
"=",
"$",
"m",
"[",
"1",
"]",
".",
"$",
"m",
"[",
"5",
"]",
";",
"$",
"return",
"[",
"'basepagename'",
"]",
"=",
"explode",
"(",
"'/'",
",",
"$",
"return",
"[",
"'fullpagename'",
"]",
")",
";",
"$",
"return",
"[",
"'basepagename'",
"]",
"=",
"$",
"return",
"[",
"'basepagename'",
"]",
"[",
"0",
"]",
";",
"$",
"return",
"[",
"'subpagename'",
"]",
"=",
"str_replace",
"(",
"$",
"return",
"[",
"'basepagename'",
"]",
".",
"'/'",
",",
"''",
",",
"$",
"return",
"[",
"'fullpagename'",
"]",
")",
";",
"$",
"return",
"[",
"'flags'",
"]",
"=",
"str_split",
"(",
"$",
"m",
"[",
"6",
"]",
")",
";",
"$",
"return",
"[",
"'action'",
"]",
"=",
"$",
"m",
"[",
"6",
"]",
";",
"$",
"return",
"[",
"'url'",
"]",
"=",
"$",
"m",
"[",
"7",
"]",
";",
"$",
"return",
"[",
"'revid'",
"]",
"=",
"$",
"m",
"[",
"9",
"]",
";",
"$",
"return",
"[",
"'oldid'",
"]",
"=",
"$",
"m",
"[",
"11",
"]",
";",
"$",
"return",
"[",
"'username'",
"]",
"=",
"$",
"m",
"[",
"12",
"]",
";",
"$",
"return",
"[",
"'len'",
"]",
"=",
"$",
"m",
"[",
"14",
"]",
";",
"$",
"return",
"[",
"'comment'",
"]",
"=",
"$",
"m",
"[",
"15",
"]",
";",
"$",
"return",
"[",
"'timestamp'",
"]",
"=",
"time",
"(",
")",
";",
"$",
"return",
"[",
"'is_new'",
"]",
"=",
"false",
";",
"$",
"return",
"[",
"'is_minor'",
"]",
"=",
"false",
";",
"$",
"return",
"[",
"'is_bot'",
"]",
"=",
"false",
";",
"$",
"return",
"[",
"'is_delete'",
"]",
"=",
"false",
";",
"$",
"return",
"[",
"'actionpage'",
"]",
"=",
"null",
";",
"if",
"(",
"in_array",
"(",
"'N'",
",",
"$",
"return",
"[",
"'flags'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"'is_new'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"in_array",
"(",
"'M'",
",",
"$",
"return",
"[",
"'flags'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"'is_minor'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"in_array",
"(",
"'B'",
",",
"$",
"return",
"[",
"'flags'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"'is_bot'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"return",
"[",
"'action'",
"]",
"==",
"'delete'",
")",
"{",
"$",
"return",
"[",
"'is_delete'",
"]",
"=",
"true",
";",
"$",
"tmp",
"=",
"explode",
"(",
"'[['",
",",
"$",
"return",
"[",
"'comment'",
"]",
")",
";",
"$",
"tmp",
"=",
"explode",
"(",
"']]'",
",",
"$",
"tmp",
"[",
"1",
"]",
")",
";",
"$",
"return",
"[",
"'actionpage'",
"]",
"=",
"$",
"tmp",
"[",
"0",
"]",
";",
"$",
"return",
"[",
"'actionpageprefix'",
"]",
"=",
"explode",
"(",
"'/'",
",",
"$",
"return",
"[",
"'actionpage'",
"]",
")",
";",
"$",
"return",
"[",
"'actionpageprefix'",
"]",
"=",
"$",
"return",
"[",
"'actionpageprefix'",
"]",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}",
"}"
] |
Parses the title, user, etc from a MediaWiki RC feed
@link http://www.mediawiki.org/wiki/Manual:IRC_RC_Bot
@param string $msg Message from feed
@return array Parsed line
@static
|
[
"Parses",
"the",
"title",
"user",
"etc",
"from",
"a",
"MediaWiki",
"RC",
"feed"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/IRC.php#L232-L283
|
233,807
|
matrozov/yii2-couchbase
|
src/Connection.php
|
Connection.getBucket
|
public function getBucket($bucketName = null, $password = null)
{
if ($bucketName === null) {
$bucketName = $this->defaultBucket;
}
if (!array_key_exists($bucketName, $this->_buckets)) {
$this->_buckets[$bucketName] = $this->selectBucket($bucketName, $password);
}
return $this->_buckets[$bucketName];
}
|
php
|
public function getBucket($bucketName = null, $password = null)
{
if ($bucketName === null) {
$bucketName = $this->defaultBucket;
}
if (!array_key_exists($bucketName, $this->_buckets)) {
$this->_buckets[$bucketName] = $this->selectBucket($bucketName, $password);
}
return $this->_buckets[$bucketName];
}
|
[
"public",
"function",
"getBucket",
"(",
"$",
"bucketName",
"=",
"null",
",",
"$",
"password",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"bucketName",
"===",
"null",
")",
"{",
"$",
"bucketName",
"=",
"$",
"this",
"->",
"defaultBucket",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"bucketName",
",",
"$",
"this",
"->",
"_buckets",
")",
")",
"{",
"$",
"this",
"->",
"_buckets",
"[",
"$",
"bucketName",
"]",
"=",
"$",
"this",
"->",
"selectBucket",
"(",
"$",
"bucketName",
",",
"$",
"password",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_buckets",
"[",
"$",
"bucketName",
"]",
";",
"}"
] |
Returns the Couchbase bucket with the given name.
@param string $bucketName bucket name. If string considered as the name of the bucket
inside the default database. If array - first element considered as the name of the database,
second - as name of bucket inside that database
@param string $password bucket password
@return Bucket Couchbase basket instance.
@throws Exception
@throws InvalidConfigException
|
[
"Returns",
"the",
"Couchbase",
"bucket",
"with",
"the",
"given",
"name",
"."
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L131-L142
|
233,808
|
matrozov/yii2-couchbase
|
src/Connection.php
|
Connection.selectBucket
|
protected function selectBucket($name, $password = '')
{
$this->open();
try {
$bucket = $this->cluster->openBucket($name, $password);
}
catch (\Exception $e) {
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
return Yii::createObject([
'class' => 'matrozov\couchbase\Bucket',
'db' => $this,
'name' => $name,
'bucket' => $bucket,
]);
}
|
php
|
protected function selectBucket($name, $password = '')
{
$this->open();
try {
$bucket = $this->cluster->openBucket($name, $password);
}
catch (\Exception $e) {
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
return Yii::createObject([
'class' => 'matrozov\couchbase\Bucket',
'db' => $this,
'name' => $name,
'bucket' => $bucket,
]);
}
|
[
"protected",
"function",
"selectBucket",
"(",
"$",
"name",
",",
"$",
"password",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"open",
"(",
")",
";",
"try",
"{",
"$",
"bucket",
"=",
"$",
"this",
"->",
"cluster",
"->",
"openBucket",
"(",
"$",
"name",
",",
"$",
"password",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"(",
"int",
")",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"return",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"'matrozov\\couchbase\\Bucket'",
",",
"'db'",
"=>",
"$",
"this",
",",
"'name'",
"=>",
"$",
"name",
",",
"'bucket'",
"=>",
"$",
"bucket",
",",
"]",
")",
";",
"}"
] |
Selects bucket with given name and password.
@param string $name bucket name.
@param string $password bucket password.
@return Bucket|null bucket instance.
@throws Exception
@throws InvalidConfigException
|
[
"Selects",
"bucket",
"with",
"given",
"name",
"and",
"password",
"."
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L154-L171
|
233,809
|
matrozov/yii2-couchbase
|
src/Connection.php
|
Connection.open
|
public function open()
{
if ($this->cluster !== null) {
return;
}
if (empty($this->dsn)) {
throw new InvalidConfigException($this->className() . '::dsn cannot be empty.');
}
$token = 'Opening Couchbase connection: ' . $this->dsn;
try {
Yii::trace($token, __METHOD__);
Yii::beginProfile($token, __METHOD__);
$this->cluster = new Cluster($this->dsn);
$this->initConnection();
Yii::endProfile($token, __METHOD__);
}
catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
}
|
php
|
public function open()
{
if ($this->cluster !== null) {
return;
}
if (empty($this->dsn)) {
throw new InvalidConfigException($this->className() . '::dsn cannot be empty.');
}
$token = 'Opening Couchbase connection: ' . $this->dsn;
try {
Yii::trace($token, __METHOD__);
Yii::beginProfile($token, __METHOD__);
$this->cluster = new Cluster($this->dsn);
$this->initConnection();
Yii::endProfile($token, __METHOD__);
}
catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
}
|
[
"public",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cluster",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"dsn",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"$",
"this",
"->",
"className",
"(",
")",
".",
"'::dsn cannot be empty.'",
")",
";",
"}",
"$",
"token",
"=",
"'Opening Couchbase connection: '",
".",
"$",
"this",
"->",
"dsn",
";",
"try",
"{",
"Yii",
"::",
"trace",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"Yii",
"::",
"beginProfile",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"$",
"this",
"->",
"cluster",
"=",
"new",
"Cluster",
"(",
"$",
"this",
"->",
"dsn",
")",
";",
"$",
"this",
"->",
"initConnection",
"(",
")",
";",
"Yii",
"::",
"endProfile",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"Yii",
"::",
"endProfile",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"(",
"int",
")",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Establishes a Couchbase connection.
It does nothing if a Couchbase connection has already been established.
@throws Exception if connection fails
@throws InvalidConfigException
|
[
"Establishes",
"a",
"Couchbase",
"connection",
".",
"It",
"does",
"nothing",
"if",
"a",
"Couchbase",
"connection",
"has",
"already",
"been",
"established",
"."
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L208-L235
|
233,810
|
matrozov/yii2-couchbase
|
src/Connection.php
|
Connection.openManager
|
public function openManager()
{
if ($this->manager !== null) {
return;
}
if ($this->cluster === null) {
$this->open();
}
if (empty($this->userName) || empty($this->password)) {
throw new InvalidConfigException($this->className() . '::userName/password cannot be empty.');
}
$token = 'Opening CouchbaseManager: ' . $this->userName;
try {
Yii::trace($token, __METHOD__);
Yii::beginProfile($token, __METHOD__);
$this->manager = $this->cluster->manager($this->userName, $this->password);
Yii::endProfile($token, __METHOD__);
}
catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
}
|
php
|
public function openManager()
{
if ($this->manager !== null) {
return;
}
if ($this->cluster === null) {
$this->open();
}
if (empty($this->userName) || empty($this->password)) {
throw new InvalidConfigException($this->className() . '::userName/password cannot be empty.');
}
$token = 'Opening CouchbaseManager: ' . $this->userName;
try {
Yii::trace($token, __METHOD__);
Yii::beginProfile($token, __METHOD__);
$this->manager = $this->cluster->manager($this->userName, $this->password);
Yii::endProfile($token, __METHOD__);
}
catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
}
|
[
"public",
"function",
"openManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"manager",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"cluster",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"open",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"userName",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"password",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"$",
"this",
"->",
"className",
"(",
")",
".",
"'::userName/password cannot be empty.'",
")",
";",
"}",
"$",
"token",
"=",
"'Opening CouchbaseManager: '",
".",
"$",
"this",
"->",
"userName",
";",
"try",
"{",
"Yii",
"::",
"trace",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"Yii",
"::",
"beginProfile",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"$",
"this",
"->",
"manager",
"=",
"$",
"this",
"->",
"cluster",
"->",
"manager",
"(",
"$",
"this",
"->",
"userName",
",",
"$",
"this",
"->",
"password",
")",
";",
"Yii",
"::",
"endProfile",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"Yii",
"::",
"endProfile",
"(",
"$",
"token",
",",
"__METHOD__",
")",
";",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"(",
"int",
")",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Open a CouchbaseManager.
It does nothing if a CouchbaseManager has already been opened.
@throws Exception if open fails
@throws InvalidConfigException
|
[
"Open",
"a",
"CouchbaseManager",
".",
"It",
"does",
"nothing",
"if",
"a",
"CouchbaseManager",
"has",
"already",
"been",
"opened",
"."
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L243-L272
|
233,811
|
matrozov/yii2-couchbase
|
src/Connection.php
|
Connection.createBucket
|
public function createBucket($bucketName, array $options = [])
{
$this->openManager();
$this->manager->createBucket($bucketName, $options);
// ToDo: https://github.com/matrozov/yii2-couchbase/issues/1
sleep(5);
}
|
php
|
public function createBucket($bucketName, array $options = [])
{
$this->openManager();
$this->manager->createBucket($bucketName, $options);
// ToDo: https://github.com/matrozov/yii2-couchbase/issues/1
sleep(5);
}
|
[
"public",
"function",
"createBucket",
"(",
"$",
"bucketName",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"openManager",
"(",
")",
";",
"$",
"this",
"->",
"manager",
"->",
"createBucket",
"(",
"$",
"bucketName",
",",
"$",
"options",
")",
";",
"// ToDo: https://github.com/matrozov/yii2-couchbase/issues/1",
"sleep",
"(",
"5",
")",
";",
"}"
] |
Creates new bucket in database associated with this command.s
@param string $bucketName bucket name
@param array $options bucket options in format: "name" => "value"
@throws Exception
@throws InvalidConfigException
|
[
"Creates",
"new",
"bucket",
"in",
"database",
"associated",
"with",
"this",
"command",
".",
"s"
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L391-L399
|
233,812
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Controllers/LoginController.php
|
LoginController.store
|
public function store()
{
$email = mb_strtolower(Input::get('email'));
$password = Input::get('password');
if ($this->users->login($email, $password, Input::get('remember') == 'yes'))
{
return Redirect::route('wardrobe.admin.index');
}
return Redirect::back()
->withInput()
->with('login_errors', true);
}
|
php
|
public function store()
{
$email = mb_strtolower(Input::get('email'));
$password = Input::get('password');
if ($this->users->login($email, $password, Input::get('remember') == 'yes'))
{
return Redirect::route('wardrobe.admin.index');
}
return Redirect::back()
->withInput()
->with('login_errors', true);
}
|
[
"public",
"function",
"store",
"(",
")",
"{",
"$",
"email",
"=",
"mb_strtolower",
"(",
"Input",
"::",
"get",
"(",
"'email'",
")",
")",
";",
"$",
"password",
"=",
"Input",
"::",
"get",
"(",
"'password'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"users",
"->",
"login",
"(",
"$",
"email",
",",
"$",
"password",
",",
"Input",
"::",
"get",
"(",
"'remember'",
")",
"==",
"'yes'",
")",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'wardrobe.admin.index'",
")",
";",
"}",
"return",
"Redirect",
"::",
"back",
"(",
")",
"->",
"withInput",
"(",
")",
"->",
"with",
"(",
"'login_errors'",
",",
"true",
")",
";",
"}"
] |
Handle a user login attempt.
|
[
"Handle",
"a",
"user",
"login",
"attempt",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/LoginController.php#L41-L55
|
233,813
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Controllers/LoginController.php
|
LoginController.remindSend
|
public function remindSend()
{
$credentials = array('email' => Input::get('email'));
return Password::remind($credentials, function($message, $user)
{
$message->subject('Reset your password');
});
}
|
php
|
public function remindSend()
{
$credentials = array('email' => Input::get('email'));
return Password::remind($credentials, function($message, $user)
{
$message->subject('Reset your password');
});
}
|
[
"public",
"function",
"remindSend",
"(",
")",
"{",
"$",
"credentials",
"=",
"array",
"(",
"'email'",
"=>",
"Input",
"::",
"get",
"(",
"'email'",
")",
")",
";",
"return",
"Password",
"::",
"remind",
"(",
"$",
"credentials",
",",
"function",
"(",
"$",
"message",
",",
"$",
"user",
")",
"{",
"$",
"message",
"->",
"subject",
"(",
"'Reset your password'",
")",
";",
"}",
")",
";",
"}"
] |
Send an email to reset your password.
|
[
"Send",
"an",
"email",
"to",
"reset",
"your",
"password",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/LoginController.php#L77-L85
|
233,814
|
budde377/Part
|
lib/util/task/ExecuteDelayedExecutionTaskQueueTaskImpl.php
|
ExecuteDelayedExecutionTaskQueueTaskImpl.execute
|
public function execute()
{
$queue = $this->container->getDelayedExecutionTaskQueue();
if($queue->length() == 0){
return;
}
ignore_user_abort(true);
$queue->execute();
}
|
php
|
public function execute()
{
$queue = $this->container->getDelayedExecutionTaskQueue();
if($queue->length() == 0){
return;
}
ignore_user_abort(true);
$queue->execute();
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"queue",
"=",
"$",
"this",
"->",
"container",
"->",
"getDelayedExecutionTaskQueue",
"(",
")",
";",
"if",
"(",
"$",
"queue",
"->",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"ignore_user_abort",
"(",
"true",
")",
";",
"$",
"queue",
"->",
"execute",
"(",
")",
";",
"}"
] |
This function runs the script
@return mixed
|
[
"This",
"function",
"runs",
"the",
"script"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/task/ExecuteDelayedExecutionTaskQueueTaskImpl.php#L31-L39
|
233,815
|
yeephp/yeephp
|
Yee/Middleware/Flash.php
|
Flash.loadMessages
|
public function loadMessages()
{
if (isset($_SESSION[$this->settings['key']])) {
$this->messages['prev'] = $_SESSION[$this->settings['key']];
}
}
|
php
|
public function loadMessages()
{
if (isset($_SESSION[$this->settings['key']])) {
$this->messages['prev'] = $_SESSION[$this->settings['key']];
}
}
|
[
"public",
"function",
"loadMessages",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"settings",
"[",
"'key'",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"'prev'",
"]",
"=",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"settings",
"[",
"'key'",
"]",
"]",
";",
"}",
"}"
] |
Load messages from previous request if available
|
[
"Load",
"messages",
"from",
"previous",
"request",
"if",
"available"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Middleware/Flash.php#L138-L143
|
233,816
|
yeephp/yeephp
|
Yee/Helper/Set.php
|
Set.singleton
|
public function singleton($key, $value)
{
$this->set($key, function ($c) use ($value) {
static $object;
if (null === $object) {
$object = $value($c);
}
return $object;
});
}
|
php
|
public function singleton($key, $value)
{
$this->set($key, function ($c) use ($value) {
static $object;
if (null === $object) {
$object = $value($c);
}
return $object;
});
}
|
[
"public",
"function",
"singleton",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"value",
")",
"{",
"static",
"$",
"object",
";",
"if",
"(",
"null",
"===",
"$",
"object",
")",
"{",
"$",
"object",
"=",
"$",
"value",
"(",
"$",
"c",
")",
";",
"}",
"return",
"$",
"object",
";",
"}",
")",
";",
"}"
] |
Ensure a value or object will remain globally unique
@param string $key The value or object name
@param Closure The closure that defines the object
@return mixed
|
[
"Ensure",
"a",
"value",
"or",
"object",
"will",
"remain",
"globally",
"unique"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Helper/Set.php#L222-L233
|
233,817
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php
|
ServiceDescriptorProtoMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ServiceDescriptorProto();
case 1:
return new ServiceDescriptorProto(func_get_arg(0));
case 2:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ServiceDescriptorProto();
case 1:
return new ServiceDescriptorProto(func_get_arg(0));
case 2:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\ServiceDescriptorProto
@throws \InvalidArgumentException
@return ServiceDescriptorProto
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L59-L83
|
233,818
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php
|
ServiceDescriptorProtoMeta.reset
|
public static function reset($object)
{
if (!($object instanceof ServiceDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceDescriptorProto.');
}
$object->name = NULL;
$object->method = NULL;
$object->options = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof ServiceDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceDescriptorProto.');
}
$object->name = NULL;
$object->method = NULL;
$object->options = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"ServiceDescriptorProto",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\ServiceDescriptorProto.'",
")",
";",
"}",
"$",
"object",
"->",
"name",
"=",
"NULL",
";",
"$",
"object",
"->",
"method",
"=",
"NULL",
";",
"$",
"object",
"->",
"options",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\ServiceDescriptorProto to default values
@param ServiceDescriptorProto $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L96-L104
|
233,819
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php
|
ServiceDescriptorProtoMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
hash_update($ctx, (string)$object->name);
}
if (isset($object->method)) {
hash_update($ctx, 'method');
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $v0) {
MethodDescriptorProtoMeta::hash($v0, $ctx);
}
}
if (isset($object->options)) {
hash_update($ctx, 'options');
ServiceOptionsMeta::hash($object->options, $ctx);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
php
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
hash_update($ctx, (string)$object->name);
}
if (isset($object->method)) {
hash_update($ctx, 'method');
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $v0) {
MethodDescriptorProtoMeta::hash($v0, $ctx);
}
}
if (isset($object->options)) {
hash_update($ctx, 'options');
ServiceOptionsMeta::hash($object->options, $ctx);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrCtx",
")",
";",
"}",
"else",
"{",
"$",
"ctx",
"=",
"$",
"algoOrCtx",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"name",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'name'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"name",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"method",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'method'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"method",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"method",
":",
"(",
"array",
")",
"$",
"object",
"->",
"method",
"as",
"$",
"v0",
")",
"{",
"MethodDescriptorProtoMeta",
"::",
"hash",
"(",
"$",
"v0",
",",
"$",
"ctx",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"options",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'options'",
")",
";",
"ServiceOptionsMeta",
"::",
"hash",
"(",
"$",
"object",
"->",
"options",
",",
"$",
"ctx",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\ServiceDescriptorProto
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L116-L146
|
233,820
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php
|
ServiceDescriptorProtoMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->name) && ($filter === null || isset($filter['name']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->name));
$output .= $object->name;
}
if (isset($object->method) && ($filter === null || isset($filter['method']))) {
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $k => $v) {
$output .= "\x12";
$buffer = MethodDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['method']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x1a";
$buffer = ServiceOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->name) && ($filter === null || isset($filter['name']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->name));
$output .= $object->name;
}
if (isset($object->method) && ($filter === null || isset($filter['method']))) {
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $k => $v) {
$output .= "\x12";
$buffer = MethodDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['method']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x1a";
$buffer = ServiceOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"name",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'name'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x0a\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"name",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"name",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"method",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'method'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"method",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"method",
":",
"(",
"array",
")",
"$",
"object",
"->",
"method",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\x12\"",
";",
"$",
"buffer",
"=",
"MethodDescriptorProtoMeta",
"::",
"toProtobuf",
"(",
"$",
"v",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'method'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"options",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'options'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x1a\"",
";",
"$",
"buffer",
"=",
"ServiceOptionsMeta",
"::",
"toProtobuf",
"(",
"$",
"object",
"->",
"options",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'options'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\ServiceDescriptorProto to Protocol Buffers message.
@param ServiceDescriptorProto $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L256-L283
|
233,821
|
budde377/Part
|
lib/model/site/SiteImpl.php
|
SiteImpl.getVariables
|
public function getVariables()
{
return $this->variables == null?$this->variables = new SiteVariablesImpl($this->db):$this->variables;
}
|
php
|
public function getVariables()
{
return $this->variables == null?$this->variables = new SiteVariablesImpl($this->db):$this->variables;
}
|
[
"public",
"function",
"getVariables",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"variables",
"==",
"null",
"?",
"$",
"this",
"->",
"variables",
"=",
"new",
"SiteVariablesImpl",
"(",
"$",
"this",
"->",
"db",
")",
":",
"$",
"this",
"->",
"variables",
";",
"}"
] |
Returns and reuses instance of site scoped variables
@return Variables
|
[
"Returns",
"and",
"reuses",
"instance",
"of",
"site",
"scoped",
"variables"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/site/SiteImpl.php#L46-L49
|
233,822
|
budde377/Part
|
lib/model/site/SiteImpl.php
|
SiteImpl.lastModified
|
public function lastModified()
{
return $this->lastMod == 0?$this->lastMod = $this->getVariables()->getValue("last_modified"):$this->lastMod;
}
|
php
|
public function lastModified()
{
return $this->lastMod == 0?$this->lastMod = $this->getVariables()->getValue("last_modified"):$this->lastMod;
}
|
[
"public",
"function",
"lastModified",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"lastMod",
"==",
"0",
"?",
"$",
"this",
"->",
"lastMod",
"=",
"$",
"this",
"->",
"getVariables",
"(",
")",
"->",
"getValue",
"(",
"\"last_modified\"",
")",
":",
"$",
"this",
"->",
"lastMod",
";",
"}"
] |
Returns last modified timestamp, 0 if site hasnot been modified
@return int 0
|
[
"Returns",
"last",
"modified",
"timestamp",
"0",
"if",
"site",
"hasnot",
"been",
"modified"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/site/SiteImpl.php#L55-L58
|
233,823
|
budde377/Part
|
lib/model/site/SiteImpl.php
|
SiteImpl.getContentLibrary
|
public function getContentLibrary()
{
return $this->contentLibrary == null?
$this->contentLibrary = new SiteContentLibraryImpl($this->container):
$this->contentLibrary;
}
|
php
|
public function getContentLibrary()
{
return $this->contentLibrary == null?
$this->contentLibrary = new SiteContentLibraryImpl($this->container):
$this->contentLibrary;
}
|
[
"public",
"function",
"getContentLibrary",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"contentLibrary",
"==",
"null",
"?",
"$",
"this",
"->",
"contentLibrary",
"=",
"new",
"SiteContentLibraryImpl",
"(",
"$",
"this",
"->",
"container",
")",
":",
"$",
"this",
"->",
"contentLibrary",
";",
"}"
] |
Will get and reuse instance of content library.
@return ContentLibrary
|
[
"Will",
"get",
"and",
"reuse",
"instance",
"of",
"content",
"library",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/site/SiteImpl.php#L75-L80
|
233,824
|
matrozov/yii2-couchbase
|
src/ActiveQuery.php
|
ActiveQuery.getBucket
|
public function getBucket($db = null)
{
/* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
}
if ($this->select === null) {
$bucketName = $db->quoteBucketName($modelClass::bucketName());
$primaryModel = $this->primaryModel ?: ActiveRecord::className();
$primaryKey = $primaryModel::primaryKey()[0];
$primaryKey = $db->quoteColumnName($primaryKey);
$this->select = "meta($bucketName).id AS $primaryKey, $bucketName.*";
}
if ($this->from === null) {
$this->from = $modelClass::bucketName();
}
return $db->getBucket($this->from);
}
|
php
|
public function getBucket($db = null)
{
/* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
}
if ($this->select === null) {
$bucketName = $db->quoteBucketName($modelClass::bucketName());
$primaryModel = $this->primaryModel ?: ActiveRecord::className();
$primaryKey = $primaryModel::primaryKey()[0];
$primaryKey = $db->quoteColumnName($primaryKey);
$this->select = "meta($bucketName).id AS $primaryKey, $bucketName.*";
}
if ($this->from === null) {
$this->from = $modelClass::bucketName();
}
return $db->getBucket($this->from);
}
|
[
"public",
"function",
"getBucket",
"(",
"$",
"db",
"=",
"null",
")",
"{",
"/* @var $modelClass ActiveRecord */",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"modelClass",
";",
"if",
"(",
"$",
"db",
"===",
"null",
")",
"{",
"$",
"db",
"=",
"$",
"modelClass",
"::",
"getDb",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"select",
"===",
"null",
")",
"{",
"$",
"bucketName",
"=",
"$",
"db",
"->",
"quoteBucketName",
"(",
"$",
"modelClass",
"::",
"bucketName",
"(",
")",
")",
";",
"$",
"primaryModel",
"=",
"$",
"this",
"->",
"primaryModel",
"?",
":",
"ActiveRecord",
"::",
"className",
"(",
")",
";",
"$",
"primaryKey",
"=",
"$",
"primaryModel",
"::",
"primaryKey",
"(",
")",
"[",
"0",
"]",
";",
"$",
"primaryKey",
"=",
"$",
"db",
"->",
"quoteColumnName",
"(",
"$",
"primaryKey",
")",
";",
"$",
"this",
"->",
"select",
"=",
"\"meta($bucketName).id AS $primaryKey, $bucketName.*\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"from",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"from",
"=",
"$",
"modelClass",
"::",
"bucketName",
"(",
")",
";",
"}",
"return",
"$",
"db",
"->",
"getBucket",
"(",
"$",
"this",
"->",
"from",
")",
";",
"}"
] |
Returns the Couchbase bucket for this query.
@param Connection $db Couchbase connection.
@return Bucket bucket instance.
@throws Exception
@throws \yii\base\InvalidConfigException
|
[
"Returns",
"the",
"Couchbase",
"bucket",
"for",
"this",
"query",
"."
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveQuery.php#L188-L213
|
233,825
|
xylemical/php-expressions
|
src/Parser.php
|
Parser.parse
|
public function parse($string) {
$output = new \SplQueue();
$operator = new \SplStack();
// Convert the string to tokens for the lexer.
$tokens = $this->lexer->tokenize($string);
// while there are tokens to be read:
while (count($tokens)) {
// read a token.
$token = array_shift($tokens);
// if the token is a number, then push it to the output queue.
if ($token->isValue()) {
$output->push($token);
continue;
}
// if the token is a function, then push it onto the operator stack.
if ($token->isFunction()) {
$operator->push($token);
continue;
}
// if the token is a function argument separator:
if ($token->getValue() === ',') {
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
$output->push($operator->pop());
}
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
continue;
}
// if the token is an operator, then:
if ($token->isOperator()) {
// while (
// (there is an operator at the top of the operator stack with greater precedence) or
// (the operator at the top of the operator stack has equal precedence and the operator is left associative)) and
// (the operator at the top of the stack is not a left bracket):
// pop operators from the operator stack, onto the output queue.
while (($op = $this->getTop($operator)) && $op->isOperator() && $token->hasHigherPriority($op)) {
$output->push($operator->pop());
}
// push the read operator onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a left bracket (i.e. "("), then:
if ($token->getValue() === '(') {
// push it onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a right bracket (i.e. ")"), then:
if ($token->getValue() === ')') {
// while the operator at the top of the operator stack is not a left bracket:
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
// pop operators from the operator stack onto the output queue.
$output->push($operator->pop());
}
// /* if the stack runs out without finding a left bracket, then there are mismatched parentheses. */
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses');
}
// pop the left bracket from the stack.
$operator->pop();
// If the token at the top of the stack is a function token, pop it onto the output queue.
if (($op = $this->getTop($operator)) && $op->isFunction()) {
$output->push($operator->pop());
}
}
}
// if there are no more tokens to read:
// while there are still operator tokens on the stack:
while (!$operator->isEmpty()) {
// /* if the operator token on the top of the stack is a bracket, then there are mismatched parentheses. */
if (is_null($operator->top()->getOperator())) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
// pop the operator onto the output queue.
$output->push($operator->pop());
}
// exit.
return iterator_to_array($output);
}
|
php
|
public function parse($string) {
$output = new \SplQueue();
$operator = new \SplStack();
// Convert the string to tokens for the lexer.
$tokens = $this->lexer->tokenize($string);
// while there are tokens to be read:
while (count($tokens)) {
// read a token.
$token = array_shift($tokens);
// if the token is a number, then push it to the output queue.
if ($token->isValue()) {
$output->push($token);
continue;
}
// if the token is a function, then push it onto the operator stack.
if ($token->isFunction()) {
$operator->push($token);
continue;
}
// if the token is a function argument separator:
if ($token->getValue() === ',') {
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
$output->push($operator->pop());
}
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
continue;
}
// if the token is an operator, then:
if ($token->isOperator()) {
// while (
// (there is an operator at the top of the operator stack with greater precedence) or
// (the operator at the top of the operator stack has equal precedence and the operator is left associative)) and
// (the operator at the top of the stack is not a left bracket):
// pop operators from the operator stack, onto the output queue.
while (($op = $this->getTop($operator)) && $op->isOperator() && $token->hasHigherPriority($op)) {
$output->push($operator->pop());
}
// push the read operator onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a left bracket (i.e. "("), then:
if ($token->getValue() === '(') {
// push it onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a right bracket (i.e. ")"), then:
if ($token->getValue() === ')') {
// while the operator at the top of the operator stack is not a left bracket:
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
// pop operators from the operator stack onto the output queue.
$output->push($operator->pop());
}
// /* if the stack runs out without finding a left bracket, then there are mismatched parentheses. */
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses');
}
// pop the left bracket from the stack.
$operator->pop();
// If the token at the top of the stack is a function token, pop it onto the output queue.
if (($op = $this->getTop($operator)) && $op->isFunction()) {
$output->push($operator->pop());
}
}
}
// if there are no more tokens to read:
// while there are still operator tokens on the stack:
while (!$operator->isEmpty()) {
// /* if the operator token on the top of the stack is a bracket, then there are mismatched parentheses. */
if (is_null($operator->top()->getOperator())) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
// pop the operator onto the output queue.
$output->push($operator->pop());
}
// exit.
return iterator_to_array($output);
}
|
[
"public",
"function",
"parse",
"(",
"$",
"string",
")",
"{",
"$",
"output",
"=",
"new",
"\\",
"SplQueue",
"(",
")",
";",
"$",
"operator",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"// Convert the string to tokens for the lexer.",
"$",
"tokens",
"=",
"$",
"this",
"->",
"lexer",
"->",
"tokenize",
"(",
"$",
"string",
")",
";",
"// while there are tokens to be read:",
"while",
"(",
"count",
"(",
"$",
"tokens",
")",
")",
"{",
"// read a token.",
"$",
"token",
"=",
"array_shift",
"(",
"$",
"tokens",
")",
";",
"// if the token is a number, then push it to the output queue.",
"if",
"(",
"$",
"token",
"->",
"isValue",
"(",
")",
")",
"{",
"$",
"output",
"->",
"push",
"(",
"$",
"token",
")",
";",
"continue",
";",
"}",
"// if the token is a function, then push it onto the operator stack.",
"if",
"(",
"$",
"token",
"->",
"isFunction",
"(",
")",
")",
"{",
"$",
"operator",
"->",
"push",
"(",
"$",
"token",
")",
";",
"continue",
";",
"}",
"// if the token is a function argument separator:",
"if",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
"===",
"','",
")",
"{",
"while",
"(",
"(",
"$",
"op",
"=",
"$",
"this",
"->",
"getTop",
"(",
"$",
"operator",
")",
")",
"&&",
"$",
"op",
"->",
"getValue",
"(",
")",
"!==",
"'('",
")",
"{",
"$",
"output",
"->",
"push",
"(",
"$",
"operator",
"->",
"pop",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"operator",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Mismatched parentheses or misplaced comma.'",
")",
";",
"}",
"continue",
";",
"}",
"// if the token is an operator, then:",
"if",
"(",
"$",
"token",
"->",
"isOperator",
"(",
")",
")",
"{",
"// while (",
"// (there is an operator at the top of the operator stack with greater precedence) or",
"// (the operator at the top of the operator stack has equal precedence and the operator is left associative)) and",
"// (the operator at the top of the stack is not a left bracket):",
"// pop operators from the operator stack, onto the output queue.",
"while",
"(",
"(",
"$",
"op",
"=",
"$",
"this",
"->",
"getTop",
"(",
"$",
"operator",
")",
")",
"&&",
"$",
"op",
"->",
"isOperator",
"(",
")",
"&&",
"$",
"token",
"->",
"hasHigherPriority",
"(",
"$",
"op",
")",
")",
"{",
"$",
"output",
"->",
"push",
"(",
"$",
"operator",
"->",
"pop",
"(",
")",
")",
";",
"}",
"// push the read operator onto the operator stack.",
"$",
"operator",
"->",
"push",
"(",
"$",
"token",
")",
";",
"continue",
";",
"}",
"// if the token is a left bracket (i.e. \"(\"), then:",
"if",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
"===",
"'('",
")",
"{",
"// push it onto the operator stack.",
"$",
"operator",
"->",
"push",
"(",
"$",
"token",
")",
";",
"continue",
";",
"}",
"// if the token is a right bracket (i.e. \")\"), then:",
"if",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
"===",
"')'",
")",
"{",
"// while the operator at the top of the operator stack is not a left bracket:",
"while",
"(",
"(",
"$",
"op",
"=",
"$",
"this",
"->",
"getTop",
"(",
"$",
"operator",
")",
")",
"&&",
"$",
"op",
"->",
"getValue",
"(",
")",
"!==",
"'('",
")",
"{",
"// pop operators from the operator stack onto the output queue.",
"$",
"output",
"->",
"push",
"(",
"$",
"operator",
"->",
"pop",
"(",
")",
")",
";",
"}",
"// /* if the stack runs out without finding a left bracket, then there are mismatched parentheses. */",
"if",
"(",
"$",
"operator",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Mismatched parentheses'",
")",
";",
"}",
"// pop the left bracket from the stack.",
"$",
"operator",
"->",
"pop",
"(",
")",
";",
"// If the token at the top of the stack is a function token, pop it onto the output queue.",
"if",
"(",
"(",
"$",
"op",
"=",
"$",
"this",
"->",
"getTop",
"(",
"$",
"operator",
")",
")",
"&&",
"$",
"op",
"->",
"isFunction",
"(",
")",
")",
"{",
"$",
"output",
"->",
"push",
"(",
"$",
"operator",
"->",
"pop",
"(",
")",
")",
";",
"}",
"}",
"}",
"// if there are no more tokens to read:",
"// while there are still operator tokens on the stack:",
"while",
"(",
"!",
"$",
"operator",
"->",
"isEmpty",
"(",
")",
")",
"{",
"// /* if the operator token on the top of the stack is a bracket, then there are mismatched parentheses. */",
"if",
"(",
"is_null",
"(",
"$",
"operator",
"->",
"top",
"(",
")",
"->",
"getOperator",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Mismatched parentheses or misplaced comma.'",
")",
";",
"}",
"// pop the operator onto the output queue.",
"$",
"output",
"->",
"push",
"(",
"$",
"operator",
"->",
"pop",
"(",
")",
")",
";",
"}",
"// exit.",
"return",
"iterator_to_array",
"(",
"$",
"output",
")",
";",
"}"
] |
Parses a string into a series of tokens in Reverse Polish Notation order.
@param string $string
@return \Xylemical\Expressions\Token[]
@throws \Xylemical\Expressions\ParserException
@see https://en.wikipedia.org/wiki/Shunting-yard_algorithm
|
[
"Parses",
"a",
"string",
"into",
"a",
"series",
"of",
"tokens",
"in",
"Reverse",
"Polish",
"Notation",
"order",
"."
] |
4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73
|
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Parser.php#L58-L155
|
233,826
|
scherersoftware/cake-model-history
|
src/Model/Table/ModelHistoryTable.php
|
ModelHistoryTable._transformDataFields
|
protected function _transformDataFields(array $history, string $model): array
{
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\\' . ucfirst($model) . 'Table'];
$model = ucfirst($model) . 'Table';
}
$fieldConfig = TableRegistry::get($model, $tableConfig)->getFields();
foreach ($history as $index => $entity) {
$entityData = $entity->data;
foreach ($entityData as $field => $value) {
if (!isset($fieldConfig[$field]) || $fieldConfig[$field]['searchable'] !== true) {
continue;
}
if (isset($fieldConfig[$field]['displayParser']) && is_callable($fieldConfig[$field]['displayParser'])) {
$callback = $fieldConfig[$field]['displayParser'];
$entityData[$field] = $callback($field, $value, $entity);
continue;
}
$filterClass = Transform::get($fieldConfig[$field]['type']);
$entityData[$field] = $filterClass->display($field, $value, $model);
}
$history[$index]->data = $entityData;
}
return $history;
}
|
php
|
protected function _transformDataFields(array $history, string $model): array
{
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\\' . ucfirst($model) . 'Table'];
$model = ucfirst($model) . 'Table';
}
$fieldConfig = TableRegistry::get($model, $tableConfig)->getFields();
foreach ($history as $index => $entity) {
$entityData = $entity->data;
foreach ($entityData as $field => $value) {
if (!isset($fieldConfig[$field]) || $fieldConfig[$field]['searchable'] !== true) {
continue;
}
if (isset($fieldConfig[$field]['displayParser']) && is_callable($fieldConfig[$field]['displayParser'])) {
$callback = $fieldConfig[$field]['displayParser'];
$entityData[$field] = $callback($field, $value, $entity);
continue;
}
$filterClass = Transform::get($fieldConfig[$field]['type']);
$entityData[$field] = $filterClass->display($field, $value, $model);
}
$history[$index]->data = $entityData;
}
return $history;
}
|
[
"protected",
"function",
"_transformDataFields",
"(",
"array",
"$",
"history",
",",
"string",
"$",
"model",
")",
":",
"array",
"{",
"$",
"tableConfig",
"=",
"[",
"]",
";",
"if",
"(",
"defined",
"(",
"'PHPUNIT_TESTSUITE'",
")",
")",
"{",
"$",
"tableConfig",
"=",
"[",
"'className'",
"=>",
"'ModelHistoryTestApp\\Model\\Table\\\\'",
".",
"ucfirst",
"(",
"$",
"model",
")",
".",
"'Table'",
"]",
";",
"$",
"model",
"=",
"ucfirst",
"(",
"$",
"model",
")",
".",
"'Table'",
";",
"}",
"$",
"fieldConfig",
"=",
"TableRegistry",
"::",
"get",
"(",
"$",
"model",
",",
"$",
"tableConfig",
")",
"->",
"getFields",
"(",
")",
";",
"foreach",
"(",
"$",
"history",
"as",
"$",
"index",
"=>",
"$",
"entity",
")",
"{",
"$",
"entityData",
"=",
"$",
"entity",
"->",
"data",
";",
"foreach",
"(",
"$",
"entityData",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"fieldConfig",
"[",
"$",
"field",
"]",
")",
"||",
"$",
"fieldConfig",
"[",
"$",
"field",
"]",
"[",
"'searchable'",
"]",
"!==",
"true",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fieldConfig",
"[",
"$",
"field",
"]",
"[",
"'displayParser'",
"]",
")",
"&&",
"is_callable",
"(",
"$",
"fieldConfig",
"[",
"$",
"field",
"]",
"[",
"'displayParser'",
"]",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"fieldConfig",
"[",
"$",
"field",
"]",
"[",
"'displayParser'",
"]",
";",
"$",
"entityData",
"[",
"$",
"field",
"]",
"=",
"$",
"callback",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"entity",
")",
";",
"continue",
";",
"}",
"$",
"filterClass",
"=",
"Transform",
"::",
"get",
"(",
"$",
"fieldConfig",
"[",
"$",
"field",
"]",
"[",
"'type'",
"]",
")",
";",
"$",
"entityData",
"[",
"$",
"field",
"]",
"=",
"$",
"filterClass",
"->",
"display",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"model",
")",
";",
"}",
"$",
"history",
"[",
"$",
"index",
"]",
"->",
"data",
"=",
"$",
"entityData",
";",
"}",
"return",
"$",
"history",
";",
"}"
] |
Transforms data fields to human readable form
@param array $history Data
@param string $model Model name
@return array
|
[
"Transforms",
"data",
"fields",
"to",
"human",
"readable",
"form"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L213-L239
|
233,827
|
scherersoftware/cake-model-history
|
src/Model/Table/ModelHistoryTable.php
|
ModelHistoryTable.getNextRevisionNumberForEntity
|
public function getNextRevisionNumberForEntity(EntityInterface $entity): int
{
$revision = 1;
$last = $this->find()
->select('revision')
->where([
'model' => $this->getEntityModel($entity),
'foreign_key' => $entity->id
])
->order(['revision DESC'])
->hydrate(false)
->first();
if (isset($last['revision'])) {
$revision = $last['revision'] + 1;
}
return $revision;
}
|
php
|
public function getNextRevisionNumberForEntity(EntityInterface $entity): int
{
$revision = 1;
$last = $this->find()
->select('revision')
->where([
'model' => $this->getEntityModel($entity),
'foreign_key' => $entity->id
])
->order(['revision DESC'])
->hydrate(false)
->first();
if (isset($last['revision'])) {
$revision = $last['revision'] + 1;
}
return $revision;
}
|
[
"public",
"function",
"getNextRevisionNumberForEntity",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"int",
"{",
"$",
"revision",
"=",
"1",
";",
"$",
"last",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"select",
"(",
"'revision'",
")",
"->",
"where",
"(",
"[",
"'model'",
"=>",
"$",
"this",
"->",
"getEntityModel",
"(",
"$",
"entity",
")",
",",
"'foreign_key'",
"=>",
"$",
"entity",
"->",
"id",
"]",
")",
"->",
"order",
"(",
"[",
"'revision DESC'",
"]",
")",
"->",
"hydrate",
"(",
"false",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"last",
"[",
"'revision'",
"]",
")",
")",
"{",
"$",
"revision",
"=",
"$",
"last",
"[",
"'revision'",
"]",
"+",
"1",
";",
"}",
"return",
"$",
"revision",
";",
"}"
] |
Handles the revision sequence
@param EntityInterface $entity Entity to get the revision number for
@return int
|
[
"Handles",
"the",
"revision",
"sequence"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L266-L284
|
233,828
|
scherersoftware/cake-model-history
|
src/Model/Table/ModelHistoryTable.php
|
ModelHistoryTable.getEntityModel
|
public function getEntityModel(EntityInterface $entity): string
{
$source = $entity->source();
if (substr($source, -5) == 'Table') {
$source = substr($source, 0, -5);
}
return $source;
}
|
php
|
public function getEntityModel(EntityInterface $entity): string
{
$source = $entity->source();
if (substr($source, -5) == 'Table') {
$source = substr($source, 0, -5);
}
return $source;
}
|
[
"public",
"function",
"getEntityModel",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"string",
"{",
"$",
"source",
"=",
"$",
"entity",
"->",
"source",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"source",
",",
"-",
"5",
")",
"==",
"'Table'",
")",
"{",
"$",
"source",
"=",
"substr",
"(",
"$",
"source",
",",
"0",
",",
"-",
"5",
")",
";",
"}",
"return",
"$",
"source",
";",
"}"
] |
Extracts the string to be saved to the model field from an entity
@param EntityInterface $entity Entity
@return string
|
[
"Extracts",
"the",
"string",
"to",
"be",
"saved",
"to",
"the",
"model",
"field",
"from",
"an",
"entity"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L292-L300
|
233,829
|
scherersoftware/cake-model-history
|
src/Model/Table/ModelHistoryTable.php
|
ModelHistoryTable.getModelHistory
|
public function getModelHistory(string $model, $foreignKey, int $itemsToShow, int $page, array $conditions = [], array $options = []): array
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
$history = $history->order([
'revision' => 'DESC',
'ModelHistory.created' => 'DESC'
])
->contain(['Users'])
->limit($itemsToShow)
->page($page)
->toArray();
return $this->_transformDataFields($history, $model);
}
|
php
|
public function getModelHistory(string $model, $foreignKey, int $itemsToShow, int $page, array $conditions = [], array $options = []): array
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
$history = $history->order([
'revision' => 'DESC',
'ModelHistory.created' => 'DESC'
])
->contain(['Users'])
->limit($itemsToShow)
->page($page)
->toArray();
return $this->_transformDataFields($history, $model);
}
|
[
"public",
"function",
"getModelHistory",
"(",
"string",
"$",
"model",
",",
"$",
"foreignKey",
",",
"int",
"$",
"itemsToShow",
",",
"int",
"$",
"page",
",",
"array",
"$",
"conditions",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"conditions",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'foreign_key'",
"=>",
"$",
"foreignKey",
"]",
",",
"$",
"conditions",
")",
";",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'includeAssociated'",
"=>",
"false",
"]",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'includeAssociated'",
"]",
")",
"{",
"$",
"hashes",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"'save_hash'",
"]",
")",
"->",
"where",
"(",
"$",
"conditions",
")",
";",
"$",
"history",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'save_hash IN'",
"=>",
"$",
"hashes",
"]",
")",
";",
"}",
"else",
"{",
"$",
"history",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"$",
"conditions",
")",
";",
"}",
"$",
"history",
"=",
"$",
"history",
"->",
"order",
"(",
"[",
"'revision'",
"=>",
"'DESC'",
",",
"'ModelHistory.created'",
"=>",
"'DESC'",
"]",
")",
"->",
"contain",
"(",
"[",
"'Users'",
"]",
")",
"->",
"limit",
"(",
"$",
"itemsToShow",
")",
"->",
"page",
"(",
"$",
"page",
")",
"->",
"toArray",
"(",
")",
";",
"return",
"$",
"this",
"->",
"_transformDataFields",
"(",
"$",
"history",
",",
"$",
"model",
")",
";",
"}"
] |
Get Model History
@param string $model Model name
@param mixed $foreignKey Foreign key
@param int $itemsToShow Amount of items to be shown
@param int $page Current position
@param array $conditions Additional conditions for find
@param array $options Additional options
@return array
|
[
"Get",
"Model",
"History"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L356-L390
|
233,830
|
scherersoftware/cake-model-history
|
src/Model/Table/ModelHistoryTable.php
|
ModelHistoryTable.getModelHistoryCount
|
public function getModelHistoryCount(string $model, $foreignKey, array $conditions = [], array $options = []): int
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
return $history->count();
}
|
php
|
public function getModelHistoryCount(string $model, $foreignKey, array $conditions = [], array $options = []): int
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
return $history->count();
}
|
[
"public",
"function",
"getModelHistoryCount",
"(",
"string",
"$",
"model",
",",
"$",
"foreignKey",
",",
"array",
"$",
"conditions",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"int",
"{",
"$",
"conditions",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'foreign_key'",
"=>",
"$",
"foreignKey",
"]",
",",
"$",
"conditions",
")",
";",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'includeAssociated'",
"=>",
"false",
"]",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'includeAssociated'",
"]",
")",
"{",
"$",
"hashes",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"'save_hash'",
"]",
")",
"->",
"where",
"(",
"$",
"conditions",
")",
";",
"$",
"history",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'save_hash IN'",
"=>",
"$",
"hashes",
"]",
")",
";",
"}",
"else",
"{",
"$",
"history",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"$",
"conditions",
")",
";",
"}",
"return",
"$",
"history",
"->",
"count",
"(",
")",
";",
"}"
] |
Get Model History entries count
@param string $model model name
@param mixed $foreignKey foreign key
@param array $conditions additional conditions for find
@return int
|
[
"Get",
"Model",
"History",
"entries",
"count"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L400-L425
|
233,831
|
scherersoftware/cake-model-history
|
src/Model/Table/ModelHistoryTable.php
|
ModelHistoryTable._translateFieldname
|
protected function _translateFieldname(string $fieldname, string $model): string
{
// Try to get the generic model.field translation string
$localeSlug = strtolower(Inflector::singularize(Inflector::delimit($model))) . '.' . strtolower($fieldname);
$translatedString = __($localeSlug);
// Return original value when no translation was made
if ($localeSlug == $translatedString) {
return $fieldname;
}
return $translatedString;
}
|
php
|
protected function _translateFieldname(string $fieldname, string $model): string
{
// Try to get the generic model.field translation string
$localeSlug = strtolower(Inflector::singularize(Inflector::delimit($model))) . '.' . strtolower($fieldname);
$translatedString = __($localeSlug);
// Return original value when no translation was made
if ($localeSlug == $translatedString) {
return $fieldname;
}
return $translatedString;
}
|
[
"protected",
"function",
"_translateFieldname",
"(",
"string",
"$",
"fieldname",
",",
"string",
"$",
"model",
")",
":",
"string",
"{",
"// Try to get the generic model.field translation string",
"$",
"localeSlug",
"=",
"strtolower",
"(",
"Inflector",
"::",
"singularize",
"(",
"Inflector",
"::",
"delimit",
"(",
"$",
"model",
")",
")",
")",
".",
"'.'",
".",
"strtolower",
"(",
"$",
"fieldname",
")",
";",
"$",
"translatedString",
"=",
"__",
"(",
"$",
"localeSlug",
")",
";",
"// Return original value when no translation was made",
"if",
"(",
"$",
"localeSlug",
"==",
"$",
"translatedString",
")",
"{",
"return",
"$",
"fieldname",
";",
"}",
"return",
"$",
"translatedString",
";",
"}"
] |
Try to translate fieldname
@param string $fieldname Fieldname
@param string $model Model
@return string
|
[
"Try",
"to",
"translate",
"fieldname"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L576-L588
|
233,832
|
nfephp-org/sped-console
|
src/Processors/XsdGeneratePhp.php
|
XsdGeneratePhp.printMappedNamespaces
|
protected function printMappedNamespaces(PhpConverter $converter)
{
$this->outputWriteLine("Namespaces:");
foreach ($converter->getNamespaces() as $xsdTargetNamespace => $phpNamespace) {
$this->outputWriteLine(
" + <comment>{$this->outputFormatterEscape($xsdTargetNamespace)}</comment>" .
" => <info>{$this->outputFormatterEscape($phpNamespace)}</info>"
);
}
}
|
php
|
protected function printMappedNamespaces(PhpConverter $converter)
{
$this->outputWriteLine("Namespaces:");
foreach ($converter->getNamespaces() as $xsdTargetNamespace => $phpNamespace) {
$this->outputWriteLine(
" + <comment>{$this->outputFormatterEscape($xsdTargetNamespace)}</comment>" .
" => <info>{$this->outputFormatterEscape($phpNamespace)}</info>"
);
}
}
|
[
"protected",
"function",
"printMappedNamespaces",
"(",
"PhpConverter",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"outputWriteLine",
"(",
"\"Namespaces:\"",
")",
";",
"foreach",
"(",
"$",
"converter",
"->",
"getNamespaces",
"(",
")",
"as",
"$",
"xsdTargetNamespace",
"=>",
"$",
"phpNamespace",
")",
"{",
"$",
"this",
"->",
"outputWriteLine",
"(",
"\" + <comment>{$this->outputFormatterEscape($xsdTargetNamespace)}</comment>\"",
".",
"\" => <info>{$this->outputFormatterEscape($phpNamespace)}</info>\"",
")",
";",
"}",
"}"
] |
Print all mapped namespaces from converter.
@param PhpConverter $converter
|
[
"Print",
"all",
"mapped",
"namespaces",
"from",
"converter",
"."
] |
eaedaa8065744b2e47d8f7c711ae993ff238126f
|
https://github.com/nfephp-org/sped-console/blob/eaedaa8065744b2e47d8f7c711ae993ff238126f/src/Processors/XsdGeneratePhp.php#L103-L112
|
233,833
|
kaliop-uk/kueueingbundle
|
Service/MessageConsumer/SymfonyService.php
|
SymfonyService.validateService
|
protected function validateService($serviceName, $methodName, $arguments = array())
{
$service = $this->container->get($serviceName);
if (!is_callable(array($service, $methodName))) {
throw new \UnexpectedValueException("Method $methodName not found in class " . get_class($service) . " implementing service $serviceName");
}
}
|
php
|
protected function validateService($serviceName, $methodName, $arguments = array())
{
$service = $this->container->get($serviceName);
if (!is_callable(array($service, $methodName))) {
throw new \UnexpectedValueException("Method $methodName not found in class " . get_class($service) . " implementing service $serviceName");
}
}
|
[
"protected",
"function",
"validateService",
"(",
"$",
"serviceName",
",",
"$",
"methodName",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceName",
")",
";",
"if",
"(",
"!",
"is_callable",
"(",
"array",
"(",
"$",
"service",
",",
"$",
"methodName",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Method $methodName not found in class \"",
".",
"get_class",
"(",
"$",
"service",
")",
".",
"\" implementing service $serviceName\"",
")",
";",
"}",
"}"
] |
Throws an error if service is not declared or methodName does not apply
@param string $serviceName
@param string $methodName
@param array $arguments
@throws
|
[
"Throws",
"an",
"error",
"if",
"service",
"is",
"not",
"declared",
"or",
"methodName",
"does",
"not",
"apply"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageConsumer/SymfonyService.php#L63-L69
|
233,834
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.connect
|
protected function connect( $pgHost, $pgPort = 22, $pgProtocol, $pgTimeout = 10 ) {
pecho( "Connecting to $pgHost:$pgPort...\n\n", PECHO_NORMAL );
switch( $pgProtocol ){
case 1:
$this->SSHObject = new Net_SSH1($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
case 2:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
default:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
}
return $this->SFTPObject = new Net_SFTP($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
}
|
php
|
protected function connect( $pgHost, $pgPort = 22, $pgProtocol, $pgTimeout = 10 ) {
pecho( "Connecting to $pgHost:$pgPort...\n\n", PECHO_NORMAL );
switch( $pgProtocol ){
case 1:
$this->SSHObject = new Net_SSH1($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
case 2:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
default:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
}
return $this->SFTPObject = new Net_SFTP($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
}
|
[
"protected",
"function",
"connect",
"(",
"$",
"pgHost",
",",
"$",
"pgPort",
"=",
"22",
",",
"$",
"pgProtocol",
",",
"$",
"pgTimeout",
"=",
"10",
")",
"{",
"pecho",
"(",
"\"Connecting to $pgHost:$pgPort...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"switch",
"(",
"$",
"pgProtocol",
")",
"{",
"case",
"1",
":",
"$",
"this",
"->",
"SSHObject",
"=",
"new",
"Net_SSH1",
"(",
"$",
"pgHost",
",",
"$",
"pgPort",
",",
"$",
"pgTimeout",
")",
";",
"// FIXME Directory doesn't exist",
"break",
";",
"case",
"2",
":",
"$",
"this",
"->",
"SSHObject",
"=",
"new",
"Net_SSH2",
"(",
"$",
"pgHost",
",",
"$",
"pgPort",
",",
"$",
"pgTimeout",
")",
";",
"// FIXME Directory doesn't exist",
"break",
";",
"default",
":",
"$",
"this",
"->",
"SSHObject",
"=",
"new",
"Net_SSH2",
"(",
"$",
"pgHost",
",",
"$",
"pgPort",
",",
"$",
"pgTimeout",
")",
";",
"// FIXME Directory doesn't exist",
"break",
";",
"}",
"return",
"$",
"this",
"->",
"SFTPObject",
"=",
"new",
"Net_SFTP",
"(",
"$",
"pgHost",
",",
"$",
"pgPort",
",",
"$",
"pgTimeout",
")",
";",
"// FIXME Directory doesn't exist",
"}"
] |
Establishes a connection to the remote server.
@FIXME: Codebase no longer includes SSH-related classes
@access protected
@param string $pgHost Host of server to connect to.
@param int $pgPort Port of server.
@param int $pgProtocol Which SSH protocol to use.
@param int $pgTimeout How long before the connection times out. (Milliseconds)
@return bool
|
[
"Establishes",
"a",
"connection",
"to",
"the",
"remote",
"server",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L201-L216
|
233,835
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.authenticate
|
protected function authenticate($pgUsername, $pgPassphrase, $pgPrivateKey)
{
//Determine the type of authentication to use.
if( is_null( $pgUsername ) ) {
pecho( "A username must at least be specified to authenticate to the server,\neven if there is authentication is none.\n\n", PECHO_FATAL );
return false;
}
$fails = 0;
if (!is_null($pgUsername) && !is_null($pgPrivateKey) && $this->protocol == 2) {
pecho( "Authenticating with Private Key Authentication...\n\n", PECHO_NORMAL );
$key = new Crypt_RSA(); // FIXME Class doesn't exist
if (!is_null($pgPassphrase)) {
$key->setPassword($pgPassphrase);
} // FIXME Method doesn't exist
$key->loadKey(file_get_contents($pgPrivateKey)); // FIXME Method doesn't exist
if ($this->SSHObject->login($pgUsername, $key) && $this->SFTPObject->login($pgUsername, $key)) {
pecho( "Successfully authenticated using Private Key Authentication.\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) && !is_null( $pgPassphrase ) ) {
pecho( "Authenticating with Password Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername, $pgPassphrase) && $this->SFTPObject->login($pgUsername,
$pgPassphrase)
) {
pecho( "Successfully authenticated using Password Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) ) {
pecho( "Authenticating with No Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername) && $this->SFTPObject->login($pgUsername)) {
pecho( "Successfully authenticated with No Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( $fails == 15 ) {
pecho( "An incorrect combination of parameters was used and therefore, no proper authentication can be established.\n\n", PECHO_FATAL );
return false;
} else {
pecho( "Peachy was unable to authenticate with any method of authentication.\nPlease check your connection settings and try again.\n\n", PECHO_FATAL );
return false;
}
}
|
php
|
protected function authenticate($pgUsername, $pgPassphrase, $pgPrivateKey)
{
//Determine the type of authentication to use.
if( is_null( $pgUsername ) ) {
pecho( "A username must at least be specified to authenticate to the server,\neven if there is authentication is none.\n\n", PECHO_FATAL );
return false;
}
$fails = 0;
if (!is_null($pgUsername) && !is_null($pgPrivateKey) && $this->protocol == 2) {
pecho( "Authenticating with Private Key Authentication...\n\n", PECHO_NORMAL );
$key = new Crypt_RSA(); // FIXME Class doesn't exist
if (!is_null($pgPassphrase)) {
$key->setPassword($pgPassphrase);
} // FIXME Method doesn't exist
$key->loadKey(file_get_contents($pgPrivateKey)); // FIXME Method doesn't exist
if ($this->SSHObject->login($pgUsername, $key) && $this->SFTPObject->login($pgUsername, $key)) {
pecho( "Successfully authenticated using Private Key Authentication.\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) && !is_null( $pgPassphrase ) ) {
pecho( "Authenticating with Password Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername, $pgPassphrase) && $this->SFTPObject->login($pgUsername,
$pgPassphrase)
) {
pecho( "Successfully authenticated using Password Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) ) {
pecho( "Authenticating with No Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername) && $this->SFTPObject->login($pgUsername)) {
pecho( "Successfully authenticated with No Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( $fails == 15 ) {
pecho( "An incorrect combination of parameters was used and therefore, no proper authentication can be established.\n\n", PECHO_FATAL );
return false;
} else {
pecho( "Peachy was unable to authenticate with any method of authentication.\nPlease check your connection settings and try again.\n\n", PECHO_FATAL );
return false;
}
}
|
[
"protected",
"function",
"authenticate",
"(",
"$",
"pgUsername",
",",
"$",
"pgPassphrase",
",",
"$",
"pgPrivateKey",
")",
"{",
"//Determine the type of authentication to use.",
"if",
"(",
"is_null",
"(",
"$",
"pgUsername",
")",
")",
"{",
"pecho",
"(",
"\"A username must at least be specified to authenticate to the server,\\neven if there is authentication is none.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"$",
"fails",
"=",
"0",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"pgUsername",
")",
"&&",
"!",
"is_null",
"(",
"$",
"pgPrivateKey",
")",
"&&",
"$",
"this",
"->",
"protocol",
"==",
"2",
")",
"{",
"pecho",
"(",
"\"Authenticating with Private Key Authentication...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"$",
"key",
"=",
"new",
"Crypt_RSA",
"(",
")",
";",
"// FIXME Class doesn't exist",
"if",
"(",
"!",
"is_null",
"(",
"$",
"pgPassphrase",
")",
")",
"{",
"$",
"key",
"->",
"setPassword",
"(",
"$",
"pgPassphrase",
")",
";",
"}",
"// FIXME Method doesn't exist",
"$",
"key",
"->",
"loadKey",
"(",
"file_get_contents",
"(",
"$",
"pgPrivateKey",
")",
")",
";",
"// FIXME Method doesn't exist",
"if",
"(",
"$",
"this",
"->",
"SSHObject",
"->",
"login",
"(",
"$",
"pgUsername",
",",
"$",
"key",
")",
"&&",
"$",
"this",
"->",
"SFTPObject",
"->",
"login",
"(",
"$",
"pgUsername",
",",
"$",
"key",
")",
")",
"{",
"pecho",
"(",
"\"Successfully authenticated using Private Key Authentication.\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"return",
"true",
";",
"}",
"$",
"fails",
"++",
";",
"}",
"else",
"$",
"fails",
"+=",
"5",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"pgUsername",
")",
"&&",
"!",
"is_null",
"(",
"$",
"pgPassphrase",
")",
")",
"{",
"pecho",
"(",
"\"Authenticating with Password Authentication...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"if",
"(",
"$",
"this",
"->",
"SSHObject",
"->",
"login",
"(",
"$",
"pgUsername",
",",
"$",
"pgPassphrase",
")",
"&&",
"$",
"this",
"->",
"SFTPObject",
"->",
"login",
"(",
"$",
"pgUsername",
",",
"$",
"pgPassphrase",
")",
")",
"{",
"pecho",
"(",
"\"Successfully authenticated using Password Authentication\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"return",
"true",
";",
"}",
"$",
"fails",
"++",
";",
"}",
"else",
"$",
"fails",
"+=",
"5",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"pgUsername",
")",
")",
"{",
"pecho",
"(",
"\"Authenticating with No Authentication...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"if",
"(",
"$",
"this",
"->",
"SSHObject",
"->",
"login",
"(",
"$",
"pgUsername",
")",
"&&",
"$",
"this",
"->",
"SFTPObject",
"->",
"login",
"(",
"$",
"pgUsername",
")",
")",
"{",
"pecho",
"(",
"\"Successfully authenticated with No Authentication\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"return",
"true",
";",
"}",
"$",
"fails",
"++",
";",
"}",
"else",
"$",
"fails",
"+=",
"5",
";",
"if",
"(",
"$",
"fails",
"==",
"15",
")",
"{",
"pecho",
"(",
"\"An incorrect combination of parameters was used and therefore, no proper authentication can be established.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Peachy was unable to authenticate with any method of authentication.\\nPlease check your connection settings and try again.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Authenticates to the remote server.
@access protected
@param string $pgUsername Username
@param string $pgPassphrase Password or passphrase of key file
@param string $pgPrivateKey File path of key file.
@return bool
|
[
"Authenticates",
"to",
"the",
"remote",
"server",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L227-L274
|
233,836
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.iExec
|
public function iExec($command, $expect = "", $expectRegex = false) {
trim( $command, "\n" );
if ($this->SSHObject->write($command . "\n")) {
return $this->SSHObject->read($expect,
($expectRegex ? NET_SSH . $this->protocol . _READ_REGEX : NET_SSH . $this->protocol . _READ_SIMPLE));
} else return false;
}
|
php
|
public function iExec($command, $expect = "", $expectRegex = false) {
trim( $command, "\n" );
if ($this->SSHObject->write($command . "\n")) {
return $this->SSHObject->read($expect,
($expectRegex ? NET_SSH . $this->protocol . _READ_REGEX : NET_SSH . $this->protocol . _READ_SIMPLE));
} else return false;
}
|
[
"public",
"function",
"iExec",
"(",
"$",
"command",
",",
"$",
"expect",
"=",
"\"\"",
",",
"$",
"expectRegex",
"=",
"false",
")",
"{",
"trim",
"(",
"$",
"command",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"SSHObject",
"->",
"write",
"(",
"$",
"command",
".",
"\"\\n\"",
")",
")",
"{",
"return",
"$",
"this",
"->",
"SSHObject",
"->",
"read",
"(",
"$",
"expect",
",",
"(",
"$",
"expectRegex",
"?",
"NET_SSH",
".",
"$",
"this",
"->",
"protocol",
".",
"_READ_REGEX",
":",
"NET_SSH",
".",
"$",
"this",
"->",
"protocol",
".",
"_READ_SIMPLE",
")",
")",
";",
"}",
"else",
"return",
"false",
";",
"}"
] |
Opens an interactive shell if not done already and transmits commands and returns output.
@access public
@param string $command Command to execute
@param string $expect String of output to expect and remove from output.
@param bool $expectRegex Switches string expectation to regular expressions.
@returns bool|string
FIXME Contains undefined constants
|
[
"Opens",
"an",
"interactive",
"shell",
"if",
"not",
"done",
"already",
"and",
"transmits",
"commands",
"and",
"returns",
"output",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L312-L318
|
233,837
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.file_put_contents
|
public function file_put_contents( $to, $data, $resume = false ) {
if( $resume ) {
return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING) | NET_SFTP_RESUME);
} else return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING));
}
|
php
|
public function file_put_contents( $to, $data, $resume = false ) {
if( $resume ) {
return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING) | NET_SFTP_RESUME);
} else return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING));
}
|
[
"public",
"function",
"file_put_contents",
"(",
"$",
"to",
",",
"$",
"data",
",",
"$",
"resume",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"resume",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"put",
"(",
"$",
"to",
",",
"$",
"data",
",",
"(",
"is_file",
"(",
"$",
"data",
")",
"&&",
"file_exists",
"(",
"$",
"data",
")",
"?",
"NET_SFTP_LOCAL_FILE",
":",
"NET_SFTP_STRING",
")",
"|",
"NET_SFTP_RESUME",
")",
";",
"}",
"else",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"put",
"(",
"$",
"to",
",",
"$",
"data",
",",
"(",
"is_file",
"(",
"$",
"data",
")",
"&&",
"file_exists",
"(",
"$",
"data",
")",
"?",
"NET_SFTP_LOCAL_FILE",
":",
"NET_SFTP_STRING",
")",
")",
";",
"}"
] |
Write a file to a remote server
@access public
@param string $to location of file to be placed
@param string $data data to write or file location of file to upload
@param bool $resume resume an interrupted transfer
@return bool
FIXME Contains undefined constants
|
[
"Write",
"a",
"file",
"to",
"a",
"remote",
"server"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L355-L362
|
233,838
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.file_get_contents
|
public function file_get_contents( $from, $to = false, $offset = 0, $length = -1 )
{
return $this->SFTPObject->get($from, $to, $offset, $length);
}
|
php
|
public function file_get_contents( $from, $to = false, $offset = 0, $length = -1 )
{
return $this->SFTPObject->get($from, $to, $offset, $length);
}
|
[
"public",
"function",
"file_get_contents",
"(",
"$",
"from",
",",
"$",
"to",
"=",
"false",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"length",
"=",
"-",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"get",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"offset",
",",
"$",
"length",
")",
";",
"}"
] |
Retrieve a file from a remote server
@access public
@param string $from Location on remote server to retrieve from.
@param string|bool $to Location to write to. If left blank, file contents is returned.
@param int $offset Where to start retrieving files from.
@param int $length How much of the file to retrieve.
@returns bool|string
|
[
"Retrieve",
"a",
"file",
"from",
"a",
"remote",
"server"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L374-L377
|
233,839
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.chmod
|
public function chmod( $path, $mode, $recursive = false )
{
return $this->SFTPObject->chmod($mode, $path, $recursive);
}
|
php
|
public function chmod( $path, $mode, $recursive = false )
{
return $this->SFTPObject->chmod($mode, $path, $recursive);
}
|
[
"public",
"function",
"chmod",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"chmod",
"(",
"$",
"mode",
",",
"$",
"path",
",",
"$",
"recursive",
")",
";",
"}"
] |
Changes file mode
@access public
@param string $path Path to the directory or file
@param int $mode Mode to change to
@param bool $recursive Apply it to files within directory and children directories.
@return bool|int
|
[
"Changes",
"file",
"mode"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L450-L453
|
233,840
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.touch
|
public function touch( $filename, $time = null, $atime = null )
{
return $this->SFTPObject->touch($filename, $time, $atime);
}
|
php
|
public function touch( $filename, $time = null, $atime = null )
{
return $this->SFTPObject->touch($filename, $time, $atime);
}
|
[
"public",
"function",
"touch",
"(",
"$",
"filename",
",",
"$",
"time",
"=",
"null",
",",
"$",
"atime",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"touch",
"(",
"$",
"filename",
",",
"$",
"time",
",",
"$",
"atime",
")",
";",
"}"
] |
Sets access and modification time of file
@access public
@param string $filename The name of the file being touched.
@param int $time The touch time. If time is not supplied, the current system time is used.
@param int $atime If present, the access time of the given filename is set to the value of atime. Otherwise, it is set to the value passed to the time parameter. If neither are present, the current system time is used.
@return bool
|
[
"Sets",
"access",
"and",
"modification",
"time",
"of",
"file"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L464-L467
|
233,841
|
MW-Peachy/Peachy
|
Includes/SSH.php
|
SSH.CheckForUpdate
|
protected function CheckForUpdate() {
global $pgIP;
$data = json_decode( $this->http->get( 'https://api.github.com/repos/phpseclib/phpseclib/branches/master', null, array(), false ), true );
$this->commits = $data;
if( !file_exists( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) ) return false;
$log = unserialize( file_get_contents( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) );
if( isset( $data['commit']['sha'] ) && $log['commit']['sha'] != $data['commit']['sha'] ) {
pecho( "Updating SSH class!\n\n", PECHO_NOTICE );
return false;
}
return true;
}
|
php
|
protected function CheckForUpdate() {
global $pgIP;
$data = json_decode( $this->http->get( 'https://api.github.com/repos/phpseclib/phpseclib/branches/master', null, array(), false ), true );
$this->commits = $data;
if( !file_exists( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) ) return false;
$log = unserialize( file_get_contents( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) );
if( isset( $data['commit']['sha'] ) && $log['commit']['sha'] != $data['commit']['sha'] ) {
pecho( "Updating SSH class!\n\n", PECHO_NOTICE );
return false;
}
return true;
}
|
[
"protected",
"function",
"CheckForUpdate",
"(",
")",
"{",
"global",
"$",
"pgIP",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"http",
"->",
"get",
"(",
"'https://api.github.com/repos/phpseclib/phpseclib/branches/master'",
",",
"null",
",",
"array",
"(",
")",
",",
"false",
")",
",",
"true",
")",
";",
"$",
"this",
"->",
"commits",
"=",
"$",
"data",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"pgIP",
".",
"'Includes'",
".",
"DIRECTORY_SEPARATOR",
".",
"'phpseclibupdate'",
")",
")",
"return",
"false",
";",
"$",
"log",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"pgIP",
".",
"'Includes'",
".",
"DIRECTORY_SEPARATOR",
".",
"'phpseclibupdate'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'commit'",
"]",
"[",
"'sha'",
"]",
")",
"&&",
"$",
"log",
"[",
"'commit'",
"]",
"[",
"'sha'",
"]",
"!=",
"$",
"data",
"[",
"'commit'",
"]",
"[",
"'sha'",
"]",
")",
"{",
"pecho",
"(",
"\"Updating SSH class!\\n\\n\"",
",",
"PECHO_NOTICE",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check for Update Function
Checks the phpseclib/phpseclib library for updates.
@return bool Returns true if no updates
Returns false if updates needed
FIXME The .json file may no longer contain ['commit']['sha'], but possibly ['tree']['sha']
|
[
"Check",
"for",
"Update",
"Function"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L581-L592
|
233,842
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php
|
CodeGeneratorResponseMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new CodeGeneratorResponse();
case 1:
return new CodeGeneratorResponse(func_get_arg(0));
case 2:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1));
case 3:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new CodeGeneratorResponse();
case 1:
return new CodeGeneratorResponse(func_get_arg(0));
case 2:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1));
case 3:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\Compiler\CodeGeneratorResponse
@throws \InvalidArgumentException
@return CodeGeneratorResponse
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L59-L83
|
233,843
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php
|
CodeGeneratorResponseMeta.reset
|
public static function reset($object)
{
if (!($object instanceof CodeGeneratorResponse)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse.');
}
$object->error = NULL;
$object->file = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof CodeGeneratorResponse)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse.');
}
$object->error = NULL;
$object->file = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"CodeGeneratorResponse",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\Compiler\\CodeGeneratorResponse.'",
")",
";",
"}",
"$",
"object",
"->",
"error",
"=",
"NULL",
";",
"$",
"object",
"->",
"file",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\Compiler\CodeGeneratorResponse to default values
@param CodeGeneratorResponse $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L96-L103
|
233,844
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php
|
CodeGeneratorResponseMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->error)) {
hash_update($ctx, 'error');
hash_update($ctx, (string)$object->error);
}
if (isset($object->file)) {
hash_update($ctx, 'file');
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $v0) {
FileMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
php
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->error)) {
hash_update($ctx, 'error');
hash_update($ctx, (string)$object->error);
}
if (isset($object->file)) {
hash_update($ctx, 'file');
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $v0) {
FileMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrCtx",
")",
";",
"}",
"else",
"{",
"$",
"ctx",
"=",
"$",
"algoOrCtx",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"error",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'error'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"error",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"file",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'file'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"file",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"file",
":",
"(",
"array",
")",
"$",
"object",
"->",
"file",
"as",
"$",
"v0",
")",
"{",
"FileMeta",
"::",
"hash",
"(",
"$",
"v0",
",",
"$",
"ctx",
")",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\Compiler\CodeGeneratorResponse
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L115-L140
|
233,845
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php
|
CodeGeneratorResponseMeta.fromProtobuf
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new CodeGeneratorResponse();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->error = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 15:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
if (!(isset($object->file) && is_array($object->file))) {
$object->file = array();
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->file[] = FileMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
}
|
php
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new CodeGeneratorResponse();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->error = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 15:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
if (!(isset($object->file) && is_array($object->file))) {
$object->file = array();
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->file[] = FileMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
}
|
[
"public",
"static",
"function",
"fromProtobuf",
"(",
"$",
"input",
",",
"$",
"object",
"=",
"NULL",
",",
"&",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"CodeGeneratorResponse",
"(",
")",
";",
"}",
"if",
"(",
"$",
"end",
"===",
"null",
")",
"{",
"$",
"end",
"=",
"strlen",
"(",
"$",
"input",
")",
";",
"}",
"while",
"(",
"$",
"start",
"<",
"$",
"end",
")",
"{",
"$",
"tag",
"=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"$",
"wireType",
"=",
"$",
"tag",
"&",
"0x7",
";",
"$",
"number",
"=",
"$",
"tag",
">>",
"3",
";",
"switch",
"(",
"$",
"number",
")",
"{",
"case",
"1",
":",
"if",
"(",
"$",
"wireType",
"!==",
"2",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected wire type '",
".",
"$",
"wireType",
".",
"', expected 2.'",
",",
"$",
"number",
")",
";",
"}",
"$",
"length",
"=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"$",
"expectedStart",
"=",
"$",
"start",
"+",
"$",
"length",
";",
"if",
"(",
"$",
"expectedStart",
">",
"$",
"end",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Not enough data.'",
")",
";",
"}",
"$",
"object",
"->",
"error",
"=",
"substr",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"length",
")",
";",
"$",
"start",
"+=",
"$",
"length",
";",
"if",
"(",
"$",
"start",
"!==",
"$",
"expectedStart",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected start. Expected '",
".",
"$",
"expectedStart",
".",
"', got '",
".",
"$",
"start",
".",
"'.'",
",",
"$",
"number",
")",
";",
"}",
"break",
";",
"case",
"15",
":",
"if",
"(",
"$",
"wireType",
"!==",
"2",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected wire type '",
".",
"$",
"wireType",
".",
"', expected 2.'",
",",
"$",
"number",
")",
";",
"}",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"object",
"->",
"file",
")",
"&&",
"is_array",
"(",
"$",
"object",
"->",
"file",
")",
")",
")",
"{",
"$",
"object",
"->",
"file",
"=",
"array",
"(",
")",
";",
"}",
"$",
"length",
"=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"$",
"expectedStart",
"=",
"$",
"start",
"+",
"$",
"length",
";",
"if",
"(",
"$",
"expectedStart",
">",
"$",
"end",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Not enough data.'",
")",
";",
"}",
"$",
"object",
"->",
"file",
"[",
"]",
"=",
"FileMeta",
"::",
"fromProtobuf",
"(",
"$",
"input",
",",
"null",
",",
"$",
"start",
",",
"$",
"start",
"+",
"$",
"length",
")",
";",
"if",
"(",
"$",
"start",
"!==",
"$",
"expectedStart",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected start. Expected '",
".",
"$",
"expectedStart",
".",
"', got '",
".",
"$",
"start",
".",
"'.'",
",",
"$",
"number",
")",
";",
"}",
"break",
";",
"default",
":",
"switch",
"(",
"$",
"wireType",
")",
"{",
"case",
"0",
":",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"start",
"+=",
"8",
";",
"break",
";",
"case",
"2",
":",
"$",
"start",
"+=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"break",
";",
"case",
"5",
":",
"$",
"start",
"+=",
"4",
";",
"break",
";",
"default",
":",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected wire type '",
".",
"$",
"wireType",
".",
"'.'",
",",
"$",
"number",
")",
";",
"}",
"}",
"}",
"return",
"$",
"object",
";",
"}"
] |
Creates \Google\Protobuf\Compiler\CodeGeneratorResponse object from serialized Protocol Buffers message.
@param string $input
@param CodeGeneratorResponse $object
@param int $start
@param int $end
@throws \Exception
@return CodeGeneratorResponse
|
[
"Creates",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L155-L223
|
233,846
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php
|
CodeGeneratorResponseMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->error) && ($filter === null || isset($filter['error']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->error));
$output .= $object->error;
}
if (isset($object->file) && ($filter === null || isset($filter['file']))) {
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) {
$output .= "\x7a";
$buffer = FileMeta::toProtobuf($v, $filter === null ? null : $filter['file']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->error) && ($filter === null || isset($filter['error']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->error));
$output .= $object->error;
}
if (isset($object->file) && ($filter === null || isset($filter['file']))) {
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) {
$output .= "\x7a";
$buffer = FileMeta::toProtobuf($v, $filter === null ? null : $filter['file']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"error",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'error'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x0a\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"error",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"error",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"file",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'file'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"file",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"file",
":",
"(",
"array",
")",
"$",
"object",
"->",
"file",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\x7a\"",
";",
"$",
"buffer",
"=",
"FileMeta",
"::",
"toProtobuf",
"(",
"$",
"v",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'file'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\Compiler\CodeGeneratorResponse to Protocol Buffers message.
@param CodeGeneratorResponse $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L236-L256
|
233,847
|
budde377/Part
|
lib/model/ContentLibraryImpl.php
|
ContentLibraryImpl.listContents
|
public function listContents($time = 0)
{
$this->setUpList();
return array_filter($this->idArray, function (Content $content) use ($time) {
return $content->latestTime() >= $time;
});
}
|
php
|
public function listContents($time = 0)
{
$this->setUpList();
return array_filter($this->idArray, function (Content $content) use ($time) {
return $content->latestTime() >= $time;
});
}
|
[
"public",
"function",
"listContents",
"(",
"$",
"time",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"setUpList",
"(",
")",
";",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"idArray",
",",
"function",
"(",
"Content",
"$",
"content",
")",
"use",
"(",
"$",
"time",
")",
"{",
"return",
"$",
"content",
"->",
"latestTime",
"(",
")",
">=",
"$",
"time",
";",
"}",
")",
";",
"}"
] |
This will list site content.
It the timestamp is given, the latest time will be newer
than the timestamp.
@param int $time A Unix timestamp
@return array A array of PageContent.
|
[
"This",
"will",
"list",
"site",
"content",
".",
"It",
"the",
"timestamp",
"is",
"given",
"the",
"latest",
"time",
"will",
"be",
"newer",
"than",
"the",
"timestamp",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/ContentLibraryImpl.php#L39-L45
|
233,848
|
budde377/Part
|
lib/model/ContentLibraryImpl.php
|
ContentLibraryImpl.getContent
|
public function getContent($id = "")
{
$this->setUpList();
return isset($this->idArray[$id]) ?
$this->idArray[$id] :
$this->idArray[$id] = $this->createContent($id);
}
|
php
|
public function getContent($id = "")
{
$this->setUpList();
return isset($this->idArray[$id]) ?
$this->idArray[$id] :
$this->idArray[$id] = $this->createContent($id);
}
|
[
"public",
"function",
"getContent",
"(",
"$",
"id",
"=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"setUpList",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"idArray",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"idArray",
"[",
"$",
"id",
"]",
":",
"$",
"this",
"->",
"idArray",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"createContent",
"(",
"$",
"id",
")",
";",
"}"
] |
This will return and reuse a instance of content related to the given id.
@param string $id
@return Content
|
[
"This",
"will",
"return",
"and",
"reuse",
"a",
"instance",
"of",
"content",
"related",
"to",
"the",
"given",
"id",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/ContentLibraryImpl.php#L53-L60
|
233,849
|
budde377/Part
|
lib/model/ContentLibraryImpl.php
|
ContentLibraryImpl.searchLibrary
|
public function searchLibrary($string, $time = null)
{
$this->setUpList();
$this->search_library_stm->bindValue(':like', "%$string%");
$this->search_library_stm->bindValue(':time', $time == null ? 0 : $time);
$this->search_library_stm->execute();
$retArray = [];
foreach ($this->search_library_stm->fetchAll(PDO::FETCH_ASSOC) as $val) {
$id = $val["id"];
if (!isset($this->idArray[$id])) {
continue;
}
$retArray[$id] = $this->idArray[$id];
}
return $retArray;
}
|
php
|
public function searchLibrary($string, $time = null)
{
$this->setUpList();
$this->search_library_stm->bindValue(':like', "%$string%");
$this->search_library_stm->bindValue(':time', $time == null ? 0 : $time);
$this->search_library_stm->execute();
$retArray = [];
foreach ($this->search_library_stm->fetchAll(PDO::FETCH_ASSOC) as $val) {
$id = $val["id"];
if (!isset($this->idArray[$id])) {
continue;
}
$retArray[$id] = $this->idArray[$id];
}
return $retArray;
}
|
[
"public",
"function",
"searchLibrary",
"(",
"$",
"string",
",",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setUpList",
"(",
")",
";",
"$",
"this",
"->",
"search_library_stm",
"->",
"bindValue",
"(",
"':like'",
",",
"\"%$string%\"",
")",
";",
"$",
"this",
"->",
"search_library_stm",
"->",
"bindValue",
"(",
"':time'",
",",
"$",
"time",
"==",
"null",
"?",
"0",
":",
"$",
"time",
")",
";",
"$",
"this",
"->",
"search_library_stm",
"->",
"execute",
"(",
")",
";",
"$",
"retArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"search_library_stm",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
"as",
"$",
"val",
")",
"{",
"$",
"id",
"=",
"$",
"val",
"[",
"\"id\"",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"idArray",
"[",
"$",
"id",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"retArray",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"idArray",
"[",
"$",
"id",
"]",
";",
"}",
"return",
"$",
"retArray",
";",
"}"
] |
This will search the content of each content
and return an array containing all contents matching
the search string.
@param String $string
@param int $time Will limit the search to those contents after given timestamp
@return array
|
[
"This",
"will",
"search",
"the",
"content",
"of",
"each",
"content",
"and",
"return",
"an",
"array",
"containing",
"all",
"contents",
"matching",
"the",
"search",
"string",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/ContentLibraryImpl.php#L87-L104
|
233,850
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.setSource
|
public function setSource($source)
{
if ($source instanceof DataList) {
$this->setDataClass($source->dataClass());
}
return parent::setSource($source);
}
|
php
|
public function setSource($source)
{
if ($source instanceof DataList) {
$this->setDataClass($source->dataClass());
}
return parent::setSource($source);
}
|
[
"public",
"function",
"setSource",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"instanceof",
"DataList",
")",
"{",
"$",
"this",
"->",
"setDataClass",
"(",
"$",
"source",
"->",
"dataClass",
"(",
")",
")",
";",
"}",
"return",
"parent",
"::",
"setSource",
"(",
"$",
"source",
")",
";",
"}"
] |
Defines the source for the receiver.
@param array|ArrayAccess
@return $this
|
[
"Defines",
"the",
"source",
"for",
"the",
"receiver",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L197-L204
|
233,851
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.setAjaxConfig
|
public function setAjaxConfig($arg1, $arg2 = null)
{
if (is_array($arg1)) {
$this->ajaxConfig = $arg1;
} else {
$this->ajaxConfig[$arg1] = $arg2;
}
return $this;
}
|
php
|
public function setAjaxConfig($arg1, $arg2 = null)
{
if (is_array($arg1)) {
$this->ajaxConfig = $arg1;
} else {
$this->ajaxConfig[$arg1] = $arg2;
}
return $this;
}
|
[
"public",
"function",
"setAjaxConfig",
"(",
"$",
"arg1",
",",
"$",
"arg2",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"arg1",
")",
")",
"{",
"$",
"this",
"->",
"ajaxConfig",
"=",
"$",
"arg1",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ajaxConfig",
"[",
"$",
"arg1",
"]",
"=",
"$",
"arg2",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Defines either the named Ajax config value, or the Ajax config array.
@param string|array $arg1
@param mixed $arg2
@return $this
|
[
"Defines",
"either",
"the",
"named",
"Ajax",
"config",
"value",
"or",
"the",
"Ajax",
"config",
"array",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L214-L223
|
233,852
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getAjaxConfig
|
public function getAjaxConfig($name = null)
{
if (!is_null($name)) {
return isset($this->ajaxConfig[$name]) ? $this->ajaxConfig[$name] : null;
}
return $this->ajaxConfig;
}
|
php
|
public function getAjaxConfig($name = null)
{
if (!is_null($name)) {
return isset($this->ajaxConfig[$name]) ? $this->ajaxConfig[$name] : null;
}
return $this->ajaxConfig;
}
|
[
"public",
"function",
"getAjaxConfig",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"ajaxConfig",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"ajaxConfig",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"ajaxConfig",
";",
"}"
] |
Answers either the named Ajax config value, or the Ajax config array.
@param string $name
@return mixed
|
[
"Answers",
"either",
"the",
"named",
"Ajax",
"config",
"value",
"or",
"the",
"Ajax",
"config",
"array",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L232-L239
|
233,853
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.setDescriptor
|
public function setDescriptor($field, $order = 'ASC')
{
// Define Attributes:
$this->setTextField($field);
$this->setSearchFields([$field]);
$this->setSortBy([$field => $order]);
// Answer Self:
return $this;
}
|
php
|
public function setDescriptor($field, $order = 'ASC')
{
// Define Attributes:
$this->setTextField($field);
$this->setSearchFields([$field]);
$this->setSortBy([$field => $order]);
// Answer Self:
return $this;
}
|
[
"public",
"function",
"setDescriptor",
"(",
"$",
"field",
",",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"// Define Attributes:",
"$",
"this",
"->",
"setTextField",
"(",
"$",
"field",
")",
";",
"$",
"this",
"->",
"setSearchFields",
"(",
"[",
"$",
"field",
"]",
")",
";",
"$",
"this",
"->",
"setSortBy",
"(",
"[",
"$",
"field",
"=>",
"$",
"order",
"]",
")",
";",
"// Answer Self:",
"return",
"$",
"this",
";",
"}"
] |
Updates the text field, search fields and sort order to the specified field name.
@param string $field
@param string $order
@return $this
|
[
"Updates",
"the",
"text",
"field",
"search",
"fields",
"and",
"sort",
"order",
"to",
"the",
"specified",
"field",
"name",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L489-L500
|
233,854
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.search
|
public function search(HTTPRequest $request)
{
// Detect Ajax:
if (!$request->isAjax()) {
return;
}
// Initialise:
$data = ['results' => []];
// Create Data List:
$list = $this->getList();
// Filter Data List:
if ($term = $request->getVar('term')) {
$list = $list->filterAny($this->getSearchFilters($term))->exclude($this->getExclude());
}
// Sort Data List:
if ($sort = $this->getSortBy()) {
$list = $list->sort($sort);
}
// Limit Data List:
if ($limit = $this->getLimit()) {
$list = $list->limit($limit);
}
// Define Results:
foreach ($list as $record) {
$data['results'][] = $this->getResultData($record);
}
// Answer JSON Response:
return $this->respond($data);
}
|
php
|
public function search(HTTPRequest $request)
{
// Detect Ajax:
if (!$request->isAjax()) {
return;
}
// Initialise:
$data = ['results' => []];
// Create Data List:
$list = $this->getList();
// Filter Data List:
if ($term = $request->getVar('term')) {
$list = $list->filterAny($this->getSearchFilters($term))->exclude($this->getExclude());
}
// Sort Data List:
if ($sort = $this->getSortBy()) {
$list = $list->sort($sort);
}
// Limit Data List:
if ($limit = $this->getLimit()) {
$list = $list->limit($limit);
}
// Define Results:
foreach ($list as $record) {
$data['results'][] = $this->getResultData($record);
}
// Answer JSON Response:
return $this->respond($data);
}
|
[
"public",
"function",
"search",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"// Detect Ajax:",
"if",
"(",
"!",
"$",
"request",
"->",
"isAjax",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Initialise:",
"$",
"data",
"=",
"[",
"'results'",
"=>",
"[",
"]",
"]",
";",
"// Create Data List:",
"$",
"list",
"=",
"$",
"this",
"->",
"getList",
"(",
")",
";",
"// Filter Data List:",
"if",
"(",
"$",
"term",
"=",
"$",
"request",
"->",
"getVar",
"(",
"'term'",
")",
")",
"{",
"$",
"list",
"=",
"$",
"list",
"->",
"filterAny",
"(",
"$",
"this",
"->",
"getSearchFilters",
"(",
"$",
"term",
")",
")",
"->",
"exclude",
"(",
"$",
"this",
"->",
"getExclude",
"(",
")",
")",
";",
"}",
"// Sort Data List:",
"if",
"(",
"$",
"sort",
"=",
"$",
"this",
"->",
"getSortBy",
"(",
")",
")",
"{",
"$",
"list",
"=",
"$",
"list",
"->",
"sort",
"(",
"$",
"sort",
")",
";",
"}",
"// Limit Data List:",
"if",
"(",
"$",
"limit",
"=",
"$",
"this",
"->",
"getLimit",
"(",
")",
")",
"{",
"$",
"list",
"=",
"$",
"list",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"// Define Results:",
"foreach",
"(",
"$",
"list",
"as",
"$",
"record",
")",
"{",
"$",
"data",
"[",
"'results'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getResultData",
"(",
"$",
"record",
")",
";",
"}",
"// Answer JSON Response:",
"return",
"$",
"this",
"->",
"respond",
"(",
"$",
"data",
")",
";",
"}"
] |
Answers an HTTP response containing JSON results matching the given search parameters.
@param HTTPRequest $request
@return HTTPResponse
|
[
"Answers",
"an",
"HTTP",
"response",
"containing",
"JSON",
"results",
"matching",
"the",
"given",
"search",
"parameters",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L539-L582
|
233,855
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getSearchFilters
|
public function getSearchFilters($term)
{
$filters = [];
foreach ($this->getSearchFields() as $field) {
$filters[$this->getSearchFilterName($field)] = $term;
}
return $filters;
}
|
php
|
public function getSearchFilters($term)
{
$filters = [];
foreach ($this->getSearchFields() as $field) {
$filters[$this->getSearchFilterName($field)] = $term;
}
return $filters;
}
|
[
"public",
"function",
"getSearchFilters",
"(",
"$",
"term",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getSearchFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"filters",
"[",
"$",
"this",
"->",
"getSearchFilterName",
"(",
"$",
"field",
")",
"]",
"=",
"$",
"term",
";",
"}",
"return",
"$",
"filters",
";",
"}"
] |
Answers an array of search filters for the given term.
@param string $term
@return array
|
[
"Answers",
"an",
"array",
"of",
"search",
"filters",
"for",
"the",
"given",
"term",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L591-L600
|
233,856
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.saveIntoRelation
|
public function saveIntoRelation(Relation $relation)
{
$ids = [];
if ($values = $this->getValueArray()) {
$ids = $this->getList()->filter($this->getIDField(), $values)->getIDList();
}
$relation->setByIDList($ids);
}
|
php
|
public function saveIntoRelation(Relation $relation)
{
$ids = [];
if ($values = $this->getValueArray()) {
$ids = $this->getList()->filter($this->getIDField(), $values)->getIDList();
}
$relation->setByIDList($ids);
}
|
[
"public",
"function",
"saveIntoRelation",
"(",
"Relation",
"$",
"relation",
")",
"{",
"$",
"ids",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"values",
"=",
"$",
"this",
"->",
"getValueArray",
"(",
")",
")",
"{",
"$",
"ids",
"=",
"$",
"this",
"->",
"getList",
"(",
")",
"->",
"filter",
"(",
"$",
"this",
"->",
"getIDField",
"(",
")",
",",
"$",
"values",
")",
"->",
"getIDList",
"(",
")",
";",
"}",
"$",
"relation",
"->",
"setByIDList",
"(",
"$",
"ids",
")",
";",
"}"
] |
Saves the value of the field into the given relation.
@param Relation $relation
@return void
|
[
"Saves",
"the",
"value",
"of",
"the",
"field",
"into",
"the",
"given",
"relation",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L633-L642
|
233,857
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getResultData
|
protected function getResultData(ViewableData $record, $selected = false)
{
return [
'id' => $record->{$this->getIDField()},
'text' => $record->{$this->getTextField()},
'formattedResult' => $this->getFormattedResult($record),
'formattedSelection' => $this->getFormattedSelection($record),
'selected' => $selected
];
}
|
php
|
protected function getResultData(ViewableData $record, $selected = false)
{
return [
'id' => $record->{$this->getIDField()},
'text' => $record->{$this->getTextField()},
'formattedResult' => $this->getFormattedResult($record),
'formattedSelection' => $this->getFormattedSelection($record),
'selected' => $selected
];
}
|
[
"protected",
"function",
"getResultData",
"(",
"ViewableData",
"$",
"record",
",",
"$",
"selected",
"=",
"false",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"record",
"->",
"{",
"$",
"this",
"->",
"getIDField",
"(",
")",
"}",
",",
"'text'",
"=>",
"$",
"record",
"->",
"{",
"$",
"this",
"->",
"getTextField",
"(",
")",
"}",
",",
"'formattedResult'",
"=>",
"$",
"this",
"->",
"getFormattedResult",
"(",
"$",
"record",
")",
",",
"'formattedSelection'",
"=>",
"$",
"this",
"->",
"getFormattedSelection",
"(",
"$",
"record",
")",
",",
"'selected'",
"=>",
"$",
"selected",
"]",
";",
"}"
] |
Answers a result data array for the given record object.
@param ViewableData $record
@param boolean $selected
@return array
|
[
"Answers",
"a",
"result",
"data",
"array",
"for",
"the",
"given",
"record",
"object",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L719-L728
|
233,858
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getFormattedResult
|
protected function getFormattedResult(ViewableData $record)
{
if ($format = $this->getFormatResult()) {
return SSViewer::fromString($format)->process($record);
}
}
|
php
|
protected function getFormattedResult(ViewableData $record)
{
if ($format = $this->getFormatResult()) {
return SSViewer::fromString($format)->process($record);
}
}
|
[
"protected",
"function",
"getFormattedResult",
"(",
"ViewableData",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"format",
"=",
"$",
"this",
"->",
"getFormatResult",
"(",
")",
")",
"{",
"return",
"SSViewer",
"::",
"fromString",
"(",
"$",
"format",
")",
"->",
"process",
"(",
"$",
"record",
")",
";",
"}",
"}"
] |
Answers a formatted result string for the given record object.
@param ViewableData $record
@return string
|
[
"Answers",
"a",
"formatted",
"result",
"string",
"for",
"the",
"given",
"record",
"object",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L737-L742
|
233,859
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getFormattedSelection
|
protected function getFormattedSelection(ViewableData $record)
{
if ($format = $this->getFormatSelection()) {
return SSViewer::fromString($format)->process($record);
}
}
|
php
|
protected function getFormattedSelection(ViewableData $record)
{
if ($format = $this->getFormatSelection()) {
return SSViewer::fromString($format)->process($record);
}
}
|
[
"protected",
"function",
"getFormattedSelection",
"(",
"ViewableData",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"format",
"=",
"$",
"this",
"->",
"getFormatSelection",
"(",
")",
")",
"{",
"return",
"SSViewer",
"::",
"fromString",
"(",
"$",
"format",
")",
"->",
"process",
"(",
"$",
"record",
")",
";",
"}",
"}"
] |
Answers a formatted selection string for the given record object.
@param ViewableData $record
@return string
|
[
"Answers",
"a",
"formatted",
"selection",
"string",
"for",
"the",
"given",
"record",
"object",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L751-L756
|
233,860
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getListMap
|
protected function getListMap($source)
{
// Extract Map from ID / Text Fields:
if ($source instanceof SS_List) {
$source = $source->map($this->getIDField(), $this->getTextField());
}
// Convert Map to Array:
if ($source instanceof Map) {
$source = $source->toArray();
}
// Determine Invalid Types:
if (!is_array($source) && !($source instanceof ArrayAccess)) {
user_error('$source passed in as invalid type', E_USER_ERROR);
}
// Answer Data Source:
return $source;
}
|
php
|
protected function getListMap($source)
{
// Extract Map from ID / Text Fields:
if ($source instanceof SS_List) {
$source = $source->map($this->getIDField(), $this->getTextField());
}
// Convert Map to Array:
if ($source instanceof Map) {
$source = $source->toArray();
}
// Determine Invalid Types:
if (!is_array($source) && !($source instanceof ArrayAccess)) {
user_error('$source passed in as invalid type', E_USER_ERROR);
}
// Answer Data Source:
return $source;
}
|
[
"protected",
"function",
"getListMap",
"(",
"$",
"source",
")",
"{",
"// Extract Map from ID / Text Fields:",
"if",
"(",
"$",
"source",
"instanceof",
"SS_List",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"->",
"map",
"(",
"$",
"this",
"->",
"getIDField",
"(",
")",
",",
"$",
"this",
"->",
"getTextField",
"(",
")",
")",
";",
"}",
"// Convert Map to Array:",
"if",
"(",
"$",
"source",
"instanceof",
"Map",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"->",
"toArray",
"(",
")",
";",
"}",
"// Determine Invalid Types:",
"if",
"(",
"!",
"is_array",
"(",
"$",
"source",
")",
"&&",
"!",
"(",
"$",
"source",
"instanceof",
"ArrayAccess",
")",
")",
"{",
"user_error",
"(",
"'$source passed in as invalid type'",
",",
"E_USER_ERROR",
")",
";",
"}",
"// Answer Data Source:",
"return",
"$",
"source",
";",
"}"
] |
Converts the given data source into an array.
@param array|ArrayAccess $source
@return array
|
[
"Converts",
"the",
"given",
"data",
"source",
"into",
"an",
"array",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L765-L788
|
233,861
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getFieldConfig
|
protected function getFieldConfig()
{
$config = parent::getFieldConfig();
if ($values = $this->getValueArray()) {
$data = [];
foreach ($values as $value) {
if ($record = $this->getValueRecord($value)) {
$data[] = $this->getResultData($record, true);
}
}
$config['data'] = $data;
}
return $config;
}
|
php
|
protected function getFieldConfig()
{
$config = parent::getFieldConfig();
if ($values = $this->getValueArray()) {
$data = [];
foreach ($values as $value) {
if ($record = $this->getValueRecord($value)) {
$data[] = $this->getResultData($record, true);
}
}
$config['data'] = $data;
}
return $config;
}
|
[
"protected",
"function",
"getFieldConfig",
"(",
")",
"{",
"$",
"config",
"=",
"parent",
"::",
"getFieldConfig",
"(",
")",
";",
"if",
"(",
"$",
"values",
"=",
"$",
"this",
"->",
"getValueArray",
"(",
")",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"record",
"=",
"$",
"this",
"->",
"getValueRecord",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"this",
"->",
"getResultData",
"(",
"$",
"record",
",",
"true",
")",
";",
"}",
"}",
"$",
"config",
"[",
"'data'",
"]",
"=",
"$",
"data",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Answers the field config for the receiver.
@return array
|
[
"Answers",
"the",
"field",
"config",
"for",
"the",
"receiver",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L795-L816
|
233,862
|
praxisnetau/silverware-select2
|
src/Forms/Select2AjaxField.php
|
Select2AjaxField.getFieldAjaxConfig
|
protected function getFieldAjaxConfig()
{
$config = $this->getAjaxConfig();
if (!isset($config['url'])) {
$config['url'] = $this->Link('search');
}
return $config;
}
|
php
|
protected function getFieldAjaxConfig()
{
$config = $this->getAjaxConfig();
if (!isset($config['url'])) {
$config['url'] = $this->Link('search');
}
return $config;
}
|
[
"protected",
"function",
"getFieldAjaxConfig",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getAjaxConfig",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'url'",
"]",
"=",
"$",
"this",
"->",
"Link",
"(",
"'search'",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Answers the field Ajax config for the receiver.
@return array
|
[
"Answers",
"the",
"field",
"Ajax",
"config",
"for",
"the",
"receiver",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L823-L832
|
233,863
|
lamoni/junosnetconf
|
JunosNetConf.php
|
JunosNetConf.loadConfigurationRaw
|
public function loadConfigurationRaw($configData="", $configNode="", array $customAttributes)
{
if ($configData !== "" && $configNode !== "") {
$loadConfig = "<load-configuration>".
"<{$configNode}>".
"{$configData}".
"</{$configNode}>".
"</load-configuration>";
}
else {
$loadConfig = "<load-configuration/>";
}
$loadConfig = new \SimpleXMLElement($loadConfig);
foreach ($customAttributes as $attributeName=>$attributeValue) {
$loadConfig->addAttribute($attributeName, $attributeValue);
}
return $this->netConf()->sendRPC($loadConfig->asXML());
}
|
php
|
public function loadConfigurationRaw($configData="", $configNode="", array $customAttributes)
{
if ($configData !== "" && $configNode !== "") {
$loadConfig = "<load-configuration>".
"<{$configNode}>".
"{$configData}".
"</{$configNode}>".
"</load-configuration>";
}
else {
$loadConfig = "<load-configuration/>";
}
$loadConfig = new \SimpleXMLElement($loadConfig);
foreach ($customAttributes as $attributeName=>$attributeValue) {
$loadConfig->addAttribute($attributeName, $attributeValue);
}
return $this->netConf()->sendRPC($loadConfig->asXML());
}
|
[
"public",
"function",
"loadConfigurationRaw",
"(",
"$",
"configData",
"=",
"\"\"",
",",
"$",
"configNode",
"=",
"\"\"",
",",
"array",
"$",
"customAttributes",
")",
"{",
"if",
"(",
"$",
"configData",
"!==",
"\"\"",
"&&",
"$",
"configNode",
"!==",
"\"\"",
")",
"{",
"$",
"loadConfig",
"=",
"\"<load-configuration>\"",
".",
"\"<{$configNode}>\"",
".",
"\"{$configData}\"",
".",
"\"</{$configNode}>\"",
".",
"\"</load-configuration>\"",
";",
"}",
"else",
"{",
"$",
"loadConfig",
"=",
"\"<load-configuration/>\"",
";",
"}",
"$",
"loadConfig",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"loadConfig",
")",
";",
"foreach",
"(",
"$",
"customAttributes",
"as",
"$",
"attributeName",
"=>",
"$",
"attributeValue",
")",
"{",
"$",
"loadConfig",
"->",
"addAttribute",
"(",
"$",
"attributeName",
",",
"$",
"attributeValue",
")",
";",
"}",
"return",
"$",
"this",
"->",
"netConf",
"(",
")",
"->",
"sendRPC",
"(",
"$",
"loadConfig",
"->",
"asXML",
"(",
")",
")",
";",
"}"
] |
Base method for loading configuration into the device's candidate configuration.
@param string $configData
@param string $configNode
@param array $customAttributes
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC
|
[
"Base",
"method",
"for",
"loading",
"configuration",
"into",
"the",
"device",
"s",
"candidate",
"configuration",
"."
] |
fc74d9c0c4eb32578e7c91c5457dd43841f327b2
|
https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L101-L128
|
233,864
|
lamoni/junosnetconf
|
JunosNetConf.php
|
JunosNetConf.commitConfigurationRaw
|
public function commitConfigurationRaw(array $customParams, $synchronize=true)
{
if ($synchronize === true) {
$customParams['synchronize'] = '';
}
$commitConfig = new \SimpleXMLElement('<commit-configuration/>');
foreach ($customParams as $paramName => $paramValue) {
$commitConfig->addChild(
$paramName,
$paramValue
);
}
return $this->netConf()->sendRPC($commitConfig->asXML());
}
|
php
|
public function commitConfigurationRaw(array $customParams, $synchronize=true)
{
if ($synchronize === true) {
$customParams['synchronize'] = '';
}
$commitConfig = new \SimpleXMLElement('<commit-configuration/>');
foreach ($customParams as $paramName => $paramValue) {
$commitConfig->addChild(
$paramName,
$paramValue
);
}
return $this->netConf()->sendRPC($commitConfig->asXML());
}
|
[
"public",
"function",
"commitConfigurationRaw",
"(",
"array",
"$",
"customParams",
",",
"$",
"synchronize",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"synchronize",
"===",
"true",
")",
"{",
"$",
"customParams",
"[",
"'synchronize'",
"]",
"=",
"''",
";",
"}",
"$",
"commitConfig",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"'<commit-configuration/>'",
")",
";",
"foreach",
"(",
"$",
"customParams",
"as",
"$",
"paramName",
"=>",
"$",
"paramValue",
")",
"{",
"$",
"commitConfig",
"->",
"addChild",
"(",
"$",
"paramName",
",",
"$",
"paramValue",
")",
";",
"}",
"return",
"$",
"this",
"->",
"netConf",
"(",
")",
"->",
"sendRPC",
"(",
"$",
"commitConfig",
"->",
"asXML",
"(",
")",
")",
";",
"}"
] |
Base for committing the candidate configuration to the active configuration.
@param array $customParams
@param bool $synchronize
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC
|
[
"Base",
"for",
"committing",
"the",
"candidate",
"configuration",
"to",
"the",
"active",
"configuration",
"."
] |
fc74d9c0c4eb32578e7c91c5457dd43841f327b2
|
https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L372-L394
|
233,865
|
lamoni/junosnetconf
|
JunosNetConf.php
|
JunosNetConf.getConfigurationRaw
|
public function getConfigurationRaw($configData, array $customAttributes=[])
{
$getConfig = new \SimpleXMLElement(
"<get-configuration>".
"{$configData}".
"</get-configuration>"
);
foreach ($customAttributes as $attrName => $attrValue) {
$getConfig->addAttribute($attrName, $attrValue);
}
return $this->netConf()->sendRPC($getConfig->asXML());
}
|
php
|
public function getConfigurationRaw($configData, array $customAttributes=[])
{
$getConfig = new \SimpleXMLElement(
"<get-configuration>".
"{$configData}".
"</get-configuration>"
);
foreach ($customAttributes as $attrName => $attrValue) {
$getConfig->addAttribute($attrName, $attrValue);
}
return $this->netConf()->sendRPC($getConfig->asXML());
}
|
[
"public",
"function",
"getConfigurationRaw",
"(",
"$",
"configData",
",",
"array",
"$",
"customAttributes",
"=",
"[",
"]",
")",
"{",
"$",
"getConfig",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"\"<get-configuration>\"",
".",
"\"{$configData}\"",
".",
"\"</get-configuration>\"",
")",
";",
"foreach",
"(",
"$",
"customAttributes",
"as",
"$",
"attrName",
"=>",
"$",
"attrValue",
")",
"{",
"$",
"getConfig",
"->",
"addAttribute",
"(",
"$",
"attrName",
",",
"$",
"attrValue",
")",
";",
"}",
"return",
"$",
"this",
"->",
"netConf",
"(",
")",
"->",
"sendRPC",
"(",
"$",
"getConfig",
"->",
"asXML",
"(",
")",
")",
";",
"}"
] |
Base for getting the device's configuration.
@param $configData
@param array $customAttributes
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC
|
[
"Base",
"for",
"getting",
"the",
"device",
"s",
"configuration",
"."
] |
fc74d9c0c4eb32578e7c91c5457dd43841f327b2
|
https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L505-L523
|
233,866
|
xylemical/php-expressions
|
src/Lexer.php
|
Lexer.tokenize
|
public function tokenize($string)
{
// Get the list of sorted operators.
$operators = $this->factory->getOperators();
// Get the operator regular expression.
$regex = $this->getRegex($operators);
// Check that we have matched all the tokens in the string.
if (!preg_match_all($regex, $string, $matches, PREG_SET_ORDER)) {
throw new LexerException('Unable to tokenize string.');
}
// Cycle through all available tokens.
$tokens = [];
foreach ($matches as $match) {
$item = $match[0];
// Process the parentheses as special cases.
if (in_array($item, ['(', ')', ','])) {
$tokens[] = new Token($item);
continue;
}
// Locate the first operator that matches the token.
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator) {
if (preg_match('#^' . $operator->getRegex() . '$#i', $item)) {
$tokens[] = new Token($item, $operator);
break;
}
}
}
return $tokens;
}
|
php
|
public function tokenize($string)
{
// Get the list of sorted operators.
$operators = $this->factory->getOperators();
// Get the operator regular expression.
$regex = $this->getRegex($operators);
// Check that we have matched all the tokens in the string.
if (!preg_match_all($regex, $string, $matches, PREG_SET_ORDER)) {
throw new LexerException('Unable to tokenize string.');
}
// Cycle through all available tokens.
$tokens = [];
foreach ($matches as $match) {
$item = $match[0];
// Process the parentheses as special cases.
if (in_array($item, ['(', ')', ','])) {
$tokens[] = new Token($item);
continue;
}
// Locate the first operator that matches the token.
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator) {
if (preg_match('#^' . $operator->getRegex() . '$#i', $item)) {
$tokens[] = new Token($item, $operator);
break;
}
}
}
return $tokens;
}
|
[
"public",
"function",
"tokenize",
"(",
"$",
"string",
")",
"{",
"// Get the list of sorted operators.",
"$",
"operators",
"=",
"$",
"this",
"->",
"factory",
"->",
"getOperators",
"(",
")",
";",
"// Get the operator regular expression.",
"$",
"regex",
"=",
"$",
"this",
"->",
"getRegex",
"(",
"$",
"operators",
")",
";",
"// Check that we have matched all the tokens in the string.",
"if",
"(",
"!",
"preg_match_all",
"(",
"$",
"regex",
",",
"$",
"string",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
")",
"{",
"throw",
"new",
"LexerException",
"(",
"'Unable to tokenize string.'",
")",
";",
"}",
"// Cycle through all available tokens.",
"$",
"tokens",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"match",
")",
"{",
"$",
"item",
"=",
"$",
"match",
"[",
"0",
"]",
";",
"// Process the parentheses as special cases.",
"if",
"(",
"in_array",
"(",
"$",
"item",
",",
"[",
"'('",
",",
"')'",
",",
"','",
"]",
")",
")",
"{",
"$",
"tokens",
"[",
"]",
"=",
"new",
"Token",
"(",
"$",
"item",
")",
";",
"continue",
";",
"}",
"// Locate the first operator that matches the token.",
"/** @var \\Xylemical\\Expressions\\Operator $operator */",
"foreach",
"(",
"$",
"operators",
"as",
"$",
"operator",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#^'",
".",
"$",
"operator",
"->",
"getRegex",
"(",
")",
".",
"'$#i'",
",",
"$",
"item",
")",
")",
"{",
"$",
"tokens",
"[",
"]",
"=",
"new",
"Token",
"(",
"$",
"item",
",",
"$",
"operator",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"tokens",
";",
"}"
] |
Converts a string into tokens.
@param $string
@return \Xylemical\Expressions\Token[]
@throws \Xylemical\Expressions\LexerException
|
[
"Converts",
"a",
"string",
"into",
"tokens",
"."
] |
4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73
|
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Lexer.php#L41-L76
|
233,867
|
xylemical/php-expressions
|
src/Lexer.php
|
Lexer.getRegex
|
protected function getRegex($operators)
{
$regexes = [];
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator)
{
$regexes[] = $operator->getRegex();
}
// Add parentheses regexes.
$regexes[] = '\(';
$regexes[] = '\)';
$regexes[] = ',';
// Generate the full regex.
return '#(?:' . implode('|', $regexes) . ')#i';
}
|
php
|
protected function getRegex($operators)
{
$regexes = [];
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator)
{
$regexes[] = $operator->getRegex();
}
// Add parentheses regexes.
$regexes[] = '\(';
$regexes[] = '\)';
$regexes[] = ',';
// Generate the full regex.
return '#(?:' . implode('|', $regexes) . ')#i';
}
|
[
"protected",
"function",
"getRegex",
"(",
"$",
"operators",
")",
"{",
"$",
"regexes",
"=",
"[",
"]",
";",
"/** @var \\Xylemical\\Expressions\\Operator $operator */",
"foreach",
"(",
"$",
"operators",
"as",
"$",
"operator",
")",
"{",
"$",
"regexes",
"[",
"]",
"=",
"$",
"operator",
"->",
"getRegex",
"(",
")",
";",
"}",
"// Add parentheses regexes.",
"$",
"regexes",
"[",
"]",
"=",
"'\\('",
";",
"$",
"regexes",
"[",
"]",
"=",
"'\\)'",
";",
"$",
"regexes",
"[",
"]",
"=",
"','",
";",
"// Generate the full regex.",
"return",
"'#(?:'",
".",
"implode",
"(",
"'|'",
",",
"$",
"regexes",
")",
".",
"')#i'",
";",
"}"
] |
Get the regex used to locate tokens.
@return string
|
[
"Get",
"the",
"regex",
"used",
"to",
"locate",
"tokens",
"."
] |
4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73
|
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Lexer.php#L83-L100
|
233,868
|
baleen/migrations
|
src/Delta/Collection/Collection.php
|
Collection.find
|
public function find($element, $resolve = true)
{
$result = null;
if (is_object($element)) {
$element = (string) $element;
}
if ($resolve && is_string($element)) {
$result = $this->getResolver()->resolve($element, $this);
}
if (null === $result && is_scalar($element)) {
$result = $this->get($element);
}
return $result;
}
|
php
|
public function find($element, $resolve = true)
{
$result = null;
if (is_object($element)) {
$element = (string) $element;
}
if ($resolve && is_string($element)) {
$result = $this->getResolver()->resolve($element, $this);
}
if (null === $result && is_scalar($element)) {
$result = $this->get($element);
}
return $result;
}
|
[
"public",
"function",
"find",
"(",
"$",
"element",
",",
"$",
"resolve",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"is_object",
"(",
"$",
"element",
")",
")",
"{",
"$",
"element",
"=",
"(",
"string",
")",
"$",
"element",
";",
"}",
"if",
"(",
"$",
"resolve",
"&&",
"is_string",
"(",
"$",
"element",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getResolver",
"(",
")",
"->",
"resolve",
"(",
"$",
"element",
",",
"$",
"this",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"result",
"&&",
"is_scalar",
"(",
"$",
"element",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"element",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Gets an element.
@param mixed $element If an alias is given then it will be resolved to an element. Otherwise the $key will be used
to fetch the element by index.
@param bool $resolve Whether to use the resolver or not.
@return DeltaInterface|null Null if not present
|
[
"Gets",
"an",
"element",
"."
] |
cfc8c439858cf4f0d4119af9eb67de493da8d95c
|
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Collection.php#L93-L110
|
233,869
|
baleen/migrations
|
src/Delta/Collection/Collection.php
|
Collection.add
|
public function add(DeltaInterface $version)
{
$this->validate($version);
$result = parent::add($version);
if ($result) {
$this->invalidateResolverCache();
}
return $result;
}
|
php
|
public function add(DeltaInterface $version)
{
$this->validate($version);
$result = parent::add($version);
if ($result) {
$this->invalidateResolverCache();
}
return $result;
}
|
[
"public",
"function",
"add",
"(",
"DeltaInterface",
"$",
"version",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"version",
")",
";",
"$",
"result",
"=",
"parent",
"::",
"add",
"(",
"$",
"version",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"invalidateResolverCache",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Add a version to the collection
@param mixed $version
@return bool
@throws CollectionException
@throws InvalidArgumentException
|
[
"Add",
"a",
"version",
"to",
"the",
"collection"
] |
cfc8c439858cf4f0d4119af9eb67de493da8d95c
|
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Collection.php#L151-L160
|
233,870
|
kaliop-uk/kueueingbundle
|
Adapter/RabbitMq/Consumer.php
|
Consumer.setCallback
|
public function setCallback($callback)
{
if ($callback instanceof \OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface) {
$callback = array($callback, 'execute');
}
$this->callback = $callback;
return $this;
}
|
php
|
public function setCallback($callback)
{
if ($callback instanceof \OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface) {
$callback = array($callback, 'execute');
}
$this->callback = $callback;
return $this;
}
|
[
"public",
"function",
"setCallback",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"callback",
"instanceof",
"\\",
"OldSound",
"\\",
"RabbitMqBundle",
"\\",
"RabbitMq",
"\\",
"ConsumerInterface",
")",
"{",
"$",
"callback",
"=",
"array",
"(",
"$",
"callback",
",",
"'execute'",
")",
";",
"}",
"$",
"this",
"->",
"callback",
"=",
"$",
"callback",
";",
"return",
"$",
"this",
";",
"}"
] |
Overridden to make it fluent, plus accept an object as well
@param callable|\OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface $callback
@return Consumer
|
[
"Overridden",
"to",
"make",
"it",
"fluent",
"plus",
"accept",
"an",
"object",
"as",
"well"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L77-L85
|
233,871
|
kaliop-uk/kueueingbundle
|
Adapter/RabbitMq/Consumer.php
|
Consumer.setRoutingKey
|
public function setRoutingKey($routingKey)
{
// we have to throw an exception, otherwise the new routing key will just be ignored
if ($this->queueDeclared && $this->routingKey != $routingKey) {
throw new \RuntimeException('AMQP Consumer can not use a new routing key: queue has already been declared');
}
$this->routingKey = $routingKey;
return $this;
}
|
php
|
public function setRoutingKey($routingKey)
{
// we have to throw an exception, otherwise the new routing key will just be ignored
if ($this->queueDeclared && $this->routingKey != $routingKey) {
throw new \RuntimeException('AMQP Consumer can not use a new routing key: queue has already been declared');
}
$this->routingKey = $routingKey;
return $this;
}
|
[
"public",
"function",
"setRoutingKey",
"(",
"$",
"routingKey",
")",
"{",
"// we have to throw an exception, otherwise the new routing key will just be ignored",
"if",
"(",
"$",
"this",
"->",
"queueDeclared",
"&&",
"$",
"this",
"->",
"routingKey",
"!=",
"$",
"routingKey",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'AMQP Consumer can not use a new routing key: queue has already been declared'",
")",
";",
"}",
"$",
"this",
"->",
"routingKey",
"=",
"$",
"routingKey",
";",
"return",
"$",
"this",
";",
"}"
] |
Overridden to make it fluent
@param string $routingKey
@return Consumer
@throws \RuntimeException
|
[
"Overridden",
"to",
"make",
"it",
"fluent"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L106-L115
|
233,872
|
kaliop-uk/kueueingbundle
|
Adapter/RabbitMq/Consumer.php
|
Consumer.consume
|
public function consume($msgAmount, $timeout=0)
{
if ($timeout > 0) {
// save initial time
$loopBegin = time();
$remaining = $timeout;
// reimplement parent::consume() to inject the timeout
$this->target = $msgAmount;
$this->setupConsumer();
while (count($this->getChannel()->callbacks)) {
// avoid waiting more than timeout seconds for message reception
$this->setIdleTimeout($remaining);
$this->maybeStopConsumer();
try {
$this->getChannel()->wait(null, true, $this->getIdleTimeout());
} catch (AMQPTimeoutException $e) {
return;
}
$remaining = $loopBegin + $timeout - time();
if ($remaining <= 0) {
$this->forceStopConsumer();
}
}
} else {
$this->loopBegin = null;
parent::consume($msgAmount);
}
}
|
php
|
public function consume($msgAmount, $timeout=0)
{
if ($timeout > 0) {
// save initial time
$loopBegin = time();
$remaining = $timeout;
// reimplement parent::consume() to inject the timeout
$this->target = $msgAmount;
$this->setupConsumer();
while (count($this->getChannel()->callbacks)) {
// avoid waiting more than timeout seconds for message reception
$this->setIdleTimeout($remaining);
$this->maybeStopConsumer();
try {
$this->getChannel()->wait(null, true, $this->getIdleTimeout());
} catch (AMQPTimeoutException $e) {
return;
}
$remaining = $loopBegin + $timeout - time();
if ($remaining <= 0) {
$this->forceStopConsumer();
}
}
} else {
$this->loopBegin = null;
parent::consume($msgAmount);
}
}
|
[
"public",
"function",
"consume",
"(",
"$",
"msgAmount",
",",
"$",
"timeout",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"timeout",
">",
"0",
")",
"{",
"// save initial time",
"$",
"loopBegin",
"=",
"time",
"(",
")",
";",
"$",
"remaining",
"=",
"$",
"timeout",
";",
"// reimplement parent::consume() to inject the timeout",
"$",
"this",
"->",
"target",
"=",
"$",
"msgAmount",
";",
"$",
"this",
"->",
"setupConsumer",
"(",
")",
";",
"while",
"(",
"count",
"(",
"$",
"this",
"->",
"getChannel",
"(",
")",
"->",
"callbacks",
")",
")",
"{",
"// avoid waiting more than timeout seconds for message reception",
"$",
"this",
"->",
"setIdleTimeout",
"(",
"$",
"remaining",
")",
";",
"$",
"this",
"->",
"maybeStopConsumer",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"getChannel",
"(",
")",
"->",
"wait",
"(",
"null",
",",
"true",
",",
"$",
"this",
"->",
"getIdleTimeout",
"(",
")",
")",
";",
"}",
"catch",
"(",
"AMQPTimeoutException",
"$",
"e",
")",
"{",
"return",
";",
"}",
"$",
"remaining",
"=",
"$",
"loopBegin",
"+",
"$",
"timeout",
"-",
"time",
"(",
")",
";",
"if",
"(",
"$",
"remaining",
"<=",
"0",
")",
"{",
"$",
"this",
"->",
"forceStopConsumer",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"loopBegin",
"=",
"null",
";",
"parent",
"::",
"consume",
"(",
"$",
"msgAmount",
")",
";",
"}",
"}"
] |
Overridden to add support for timeout
@param int $msgAmount
@param int $timeout
|
[
"Overridden",
"to",
"add",
"support",
"for",
"timeout"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L122-L150
|
233,873
|
kaliop-uk/kueueingbundle
|
Adapter/RabbitMq/Consumer.php
|
Consumer.processMessage
|
public function processMessage(BaseAMQPMessage $msg)
{
$newMsg = new AMQPMessage($msg->body, $msg->get_properties());
$newMsg->delivery_info = $msg->delivery_info;
$newMsg->body_size = $msg->body_size;
$newMsg->is_truncated = $msg->is_truncated;
$newMsg->setQueueName($this->queueName);
$processFlag = call_user_func($this->callback, $newMsg);
$this->handleProcessMessage($newMsg, $processFlag);
}
|
php
|
public function processMessage(BaseAMQPMessage $msg)
{
$newMsg = new AMQPMessage($msg->body, $msg->get_properties());
$newMsg->delivery_info = $msg->delivery_info;
$newMsg->body_size = $msg->body_size;
$newMsg->is_truncated = $msg->is_truncated;
$newMsg->setQueueName($this->queueName);
$processFlag = call_user_func($this->callback, $newMsg);
$this->handleProcessMessage($newMsg, $processFlag);
}
|
[
"public",
"function",
"processMessage",
"(",
"BaseAMQPMessage",
"$",
"msg",
")",
"{",
"$",
"newMsg",
"=",
"new",
"AMQPMessage",
"(",
"$",
"msg",
"->",
"body",
",",
"$",
"msg",
"->",
"get_properties",
"(",
")",
")",
";",
"$",
"newMsg",
"->",
"delivery_info",
"=",
"$",
"msg",
"->",
"delivery_info",
";",
"$",
"newMsg",
"->",
"body_size",
"=",
"$",
"msg",
"->",
"body_size",
";",
"$",
"newMsg",
"->",
"is_truncated",
"=",
"$",
"msg",
"->",
"is_truncated",
";",
"$",
"newMsg",
"->",
"setQueueName",
"(",
"$",
"this",
"->",
"queueName",
")",
";",
"$",
"processFlag",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"callback",
",",
"$",
"newMsg",
")",
";",
"$",
"this",
"->",
"handleProcessMessage",
"(",
"$",
"newMsg",
",",
"$",
"processFlag",
")",
";",
"}"
] |
Overridden to inject the queue name into the AMQP message
@param BaseAMQPMessage $msg
|
[
"Overridden",
"to",
"inject",
"the",
"queue",
"name",
"into",
"the",
"AMQP",
"message"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L156-L166
|
233,874
|
budde377/Part
|
lib/util/file/FileImpl.php
|
FileImpl.move
|
public function move($path)
{
if($this->isDirectory()){
return false;
}
$path = $this->relativeToAbsolute($path);
if (($ret = @rename($this->filePath, $path)) === true) {
$this->filePath = $path;
}
return $ret;
}
|
php
|
public function move($path)
{
if($this->isDirectory()){
return false;
}
$path = $this->relativeToAbsolute($path);
if (($ret = @rename($this->filePath, $path)) === true) {
$this->filePath = $path;
}
return $ret;
}
|
[
"public",
"function",
"move",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDirectory",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"relativeToAbsolute",
"(",
"$",
"path",
")",
";",
"if",
"(",
"(",
"$",
"ret",
"=",
"@",
"rename",
"(",
"$",
"this",
"->",
"filePath",
",",
"$",
"path",
")",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"filePath",
"=",
"$",
"path",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Will move the file to specified path
@param string $path
@return bool TRUE if success FALSE if failure
|
[
"Will",
"move",
"the",
"file",
"to",
"specified",
"path"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileImpl.php#L93-L104
|
233,875
|
budde377/Part
|
lib/util/file/FileImpl.php
|
FileImpl.write
|
public function write($string)
{
$handle = @fopen($this->filePath, $this->mode);
if ($handle === false) {
return $handle;
}
return @fwrite($handle, $string);
}
|
php
|
public function write($string)
{
$handle = @fopen($this->filePath, $this->mode);
if ($handle === false) {
return $handle;
}
return @fwrite($handle, $string);
}
|
[
"public",
"function",
"write",
"(",
"$",
"string",
")",
"{",
"$",
"handle",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"filePath",
",",
"$",
"this",
"->",
"mode",
")",
";",
"if",
"(",
"$",
"handle",
"===",
"false",
")",
"{",
"return",
"$",
"handle",
";",
"}",
"return",
"@",
"fwrite",
"(",
"$",
"handle",
",",
"$",
"string",
")",
";",
"}"
] |
Writes to file
@param $string
@return int | bool Returns the number of bytes written, or FALSE on error.
|
[
"Writes",
"to",
"file"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileImpl.php#L138-L147
|
233,876
|
budde377/Part
|
lib/util/file/FileImpl.php
|
FileImpl.setAccessMode
|
public function setAccessMode($permissions)
{
switch ($permissions) {
case File::FILE_MODE_RW_POINTER_AT_END:
case File::FILE_MODE_W_POINTER_AT_END:
case File::FILE_MODE_R_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH:
case File::FILE_MODE_W_TRUNCATE_FILE_TO_ZERO_LENGTH:
$this->mode = $permissions;
}
}
|
php
|
public function setAccessMode($permissions)
{
switch ($permissions) {
case File::FILE_MODE_RW_POINTER_AT_END:
case File::FILE_MODE_W_POINTER_AT_END:
case File::FILE_MODE_R_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH:
case File::FILE_MODE_W_TRUNCATE_FILE_TO_ZERO_LENGTH:
$this->mode = $permissions;
}
}
|
[
"public",
"function",
"setAccessMode",
"(",
"$",
"permissions",
")",
"{",
"switch",
"(",
"$",
"permissions",
")",
"{",
"case",
"File",
"::",
"FILE_MODE_RW_POINTER_AT_END",
":",
"case",
"File",
"::",
"FILE_MODE_W_POINTER_AT_END",
":",
"case",
"File",
"::",
"FILE_MODE_R_POINTER_AT_BEGINNING",
":",
"case",
"File",
"::",
"FILE_MODE_RW_POINTER_AT_BEGINNING",
":",
"case",
"File",
"::",
"FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH",
":",
"case",
"File",
"::",
"FILE_MODE_W_TRUNCATE_FILE_TO_ZERO_LENGTH",
":",
"$",
"this",
"->",
"mode",
"=",
"$",
"permissions",
";",
"}",
"}"
] |
Sets the access mode, available options is in FileModeEnum
@param string $permissions
@return void
|
[
"Sets",
"the",
"access",
"mode",
"available",
"options",
"is",
"in",
"FileModeEnum"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileImpl.php#L154-L167
|
233,877
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php
|
ClassWithFixed64PropertyMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithFixed64Property();
case 1:
return new ClassWithFixed64Property(func_get_arg(0));
case 2:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithFixed64Property();
case 1:
return new ClassWithFixed64Property(func_get_arg(0));
case 2:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithFixed64Property
@throws \InvalidArgumentException
@return ClassWithFixed64Property
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithFixed64Property"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php#L66-L90
|
233,878
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php
|
ClassWithFixed64PropertyMeta.fromProtobuf
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new ClassWithFixed64Property();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 1) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 1.', $number);
}
$expectedStart = $start + 8;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->x = Binary::decodeUint64($input, $start);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
}
|
php
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new ClassWithFixed64Property();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 1) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 1.', $number);
}
$expectedStart = $start + 8;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->x = Binary::decodeUint64($input, $start);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
}
|
[
"public",
"static",
"function",
"fromProtobuf",
"(",
"$",
"input",
",",
"$",
"object",
"=",
"NULL",
",",
"&",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"ClassWithFixed64Property",
"(",
")",
";",
"}",
"if",
"(",
"$",
"end",
"===",
"null",
")",
"{",
"$",
"end",
"=",
"strlen",
"(",
"$",
"input",
")",
";",
"}",
"while",
"(",
"$",
"start",
"<",
"$",
"end",
")",
"{",
"$",
"tag",
"=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"$",
"wireType",
"=",
"$",
"tag",
"&",
"0x7",
";",
"$",
"number",
"=",
"$",
"tag",
">>",
"3",
";",
"switch",
"(",
"$",
"number",
")",
"{",
"case",
"1",
":",
"if",
"(",
"$",
"wireType",
"!==",
"1",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected wire type '",
".",
"$",
"wireType",
".",
"', expected 1.'",
",",
"$",
"number",
")",
";",
"}",
"$",
"expectedStart",
"=",
"$",
"start",
"+",
"8",
";",
"if",
"(",
"$",
"expectedStart",
">",
"$",
"end",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Not enough data.'",
")",
";",
"}",
"$",
"object",
"->",
"x",
"=",
"Binary",
"::",
"decodeUint64",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"if",
"(",
"$",
"start",
"!==",
"$",
"expectedStart",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected start. Expected '",
".",
"$",
"expectedStart",
".",
"', got '",
".",
"$",
"start",
".",
"'.'",
",",
"$",
"number",
")",
";",
"}",
"break",
";",
"default",
":",
"switch",
"(",
"$",
"wireType",
")",
"{",
"case",
"0",
":",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"start",
"+=",
"8",
";",
"break",
";",
"case",
"2",
":",
"$",
"start",
"+=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"break",
";",
"case",
"5",
":",
"$",
"start",
"+=",
"4",
";",
"break",
";",
"default",
":",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected wire type '",
".",
"$",
"wireType",
".",
"'.'",
",",
"$",
"number",
")",
";",
"}",
"}",
"}",
"return",
"$",
"object",
";",
"}"
] |
Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithFixed64Property object from serialized Protocol Buffers message.
@param string $input
@param ClassWithFixed64Property $object
@param int $start
@param int $end
@throws \Exception
@return ClassWithFixed64Property
|
[
"Creates",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithFixed64Property",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php#L332-L381
|
233,879
|
willmorgan/silverstripe-cropperfield
|
code/CropperField.php
|
CropperField.saveInto
|
public function saveInto(DataObjectInterface $object) {
if(!$this->canCrop() || !$this->hasSourceFile()) {
return;
}
$object->setField($this->getName() . 'ID', $this->generateCropped()->ID);
$object->write();
}
|
php
|
public function saveInto(DataObjectInterface $object) {
if(!$this->canCrop() || !$this->hasSourceFile()) {
return;
}
$object->setField($this->getName() . 'ID', $this->generateCropped()->ID);
$object->write();
}
|
[
"public",
"function",
"saveInto",
"(",
"DataObjectInterface",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canCrop",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"hasSourceFile",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"object",
"->",
"setField",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'ID'",
",",
"$",
"this",
"->",
"generateCropped",
"(",
")",
"->",
"ID",
")",
";",
"$",
"object",
"->",
"write",
"(",
")",
";",
"}"
] |
If enabled, crop the image, save as a new file, and link it via relation
@return void
|
[
"If",
"enabled",
"crop",
"the",
"image",
"save",
"as",
"a",
"new",
"file",
"and",
"link",
"it",
"via",
"relation"
] |
855ca4f44dd392b1cf9d36f411a2c145b4b3d975
|
https://github.com/willmorgan/silverstripe-cropperfield/blob/855ca4f44dd392b1cf9d36f411a2c145b4b3d975/code/CropperField.php#L269-L275
|
233,880
|
willmorgan/silverstripe-cropperfield
|
code/CropperField.php
|
CropperField.requireFrontend
|
protected function requireFrontend() {
$extension = Director::isLive() ? '.min' : '';
$cssFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.css',
CROPPERFIELD_PATH . '/cropper/CropperField.css',
);
$jsFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.js',
CROPPERFIELD_PATH . '/cropper/CropperField.js',
);
Requirements::combine_files('cropperfield-all.css', $cssFiles);
Requirements::combine_files('cropperfield-all.js', $jsFiles);
}
|
php
|
protected function requireFrontend() {
$extension = Director::isLive() ? '.min' : '';
$cssFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.css',
CROPPERFIELD_PATH . '/cropper/CropperField.css',
);
$jsFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.js',
CROPPERFIELD_PATH . '/cropper/CropperField.js',
);
Requirements::combine_files('cropperfield-all.css', $cssFiles);
Requirements::combine_files('cropperfield-all.js', $jsFiles);
}
|
[
"protected",
"function",
"requireFrontend",
"(",
")",
"{",
"$",
"extension",
"=",
"Director",
"::",
"isLive",
"(",
")",
"?",
"'.min'",
":",
"''",
";",
"$",
"cssFiles",
"=",
"array",
"(",
"CROPPERFIELD_PATH",
".",
"'/cropper/cropper'",
".",
"$",
"extension",
".",
"'.css'",
",",
"CROPPERFIELD_PATH",
".",
"'/cropper/CropperField.css'",
",",
")",
";",
"$",
"jsFiles",
"=",
"array",
"(",
"CROPPERFIELD_PATH",
".",
"'/cropper/cropper'",
".",
"$",
"extension",
".",
"'.js'",
",",
"CROPPERFIELD_PATH",
".",
"'/cropper/CropperField.js'",
",",
")",
";",
"Requirements",
"::",
"combine_files",
"(",
"'cropperfield-all.css'",
",",
"$",
"cssFiles",
")",
";",
"Requirements",
"::",
"combine_files",
"(",
"'cropperfield-all.js'",
",",
"$",
"jsFiles",
")",
";",
"}"
] |
Pull in the cropper.js requirements. If in dev mode, bring in unminified.
@return void
|
[
"Pull",
"in",
"the",
"cropper",
".",
"js",
"requirements",
".",
"If",
"in",
"dev",
"mode",
"bring",
"in",
"unminified",
"."
] |
855ca4f44dd392b1cf9d36f411a2c145b4b3d975
|
https://github.com/willmorgan/silverstripe-cropperfield/blob/855ca4f44dd392b1cf9d36f411a2c145b4b3d975/code/CropperField.php#L391-L403
|
233,881
|
MW-Peachy/Peachy
|
Includes/XMLParse.php
|
XMLParse.load
|
public static function load( $data ) {
$http = HTTP::getDefaultInstance();
if( !function_exists( 'simplexml_load_string' ) ) {
throw new DependencyError( "SimpleXML", "http://us.php.net/manual/en/book.simplexml.php" );
}
libxml_use_internal_errors( true );
if( in_string( "<?xml", $data ) ) {
$xmlout = $data;
} else {
$xmlout = $http->get( $data );
}
Hooks::runHook( 'PreSimpleXMLLoad', array( &$xmlout ) );
$xml = simplexml_load_string( $xmlout );
Hooks::runHook( 'PostSimpleXMLLoad', array( &$xml ) );
if( !$xml ) {
foreach( libxml_get_errors() as $error ){
throw new XMLError( $error );
}
}
$outArr = array();
$namespaces = $xml->getNamespaces( true );
$namespaces['default'] = '';
self::recurse( $xml, $outArr, $namespaces );
libxml_clear_errors();
return $outArr;
}
|
php
|
public static function load( $data ) {
$http = HTTP::getDefaultInstance();
if( !function_exists( 'simplexml_load_string' ) ) {
throw new DependencyError( "SimpleXML", "http://us.php.net/manual/en/book.simplexml.php" );
}
libxml_use_internal_errors( true );
if( in_string( "<?xml", $data ) ) {
$xmlout = $data;
} else {
$xmlout = $http->get( $data );
}
Hooks::runHook( 'PreSimpleXMLLoad', array( &$xmlout ) );
$xml = simplexml_load_string( $xmlout );
Hooks::runHook( 'PostSimpleXMLLoad', array( &$xml ) );
if( !$xml ) {
foreach( libxml_get_errors() as $error ){
throw new XMLError( $error );
}
}
$outArr = array();
$namespaces = $xml->getNamespaces( true );
$namespaces['default'] = '';
self::recurse( $xml, $outArr, $namespaces );
libxml_clear_errors();
return $outArr;
}
|
[
"public",
"static",
"function",
"load",
"(",
"$",
"data",
")",
"{",
"$",
"http",
"=",
"HTTP",
"::",
"getDefaultInstance",
"(",
")",
";",
"if",
"(",
"!",
"function_exists",
"(",
"'simplexml_load_string'",
")",
")",
"{",
"throw",
"new",
"DependencyError",
"(",
"\"SimpleXML\"",
",",
"\"http://us.php.net/manual/en/book.simplexml.php\"",
")",
";",
"}",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"if",
"(",
"in_string",
"(",
"\"<?xml\"",
",",
"$",
"data",
")",
")",
"{",
"$",
"xmlout",
"=",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"xmlout",
"=",
"$",
"http",
"->",
"get",
"(",
"$",
"data",
")",
";",
"}",
"Hooks",
"::",
"runHook",
"(",
"'PreSimpleXMLLoad'",
",",
"array",
"(",
"&",
"$",
"xmlout",
")",
")",
";",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"xmlout",
")",
";",
"Hooks",
"::",
"runHook",
"(",
"'PostSimpleXMLLoad'",
",",
"array",
"(",
"&",
"$",
"xml",
")",
")",
";",
"if",
"(",
"!",
"$",
"xml",
")",
"{",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"throw",
"new",
"XMLError",
"(",
"$",
"error",
")",
";",
"}",
"}",
"$",
"outArr",
"=",
"array",
"(",
")",
";",
"$",
"namespaces",
"=",
"$",
"xml",
"->",
"getNamespaces",
"(",
"true",
")",
";",
"$",
"namespaces",
"[",
"'default'",
"]",
"=",
"''",
";",
"self",
"::",
"recurse",
"(",
"$",
"xml",
",",
"$",
"outArr",
",",
"$",
"namespaces",
")",
";",
"libxml_clear_errors",
"(",
")",
";",
"return",
"$",
"outArr",
";",
"}"
] |
Converts an XML url or string to a PHP array format
@static
@access public
@param string $data Either an url to an xml file, or a raw XML string. Peachy will autodetect which is which.
@return array Parsed XML
@throws BadEntryError
@throws DependencyError
@throws HookError
@throws XMLError
|
[
"Converts",
"an",
"XML",
"url",
"or",
"string",
"to",
"a",
"PHP",
"array",
"format"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/XMLParse.php#L34-L71
|
233,882
|
kaliop-uk/kueueingbundle
|
Service/MessageProducer.php
|
MessageProducer.doPublish
|
protected function doPublish($data, $routingKey = '', $extras = array())
{
$producer = $this->getProducerService();
$producer->setContentType($this->getContentType());
$producer->publish($this->encodeMessageBody($data), $routingKey, $extras);
}
|
php
|
protected function doPublish($data, $routingKey = '', $extras = array())
{
$producer = $this->getProducerService();
$producer->setContentType($this->getContentType());
$producer->publish($this->encodeMessageBody($data), $routingKey, $extras);
}
|
[
"protected",
"function",
"doPublish",
"(",
"$",
"data",
",",
"$",
"routingKey",
"=",
"''",
",",
"$",
"extras",
"=",
"array",
"(",
")",
")",
"{",
"$",
"producer",
"=",
"$",
"this",
"->",
"getProducerService",
"(",
")",
";",
"$",
"producer",
"->",
"setContentType",
"(",
"$",
"this",
"->",
"getContentType",
"(",
")",
")",
";",
"$",
"producer",
"->",
"publish",
"(",
"$",
"this",
"->",
"encodeMessageBody",
"(",
"$",
"data",
")",
",",
"$",
"routingKey",
",",
"$",
"extras",
")",
";",
"}"
] |
Some sugar for subclasses
NB: the "extras" parameter only works as long as our customized class is used instead of Kaliop\QueueingBundle\RabbitMq\Producer
(this happens naturally when this bundle is properly configured, as it is out of the box)
@param mixed $data
@param string $routingKey
@param array $extras
|
[
"Some",
"sugar",
"for",
"subclasses"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageProducer.php#L134-L139
|
233,883
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithStringPropertyMeta.php
|
ClassWithStringPropertyMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithStringProperty();
case 1:
return new ClassWithStringProperty(func_get_arg(0));
case 2:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithStringProperty();
case 1:
return new ClassWithStringProperty(func_get_arg(0));
case 2:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"ClassWithStringProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithStringProperty
@throws \InvalidArgumentException
@return ClassWithStringProperty
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithStringProperty"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithStringPropertyMeta.php#L66-L90
|
233,884
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.getOptions
|
public function getOptions()
{
// Create Options List:
$options = ArrayList::create();
// Iterate Source Items:
foreach ($this->getSourceEmpty() as $value => $title) {
$options->push($this->getFieldOption($value, $title));
}
// Handle Tags:
if ($this->usesTags()) {
// Obtain Source Values:
$values = $this->getSourceValues();
// Iterate Value Array:
foreach ($this->getValueArray() as $value) {
// Handle Tag Values:
if (!in_array($value, $values)) {
$options->push($this->getFieldOption($value, $value));
}
}
}
// Apply Extensions:
$this->extend('updateOptions', $options);
// Answer Options List:
return $options;
}
|
php
|
public function getOptions()
{
// Create Options List:
$options = ArrayList::create();
// Iterate Source Items:
foreach ($this->getSourceEmpty() as $value => $title) {
$options->push($this->getFieldOption($value, $title));
}
// Handle Tags:
if ($this->usesTags()) {
// Obtain Source Values:
$values = $this->getSourceValues();
// Iterate Value Array:
foreach ($this->getValueArray() as $value) {
// Handle Tag Values:
if (!in_array($value, $values)) {
$options->push($this->getFieldOption($value, $value));
}
}
}
// Apply Extensions:
$this->extend('updateOptions', $options);
// Answer Options List:
return $options;
}
|
[
"public",
"function",
"getOptions",
"(",
")",
"{",
"// Create Options List:",
"$",
"options",
"=",
"ArrayList",
"::",
"create",
"(",
")",
";",
"// Iterate Source Items:",
"foreach",
"(",
"$",
"this",
"->",
"getSourceEmpty",
"(",
")",
"as",
"$",
"value",
"=>",
"$",
"title",
")",
"{",
"$",
"options",
"->",
"push",
"(",
"$",
"this",
"->",
"getFieldOption",
"(",
"$",
"value",
",",
"$",
"title",
")",
")",
";",
"}",
"// Handle Tags:",
"if",
"(",
"$",
"this",
"->",
"usesTags",
"(",
")",
")",
"{",
"// Obtain Source Values:",
"$",
"values",
"=",
"$",
"this",
"->",
"getSourceValues",
"(",
")",
";",
"// Iterate Value Array:",
"foreach",
"(",
"$",
"this",
"->",
"getValueArray",
"(",
")",
"as",
"$",
"value",
")",
"{",
"// Handle Tag Values:",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"values",
")",
")",
"{",
"$",
"options",
"->",
"push",
"(",
"$",
"this",
"->",
"getFieldOption",
"(",
"$",
"value",
",",
"$",
"value",
")",
")",
";",
"}",
"}",
"}",
"// Apply Extensions:",
"$",
"this",
"->",
"extend",
"(",
"'updateOptions'",
",",
"$",
"options",
")",
";",
"// Answer Options List:",
"return",
"$",
"options",
";",
"}"
] |
Answers an array list containing the options for the field.
@return ArrayList
|
[
"Answers",
"an",
"array",
"list",
"containing",
"the",
"options",
"for",
"the",
"field",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L121-L162
|
233,885
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.getAttributes
|
public function getAttributes()
{
$attributes = array_merge(
parent::getAttributes(),
$this->getDataAttributes()
);
if ($this->isMultiple()) {
$attributes['multiple'] = true;
$attributes['name'] = $this->getMultipleName();
}
if (!isset($attributes['data-placeholder'])) {
$attributes['data-placeholder'] = $this->getEmptyString();
}
return $attributes;
}
|
php
|
public function getAttributes()
{
$attributes = array_merge(
parent::getAttributes(),
$this->getDataAttributes()
);
if ($this->isMultiple()) {
$attributes['multiple'] = true;
$attributes['name'] = $this->getMultipleName();
}
if (!isset($attributes['data-placeholder'])) {
$attributes['data-placeholder'] = $this->getEmptyString();
}
return $attributes;
}
|
[
"public",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"array_merge",
"(",
"parent",
"::",
"getAttributes",
"(",
")",
",",
"$",
"this",
"->",
"getDataAttributes",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isMultiple",
"(",
")",
")",
"{",
"$",
"attributes",
"[",
"'multiple'",
"]",
"=",
"true",
";",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"getMultipleName",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'data-placeholder'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'data-placeholder'",
"]",
"=",
"$",
"this",
"->",
"getEmptyString",
"(",
")",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Answers an array of HTML attributes for the field.
@return array
|
[
"Answers",
"an",
"array",
"of",
"HTML",
"attributes",
"for",
"the",
"field",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L260-L277
|
233,886
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.setValue
|
public function setValue($value, $data = null)
{
if ($data instanceof DataObject) {
$this->loadFrom($data);
return $this;
}
return parent::setValue($value);
}
|
php
|
public function setValue($value, $data = null)
{
if ($data instanceof DataObject) {
$this->loadFrom($data);
return $this;
}
return parent::setValue($value);
}
|
[
"public",
"function",
"setValue",
"(",
"$",
"value",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"DataObject",
")",
"{",
"$",
"this",
"->",
"loadFrom",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
";",
"}",
"return",
"parent",
"::",
"setValue",
"(",
"$",
"value",
")",
";",
"}"
] |
Defines the value of the field.
@param mixed $value
@param array|DataObject $data
@return $this
|
[
"Defines",
"the",
"value",
"of",
"the",
"field",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L303-L311
|
233,887
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.isSelectedValue
|
public function isSelectedValue($dataValue, $userValue)
{
if (!$this->isMultiple() || !is_array($userValue)) {
return parent::isSelectedValue($dataValue, $userValue);
}
return in_array($dataValue, $userValue);
}
|
php
|
public function isSelectedValue($dataValue, $userValue)
{
if (!$this->isMultiple() || !is_array($userValue)) {
return parent::isSelectedValue($dataValue, $userValue);
}
return in_array($dataValue, $userValue);
}
|
[
"public",
"function",
"isSelectedValue",
"(",
"$",
"dataValue",
",",
"$",
"userValue",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isMultiple",
"(",
")",
"||",
"!",
"is_array",
"(",
"$",
"userValue",
")",
")",
"{",
"return",
"parent",
"::",
"isSelectedValue",
"(",
"$",
"dataValue",
",",
"$",
"userValue",
")",
";",
"}",
"return",
"in_array",
"(",
"$",
"dataValue",
",",
"$",
"userValue",
")",
";",
"}"
] |
Answers true if the current value of this field matches the given option value.
@param mixed $dataValue
@param mixed $userValue
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"current",
"value",
"of",
"this",
"field",
"matches",
"the",
"given",
"option",
"value",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L321-L328
|
233,888
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.loadFrom
|
public function loadFrom(DataObjectInterface $record)
{
// Obtain Field Name:
$fieldName = $this->getName();
// Bail Early (if needed):
if (empty($fieldName) || empty($record)) {
return;
}
// Determine Value Mode:
if (!$this->isMultiple()) {
// Load Singular Value:
parent::setValue($record->$fieldName);
} else {
// Load Multiple Value:
$relation = $this->getNamedRelation($record);
if ($relation instanceof Relation) {
$this->loadFromRelation($relation);
} elseif ($record->hasField($fieldName)) {
parent::setValue($this->stringDecode($record->$fieldName));
}
}
}
|
php
|
public function loadFrom(DataObjectInterface $record)
{
// Obtain Field Name:
$fieldName = $this->getName();
// Bail Early (if needed):
if (empty($fieldName) || empty($record)) {
return;
}
// Determine Value Mode:
if (!$this->isMultiple()) {
// Load Singular Value:
parent::setValue($record->$fieldName);
} else {
// Load Multiple Value:
$relation = $this->getNamedRelation($record);
if ($relation instanceof Relation) {
$this->loadFromRelation($relation);
} elseif ($record->hasField($fieldName)) {
parent::setValue($this->stringDecode($record->$fieldName));
}
}
}
|
[
"public",
"function",
"loadFrom",
"(",
"DataObjectInterface",
"$",
"record",
")",
"{",
"// Obtain Field Name:",
"$",
"fieldName",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"// Bail Early (if needed):",
"if",
"(",
"empty",
"(",
"$",
"fieldName",
")",
"||",
"empty",
"(",
"$",
"record",
")",
")",
"{",
"return",
";",
"}",
"// Determine Value Mode:",
"if",
"(",
"!",
"$",
"this",
"->",
"isMultiple",
"(",
")",
")",
"{",
"// Load Singular Value:",
"parent",
"::",
"setValue",
"(",
"$",
"record",
"->",
"$",
"fieldName",
")",
";",
"}",
"else",
"{",
"// Load Multiple Value:",
"$",
"relation",
"=",
"$",
"this",
"->",
"getNamedRelation",
"(",
"$",
"record",
")",
";",
"if",
"(",
"$",
"relation",
"instanceof",
"Relation",
")",
"{",
"$",
"this",
"->",
"loadFromRelation",
"(",
"$",
"relation",
")",
";",
"}",
"elseif",
"(",
"$",
"record",
"->",
"hasField",
"(",
"$",
"fieldName",
")",
")",
"{",
"parent",
"::",
"setValue",
"(",
"$",
"this",
"->",
"stringDecode",
"(",
"$",
"record",
"->",
"$",
"fieldName",
")",
")",
";",
"}",
"}",
"}"
] |
Loads the value of the field from the given data object.
@param DataObjectInterface $record
@return void
|
[
"Loads",
"the",
"value",
"of",
"the",
"field",
"from",
"the",
"given",
"data",
"object",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L347-L380
|
233,889
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.validate
|
public function validate($validator)
{
// Baily Early (if tags are used):
if ($this->usesTags()) {
return true;
}
// Call Parent Method (if not multiple):
if (!$this->isMultiple()) {
return parent::validate($validator);
}
// Obtain User Values:
$values = $this->getValueArray();
// Detect Invalid Values:
$invalid = array_filter(
$values,
function ($userValue) {
foreach ($this->getValidValues() as $formValue) {
if ($this->isSelectedValue($formValue, $userValue)) {
return false;
}
}
return true;
}
);
// Answer Success (if none invalid):
if (empty($invalid)) {
return true;
}
// Define Validation Error:
$validator->validationError(
$this->getName(),
_t(
__CLASS__ . '.INVALIDOPTIONS',
'Please select values within the list provided. Invalid option(s) {values} given.',
[
'values' => implode(', ', $invalid)
]
),
'validation'
);
// Answer Failure (invalid values detected):
return false;
}
|
php
|
public function validate($validator)
{
// Baily Early (if tags are used):
if ($this->usesTags()) {
return true;
}
// Call Parent Method (if not multiple):
if (!$this->isMultiple()) {
return parent::validate($validator);
}
// Obtain User Values:
$values = $this->getValueArray();
// Detect Invalid Values:
$invalid = array_filter(
$values,
function ($userValue) {
foreach ($this->getValidValues() as $formValue) {
if ($this->isSelectedValue($formValue, $userValue)) {
return false;
}
}
return true;
}
);
// Answer Success (if none invalid):
if (empty($invalid)) {
return true;
}
// Define Validation Error:
$validator->validationError(
$this->getName(),
_t(
__CLASS__ . '.INVALIDOPTIONS',
'Please select values within the list provided. Invalid option(s) {values} given.',
[
'values' => implode(', ', $invalid)
]
),
'validation'
);
// Answer Failure (invalid values detected):
return false;
}
|
[
"public",
"function",
"validate",
"(",
"$",
"validator",
")",
"{",
"// Baily Early (if tags are used):",
"if",
"(",
"$",
"this",
"->",
"usesTags",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Call Parent Method (if not multiple):",
"if",
"(",
"!",
"$",
"this",
"->",
"isMultiple",
"(",
")",
")",
"{",
"return",
"parent",
"::",
"validate",
"(",
"$",
"validator",
")",
";",
"}",
"// Obtain User Values:",
"$",
"values",
"=",
"$",
"this",
"->",
"getValueArray",
"(",
")",
";",
"// Detect Invalid Values:",
"$",
"invalid",
"=",
"array_filter",
"(",
"$",
"values",
",",
"function",
"(",
"$",
"userValue",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getValidValues",
"(",
")",
"as",
"$",
"formValue",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSelectedValue",
"(",
"$",
"formValue",
",",
"$",
"userValue",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
")",
";",
"// Answer Success (if none invalid):",
"if",
"(",
"empty",
"(",
"$",
"invalid",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Define Validation Error:",
"$",
"validator",
"->",
"validationError",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"_t",
"(",
"__CLASS__",
".",
"'.INVALIDOPTIONS'",
",",
"'Please select values within the list provided. Invalid option(s) {values} given.'",
",",
"[",
"'values'",
"=>",
"implode",
"(",
"', '",
",",
"$",
"invalid",
")",
"]",
")",
",",
"'validation'",
")",
";",
"// Answer Failure (invalid values detected):",
"return",
"false",
";",
"}"
] |
Performs validation on the receiver.
@param Validator $validator
@return boolean
|
[
"Performs",
"validation",
"on",
"the",
"receiver",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L455-L510
|
233,890
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.getDataValue
|
protected function getDataValue($value)
{
if (is_bool($value)) {
return $value ? 'true' : 'false';
} elseif (is_array($value)) {
return Convert::array2json($value);
} else {
return Convert::raw2att($value);
}
}
|
php
|
protected function getDataValue($value)
{
if (is_bool($value)) {
return $value ? 'true' : 'false';
} elseif (is_array($value)) {
return Convert::array2json($value);
} else {
return Convert::raw2att($value);
}
}
|
[
"protected",
"function",
"getDataValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
"?",
"'true'",
":",
"'false'",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"Convert",
"::",
"array2json",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"Convert",
"::",
"raw2att",
"(",
"$",
"value",
")",
";",
"}",
"}"
] |
Converts the given data value to a string suitable for a data attribute.
@param mixed $value
@return string
|
[
"Converts",
"the",
"given",
"data",
"value",
"to",
"a",
"string",
"suitable",
"for",
"a",
"data",
"attribute",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L543-L552
|
233,891
|
praxisnetau/silverware-select2
|
src/Forms/Select2Field.php
|
Select2Field.getNamedRelation
|
protected function getNamedRelation(DataObjectInterface $record)
{
return $record->hasMethod($this->Name) ? $record->{$this->Name}() : null;
}
|
php
|
protected function getNamedRelation(DataObjectInterface $record)
{
return $record->hasMethod($this->Name) ? $record->{$this->Name}() : null;
}
|
[
"protected",
"function",
"getNamedRelation",
"(",
"DataObjectInterface",
"$",
"record",
")",
"{",
"return",
"$",
"record",
"->",
"hasMethod",
"(",
"$",
"this",
"->",
"Name",
")",
"?",
"$",
"record",
"->",
"{",
"$",
"this",
"->",
"Name",
"}",
"(",
")",
":",
"null",
";",
"}"
] |
Answers the relation with the field name from the given data object.
@param DataObjectInterface $record
@return Relation
|
[
"Answers",
"the",
"relation",
"with",
"the",
"field",
"name",
"from",
"the",
"given",
"data",
"object",
"."
] |
81f3efe7f40eb87e1390f038c3c9eed415be7bc3
|
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L577-L580
|
233,892
|
budde377/Part
|
lib/util/traits/EncryptionTrait.php
|
EncryptionTrait.encrypt
|
protected function encrypt($string, $key){
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
}
|
php
|
protected function encrypt($string, $key){
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
}
|
[
"protected",
"function",
"encrypt",
"(",
"$",
"string",
",",
"$",
"key",
")",
"{",
"return",
"base64_encode",
"(",
"mcrypt_encrypt",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"md5",
"(",
"$",
"key",
")",
",",
"$",
"string",
",",
"MCRYPT_MODE_CBC",
",",
"md5",
"(",
"md5",
"(",
"$",
"key",
")",
")",
")",
")",
";",
"}"
] |
Will encrypt string and return encrypted string.
The encryption will be an two-way function, so not as secure as could be,
but secure enough to hide passwords in database, and is highly encouraged to be used to that.
@param string $string
@param string $key
@return string
|
[
"Will",
"encrypt",
"string",
"and",
"return",
"encrypted",
"string",
".",
"The",
"encryption",
"will",
"be",
"an",
"two",
"-",
"way",
"function",
"so",
"not",
"as",
"secure",
"as",
"could",
"be",
"but",
"secure",
"enough",
"to",
"hide",
"passwords",
"in",
"database",
"and",
"is",
"highly",
"encouraged",
"to",
"be",
"used",
"to",
"that",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/traits/EncryptionTrait.php#L20-L22
|
233,893
|
kaliop-uk/kueueingbundle
|
Adapter/DriverManager.php
|
DriverManager.getDrivers
|
public function getDrivers()
{
$drivers = array();
foreach($this->aliases as $alias => $service) {
$drivers[$alias] = $this->container->get($service);
}
return $drivers;
}
|
php
|
public function getDrivers()
{
$drivers = array();
foreach($this->aliases as $alias => $service) {
$drivers[$alias] = $this->container->get($service);
}
return $drivers;
}
|
[
"public",
"function",
"getDrivers",
"(",
")",
"{",
"$",
"drivers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"aliases",
"as",
"$",
"alias",
"=>",
"$",
"service",
")",
"{",
"$",
"drivers",
"[",
"$",
"alias",
"]",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"service",
")",
";",
"}",
"return",
"$",
"drivers",
";",
"}"
] |
returns all drivers
@return array key is alias, value is the service
|
[
"returns",
"all",
"drivers"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/DriverManager.php#L84-L91
|
233,894
|
amphp/http-server-session
|
src/Session.php
|
Session.regenerate
|
public function regenerate(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if ($this->id === null || !$this->isLocked()) {
throw new \Error('Cannot save an unlocked session');
}
$newId = yield $this->storage->create();
yield $this->storage->save($newId, $this->data);
yield $this->storage->save($this->id, []);
$this->id = $newId;
$this->status = self::STATUS_READ | self::STATUS_LOCKED;
return $this->id;
});
}
|
php
|
public function regenerate(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if ($this->id === null || !$this->isLocked()) {
throw new \Error('Cannot save an unlocked session');
}
$newId = yield $this->storage->create();
yield $this->storage->save($newId, $this->data);
yield $this->storage->save($this->id, []);
$this->id = $newId;
$this->status = self::STATUS_READ | self::STATUS_LOCKED;
return $this->id;
});
}
|
[
"public",
"function",
"regenerate",
"(",
")",
":",
"Promise",
"{",
"return",
"$",
"this",
"->",
"pending",
"=",
"call",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pending",
")",
"{",
"yield",
"$",
"this",
"->",
"pending",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"id",
"===",
"null",
"||",
"!",
"$",
"this",
"->",
"isLocked",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Error",
"(",
"'Cannot save an unlocked session'",
")",
";",
"}",
"$",
"newId",
"=",
"yield",
"$",
"this",
"->",
"storage",
"->",
"create",
"(",
")",
";",
"yield",
"$",
"this",
"->",
"storage",
"->",
"save",
"(",
"$",
"newId",
",",
"$",
"this",
"->",
"data",
")",
";",
"yield",
"$",
"this",
"->",
"storage",
"->",
"save",
"(",
"$",
"this",
"->",
"id",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"id",
"=",
"$",
"newId",
";",
"$",
"this",
"->",
"status",
"=",
"self",
"::",
"STATUS_READ",
"|",
"self",
"::",
"STATUS_LOCKED",
";",
"return",
"$",
"this",
"->",
"id",
";",
"}",
")",
";",
"}"
] |
Regenerates a session identifier and locks the session.
@return Promise Resolving with the new session identifier.
|
[
"Regenerates",
"a",
"session",
"identifier",
"and",
"locks",
"the",
"session",
"."
] |
c9117a378637d170d4dc4333b9a1e646fbbd03e7
|
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L84-L105
|
233,895
|
amphp/http-server-session
|
src/Session.php
|
Session.open
|
public function open(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if ($this->id === null) {
$this->id = yield $this->storage->create();
} else {
$this->data = yield $this->storage->lock($this->id);
}
++$this->openCount;
$this->status = self::STATUS_READ | self::STATUS_LOCKED;
return $this;
});
}
|
php
|
public function open(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if ($this->id === null) {
$this->id = yield $this->storage->create();
} else {
$this->data = yield $this->storage->lock($this->id);
}
++$this->openCount;
$this->status = self::STATUS_READ | self::STATUS_LOCKED;
return $this;
});
}
|
[
"public",
"function",
"open",
"(",
")",
":",
"Promise",
"{",
"return",
"$",
"this",
"->",
"pending",
"=",
"call",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pending",
")",
"{",
"yield",
"$",
"this",
"->",
"pending",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"id",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"yield",
"$",
"this",
"->",
"storage",
"->",
"create",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"=",
"yield",
"$",
"this",
"->",
"storage",
"->",
"lock",
"(",
"$",
"this",
"->",
"id",
")",
";",
"}",
"++",
"$",
"this",
"->",
"openCount",
";",
"$",
"this",
"->",
"status",
"=",
"self",
"::",
"STATUS_READ",
"|",
"self",
"::",
"STATUS_LOCKED",
";",
"return",
"$",
"this",
";",
"}",
")",
";",
"}"
] |
Opens the session for writing.
@return Promise Resolved with the session.
|
[
"Opens",
"the",
"session",
"for",
"writing",
"."
] |
c9117a378637d170d4dc4333b9a1e646fbbd03e7
|
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L134-L153
|
233,896
|
amphp/http-server-session
|
src/Session.php
|
Session.save
|
public function save(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if (!$this->isLocked()) {
throw new \Error('Cannot save an unlocked session');
}
if ($this->data === []) {
yield $this->storage->save($this->id, []);
} else {
yield $this->storage->save($this->id, $this->data);
}
if ($this->openCount === 1) {
yield $this->storage->unlock($this->id);
$this->status &= ~self::STATUS_LOCKED;
if ($this->data === []) {
$this->id = null;
}
}
--$this->openCount;
});
}
|
php
|
public function save(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if (!$this->isLocked()) {
throw new \Error('Cannot save an unlocked session');
}
if ($this->data === []) {
yield $this->storage->save($this->id, []);
} else {
yield $this->storage->save($this->id, $this->data);
}
if ($this->openCount === 1) {
yield $this->storage->unlock($this->id);
$this->status &= ~self::STATUS_LOCKED;
if ($this->data === []) {
$this->id = null;
}
}
--$this->openCount;
});
}
|
[
"public",
"function",
"save",
"(",
")",
":",
"Promise",
"{",
"return",
"$",
"this",
"->",
"pending",
"=",
"call",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pending",
")",
"{",
"yield",
"$",
"this",
"->",
"pending",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isLocked",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Error",
"(",
"'Cannot save an unlocked session'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"data",
"===",
"[",
"]",
")",
"{",
"yield",
"$",
"this",
"->",
"storage",
"->",
"save",
"(",
"$",
"this",
"->",
"id",
",",
"[",
"]",
")",
";",
"}",
"else",
"{",
"yield",
"$",
"this",
"->",
"storage",
"->",
"save",
"(",
"$",
"this",
"->",
"id",
",",
"$",
"this",
"->",
"data",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"openCount",
"===",
"1",
")",
"{",
"yield",
"$",
"this",
"->",
"storage",
"->",
"unlock",
"(",
"$",
"this",
"->",
"id",
")",
";",
"$",
"this",
"->",
"status",
"&=",
"~",
"self",
"::",
"STATUS_LOCKED",
";",
"if",
"(",
"$",
"this",
"->",
"data",
"===",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"null",
";",
"}",
"}",
"--",
"$",
"this",
"->",
"openCount",
";",
"}",
")",
";",
"}"
] |
Saves the given data in the session.
The session must be locked with either open() before calling this method.
@return Promise
|
[
"Saves",
"the",
"given",
"data",
"in",
"the",
"session",
"."
] |
c9117a378637d170d4dc4333b9a1e646fbbd03e7
|
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L162-L190
|
233,897
|
amphp/http-server-session
|
src/Session.php
|
Session.unlock
|
public function unlock(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if (!$this->isLocked()) {
return;
}
if ($this->openCount === 1) {
yield $this->storage->unlock($this->id);
$this->status &= ~self::STATUS_LOCKED;
}
--$this->openCount;
});
}
|
php
|
public function unlock(): Promise
{
return $this->pending = call(function () {
if ($this->pending) {
yield $this->pending;
}
if (!$this->isLocked()) {
return;
}
if ($this->openCount === 1) {
yield $this->storage->unlock($this->id);
$this->status &= ~self::STATUS_LOCKED;
}
--$this->openCount;
});
}
|
[
"public",
"function",
"unlock",
"(",
")",
":",
"Promise",
"{",
"return",
"$",
"this",
"->",
"pending",
"=",
"call",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pending",
")",
"{",
"yield",
"$",
"this",
"->",
"pending",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isLocked",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"openCount",
"===",
"1",
")",
"{",
"yield",
"$",
"this",
"->",
"storage",
"->",
"unlock",
"(",
"$",
"this",
"->",
"id",
")",
";",
"$",
"this",
"->",
"status",
"&=",
"~",
"self",
"::",
"STATUS_LOCKED",
";",
"}",
"--",
"$",
"this",
"->",
"openCount",
";",
"}",
")",
";",
"}"
] |
Unlocks the session.
@return Promise
|
[
"Unlocks",
"the",
"session",
"."
] |
c9117a378637d170d4dc4333b9a1e646fbbd03e7
|
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L213-L231
|
233,898
|
baleen/migrations
|
src/Delta/Comparator/NamespacesAwareComparator.php
|
NamespacesAwareComparator.compareNamespaces
|
private function compareNamespaces($class1, $class2)
{
$res = null;
// loop from highest namespace priority to lowest
foreach ($this->namespaces as $namespace) {
if (strpos($class1, $namespace) === 0) {
$res = 1;
}
if (strpos($class2, $namespace) === 0) {
// subtract 1 from $res, setting it to either -1 or 0
$res = (int) $res - 1;
}
if (null !== $res) {
break; // exit as soon as we found a sort order
}
}
return $res;
}
|
php
|
private function compareNamespaces($class1, $class2)
{
$res = null;
// loop from highest namespace priority to lowest
foreach ($this->namespaces as $namespace) {
if (strpos($class1, $namespace) === 0) {
$res = 1;
}
if (strpos($class2, $namespace) === 0) {
// subtract 1 from $res, setting it to either -1 or 0
$res = (int) $res - 1;
}
if (null !== $res) {
break; // exit as soon as we found a sort order
}
}
return $res;
}
|
[
"private",
"function",
"compareNamespaces",
"(",
"$",
"class1",
",",
"$",
"class2",
")",
"{",
"$",
"res",
"=",
"null",
";",
"// loop from highest namespace priority to lowest",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"class1",
",",
"$",
"namespace",
")",
"===",
"0",
")",
"{",
"$",
"res",
"=",
"1",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"class2",
",",
"$",
"namespace",
")",
"===",
"0",
")",
"{",
"// subtract 1 from $res, setting it to either -1 or 0",
"$",
"res",
"=",
"(",
"int",
")",
"$",
"res",
"-",
"1",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"res",
")",
"{",
"break",
";",
"// exit as soon as we found a sort order",
"}",
"}",
"return",
"$",
"res",
";",
"}"
] |
Compare using namespaces
@param $class1
@param $class2
@return int|null
|
[
"Compare",
"using",
"namespaces"
] |
cfc8c439858cf4f0d4119af9eb67de493da8d95c
|
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Comparator/NamespacesAwareComparator.php#L120-L137
|
233,899
|
meare/juggler
|
src/Imposter/Builder/AbstractImposterBuilder.php
|
AbstractImposterBuilder.build
|
public function build($json)
{
$contract = \GuzzleHttp\json_decode($json, true);
if (!isset($contract['protocol'])) {
throw new \InvalidArgumentException('Invalid contract; Protocol is not specified');
}
return $this->getBuilder($contract['protocol'])->build($contract);
}
|
php
|
public function build($json)
{
$contract = \GuzzleHttp\json_decode($json, true);
if (!isset($contract['protocol'])) {
throw new \InvalidArgumentException('Invalid contract; Protocol is not specified');
}
return $this->getBuilder($contract['protocol'])->build($contract);
}
|
[
"public",
"function",
"build",
"(",
"$",
"json",
")",
"{",
"$",
"contract",
"=",
"\\",
"GuzzleHttp",
"\\",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"contract",
"[",
"'protocol'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid contract; Protocol is not specified'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getBuilder",
"(",
"$",
"contract",
"[",
"'protocol'",
"]",
")",
"->",
"build",
"(",
"$",
"contract",
")",
";",
"}"
] |
Builds Imposter object from JSON contract using appropriate Builder
@param string $json
@return \Meare\Juggler\Imposter\Imposter
@throws \InvalidArgumentException if contract has no protocol or no appropriate Builder found
|
[
"Builds",
"Imposter",
"object",
"from",
"JSON",
"contract",
"using",
"appropriate",
"Builder"
] |
11ec398c16e01c986679f53f8ece2c1e97ba4e29
|
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Imposter/Builder/AbstractImposterBuilder.php#L23-L31
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.