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,700
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.patrol
|
public function patrol( $rcid = 0 ) {
Hooks::runHook( 'PrePatrol', array( &$rcid ) );
pecho( "Patrolling $rcid...\n\n", PECHO_NORMAL );
$this->get_tokens();
return $this->apiQuery(
array(
'action' => 'patrol',
'rcid' => $rcid,
'token' => $this->tokens['patrol']
)
);
}
|
php
|
public function patrol( $rcid = 0 ) {
Hooks::runHook( 'PrePatrol', array( &$rcid ) );
pecho( "Patrolling $rcid...\n\n", PECHO_NORMAL );
$this->get_tokens();
return $this->apiQuery(
array(
'action' => 'patrol',
'rcid' => $rcid,
'token' => $this->tokens['patrol']
)
);
}
|
[
"public",
"function",
"patrol",
"(",
"$",
"rcid",
"=",
"0",
")",
"{",
"Hooks",
"::",
"runHook",
"(",
"'PrePatrol'",
",",
"array",
"(",
"&",
"$",
"rcid",
")",
")",
";",
"pecho",
"(",
"\"Patrolling $rcid...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"$",
"this",
"->",
"get_tokens",
"(",
")",
";",
"return",
"$",
"this",
"->",
"apiQuery",
"(",
"array",
"(",
"'action'",
"=>",
"'patrol'",
",",
"'rcid'",
"=>",
"$",
"rcid",
",",
"'token'",
"=>",
"$",
"this",
"->",
"tokens",
"[",
"'patrol'",
"]",
")",
")",
";",
"}"
] |
Patrols a page or revision
@access public
@param int $rcid Recent changes ID to patrol
@return array
|
[
"Patrols",
"a",
"page",
"or",
"revision"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2143-L2157
|
233,701
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.import
|
public function import( $page = null, $summary = '', $site = null, $fullhistory = true, $templates = true, $namespace = null, $root = false ) {
$tokens = $this->get_tokens();
$apiArray = array(
'action' => 'import',
'summary' => $summary,
'token' => $tokens['import']
);
if( $root ) $apiArray['rootpage'] = '';
if( !is_null( $page ) ) {
if( !is_file( $page ) ) {
$apiArray['interwikipage'] = $page;
if( !is_null( $site ) ) {
$apiArray['interwikisource'] = $site;
} else {
pecho( "Error: You must specify a site to import from.\n\n", PECHO_FATAL );
return false;
}
if( !is_null( $namespace ) ) $apiArray['namespace'] = $namespace;
if( $fullhistory ) $apiArray['fullhistory'] = '';
if( $templates ) $apiArray['templates'] = '';
pecho( "Importing $page from $site...\n\n", PECHO_NOTICE );
} else {
$apiArray['xml'] = "@$page";
pecho( "Uploading XML...\n\n", PECHO_NOTICE );
}
} else {
pecho( "Error: You must specify an interwiki page or a local XML file to import.\n\n", PECHO_FATAL );
return false;
}
$result = $this->apiQuery( $apiArray, true );
if( isset( $result['import'] ) ) {
if( isset( $result['import']['page'] ) ) {
return true;
} else {
pecho( "Import error...\n\n" . print_r( $result['import'], true ) . "\n\n", PECHO_FATAL );
return false;
}
} else {
pecho( "Import error...\n\n" . print_r( $result, true ), PECHO_FATAL );
return false;
}
}
|
php
|
public function import( $page = null, $summary = '', $site = null, $fullhistory = true, $templates = true, $namespace = null, $root = false ) {
$tokens = $this->get_tokens();
$apiArray = array(
'action' => 'import',
'summary' => $summary,
'token' => $tokens['import']
);
if( $root ) $apiArray['rootpage'] = '';
if( !is_null( $page ) ) {
if( !is_file( $page ) ) {
$apiArray['interwikipage'] = $page;
if( !is_null( $site ) ) {
$apiArray['interwikisource'] = $site;
} else {
pecho( "Error: You must specify a site to import from.\n\n", PECHO_FATAL );
return false;
}
if( !is_null( $namespace ) ) $apiArray['namespace'] = $namespace;
if( $fullhistory ) $apiArray['fullhistory'] = '';
if( $templates ) $apiArray['templates'] = '';
pecho( "Importing $page from $site...\n\n", PECHO_NOTICE );
} else {
$apiArray['xml'] = "@$page";
pecho( "Uploading XML...\n\n", PECHO_NOTICE );
}
} else {
pecho( "Error: You must specify an interwiki page or a local XML file to import.\n\n", PECHO_FATAL );
return false;
}
$result = $this->apiQuery( $apiArray, true );
if( isset( $result['import'] ) ) {
if( isset( $result['import']['page'] ) ) {
return true;
} else {
pecho( "Import error...\n\n" . print_r( $result['import'], true ) . "\n\n", PECHO_FATAL );
return false;
}
} else {
pecho( "Import error...\n\n" . print_r( $result, true ), PECHO_FATAL );
return false;
}
}
|
[
"public",
"function",
"import",
"(",
"$",
"page",
"=",
"null",
",",
"$",
"summary",
"=",
"''",
",",
"$",
"site",
"=",
"null",
",",
"$",
"fullhistory",
"=",
"true",
",",
"$",
"templates",
"=",
"true",
",",
"$",
"namespace",
"=",
"null",
",",
"$",
"root",
"=",
"false",
")",
"{",
"$",
"tokens",
"=",
"$",
"this",
"->",
"get_tokens",
"(",
")",
";",
"$",
"apiArray",
"=",
"array",
"(",
"'action'",
"=>",
"'import'",
",",
"'summary'",
"=>",
"$",
"summary",
",",
"'token'",
"=>",
"$",
"tokens",
"[",
"'import'",
"]",
")",
";",
"if",
"(",
"$",
"root",
")",
"$",
"apiArray",
"[",
"'rootpage'",
"]",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"page",
")",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"page",
")",
")",
"{",
"$",
"apiArray",
"[",
"'interwikipage'",
"]",
"=",
"$",
"page",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"site",
")",
")",
"{",
"$",
"apiArray",
"[",
"'interwikisource'",
"]",
"=",
"$",
"site",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Error: You must specify a site to import from.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"namespace",
")",
")",
"$",
"apiArray",
"[",
"'namespace'",
"]",
"=",
"$",
"namespace",
";",
"if",
"(",
"$",
"fullhistory",
")",
"$",
"apiArray",
"[",
"'fullhistory'",
"]",
"=",
"''",
";",
"if",
"(",
"$",
"templates",
")",
"$",
"apiArray",
"[",
"'templates'",
"]",
"=",
"''",
";",
"pecho",
"(",
"\"Importing $page from $site...\\n\\n\"",
",",
"PECHO_NOTICE",
")",
";",
"}",
"else",
"{",
"$",
"apiArray",
"[",
"'xml'",
"]",
"=",
"\"@$page\"",
";",
"pecho",
"(",
"\"Uploading XML...\\n\\n\"",
",",
"PECHO_NOTICE",
")",
";",
"}",
"}",
"else",
"{",
"pecho",
"(",
"\"Error: You must specify an interwiki page or a local XML file to import.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"$",
"apiArray",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'import'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'import'",
"]",
"[",
"'page'",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Import error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
"[",
"'import'",
"]",
",",
"true",
")",
".",
"\"\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"pecho",
"(",
"\"Import error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
",",
"true",
")",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Import a page from another wiki, or an XML file.
@access public
@param mixed|string $page local XML file or page to another wiki.
@param string $summary Import summary. Default ''.
@param string $site For interwiki imports: wiki to import from. Default null.
@param bool $fullhistory For interwiki imports: import the full history, not just the current version. Default true.
@param bool $templates For interwiki imports: import all included templates as well. Default true.
@param int $namespace For interwiki imports: import to this namespace
@param bool $root Import as subpage of this page. Default false.
@return bool
|
[
"Import",
"a",
"page",
"from",
"another",
"wiki",
"or",
"an",
"XML",
"file",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2172-L2220
|
233,702
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.diff
|
public function diff( $method = 'unified', $rev1, $rev2, $rev3 = null ) {
$r1array = array(
'action' => 'query',
'prop' => 'revisions',
'revids' => $rev1,
'rvprop' => 'content'
);
$r2array = array(
'action' => 'query',
'prop' => 'revisions',
'revids' => $rev2,
'rvprop' => 'content'
);
$r3array = array(
'action' => 'query',
'prop' => 'revisions',
'revids' => $rev3,
'rvprop' => 'content'
);
Hooks::runHook( 'PreDiff', array( &$r1array, &$r2array, &$r3array, &$method ) );
$r1text = $r2text = $r3text = null;
if( !is_null( $rev3 ) ) {
pecho( "Getting $method diff of revisions $rev1, $rev2, and $rev3...\n\n", PECHO_NORMAL );
$r3 = $this->apiQuery( $r3array );
if( isset( $r3['query']['badrevids'] ) ) {
pecho( "A bad third revision ID was passed.\n\n", PECHO_FATAL );
return false;
}
foreach( $r3['query']['pages'] as $r3pages ){
$r3text = $r3pages['revisions'][0]['*'];
}
} else {
pecho( "Getting $method diff of revisions $rev1 and $rev2...\n\n", PECHO_NORMAL );
}
$r1 = $this->apiQuery( $r1array );
$r2 = $this->apiQuery( $r2array );
if( isset( $r1['query']['badrevids'] ) ) {
pecho( "A bad first revision ID was passed.\n\n", PECHO_FATAL );
return false;
} elseif( isset( $r2['query']['badrevids'] ) ) {
pecho( "A bad second revision ID was passed.\n\n", PECHO_FATAL );
return false;
} else {
foreach( $r1['query']['pages'] as $r1pages ){
$r1text = $r1pages['revisions'][0]['*'];
}
foreach( $r2['query']['pages'] as $r2pages ){
$r2text = $r2pages['revisions'][0]['*'];
}
if( $method == "raw" ) return array( $r1text, $r2text, $r3text );
return Diff::load( $method, $r1text, $r2text, $r3text );
}
}
|
php
|
public function diff( $method = 'unified', $rev1, $rev2, $rev3 = null ) {
$r1array = array(
'action' => 'query',
'prop' => 'revisions',
'revids' => $rev1,
'rvprop' => 'content'
);
$r2array = array(
'action' => 'query',
'prop' => 'revisions',
'revids' => $rev2,
'rvprop' => 'content'
);
$r3array = array(
'action' => 'query',
'prop' => 'revisions',
'revids' => $rev3,
'rvprop' => 'content'
);
Hooks::runHook( 'PreDiff', array( &$r1array, &$r2array, &$r3array, &$method ) );
$r1text = $r2text = $r3text = null;
if( !is_null( $rev3 ) ) {
pecho( "Getting $method diff of revisions $rev1, $rev2, and $rev3...\n\n", PECHO_NORMAL );
$r3 = $this->apiQuery( $r3array );
if( isset( $r3['query']['badrevids'] ) ) {
pecho( "A bad third revision ID was passed.\n\n", PECHO_FATAL );
return false;
}
foreach( $r3['query']['pages'] as $r3pages ){
$r3text = $r3pages['revisions'][0]['*'];
}
} else {
pecho( "Getting $method diff of revisions $rev1 and $rev2...\n\n", PECHO_NORMAL );
}
$r1 = $this->apiQuery( $r1array );
$r2 = $this->apiQuery( $r2array );
if( isset( $r1['query']['badrevids'] ) ) {
pecho( "A bad first revision ID was passed.\n\n", PECHO_FATAL );
return false;
} elseif( isset( $r2['query']['badrevids'] ) ) {
pecho( "A bad second revision ID was passed.\n\n", PECHO_FATAL );
return false;
} else {
foreach( $r1['query']['pages'] as $r1pages ){
$r1text = $r1pages['revisions'][0]['*'];
}
foreach( $r2['query']['pages'] as $r2pages ){
$r2text = $r2pages['revisions'][0]['*'];
}
if( $method == "raw" ) return array( $r1text, $r2text, $r3text );
return Diff::load( $method, $r1text, $r2text, $r3text );
}
}
|
[
"public",
"function",
"diff",
"(",
"$",
"method",
"=",
"'unified'",
",",
"$",
"rev1",
",",
"$",
"rev2",
",",
"$",
"rev3",
"=",
"null",
")",
"{",
"$",
"r1array",
"=",
"array",
"(",
"'action'",
"=>",
"'query'",
",",
"'prop'",
"=>",
"'revisions'",
",",
"'revids'",
"=>",
"$",
"rev1",
",",
"'rvprop'",
"=>",
"'content'",
")",
";",
"$",
"r2array",
"=",
"array",
"(",
"'action'",
"=>",
"'query'",
",",
"'prop'",
"=>",
"'revisions'",
",",
"'revids'",
"=>",
"$",
"rev2",
",",
"'rvprop'",
"=>",
"'content'",
")",
";",
"$",
"r3array",
"=",
"array",
"(",
"'action'",
"=>",
"'query'",
",",
"'prop'",
"=>",
"'revisions'",
",",
"'revids'",
"=>",
"$",
"rev3",
",",
"'rvprop'",
"=>",
"'content'",
")",
";",
"Hooks",
"::",
"runHook",
"(",
"'PreDiff'",
",",
"array",
"(",
"&",
"$",
"r1array",
",",
"&",
"$",
"r2array",
",",
"&",
"$",
"r3array",
",",
"&",
"$",
"method",
")",
")",
";",
"$",
"r1text",
"=",
"$",
"r2text",
"=",
"$",
"r3text",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"rev3",
")",
")",
"{",
"pecho",
"(",
"\"Getting $method diff of revisions $rev1, $rev2, and $rev3...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"$",
"r3",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"$",
"r3array",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"r3",
"[",
"'query'",
"]",
"[",
"'badrevids'",
"]",
")",
")",
"{",
"pecho",
"(",
"\"A bad third revision ID was passed.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"r3",
"[",
"'query'",
"]",
"[",
"'pages'",
"]",
"as",
"$",
"r3pages",
")",
"{",
"$",
"r3text",
"=",
"$",
"r3pages",
"[",
"'revisions'",
"]",
"[",
"0",
"]",
"[",
"'*'",
"]",
";",
"}",
"}",
"else",
"{",
"pecho",
"(",
"\"Getting $method diff of revisions $rev1 and $rev2...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"}",
"$",
"r1",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"$",
"r1array",
")",
";",
"$",
"r2",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"$",
"r2array",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"r1",
"[",
"'query'",
"]",
"[",
"'badrevids'",
"]",
")",
")",
"{",
"pecho",
"(",
"\"A bad first revision ID was passed.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"r2",
"[",
"'query'",
"]",
"[",
"'badrevids'",
"]",
")",
")",
"{",
"pecho",
"(",
"\"A bad second revision ID was passed.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"r1",
"[",
"'query'",
"]",
"[",
"'pages'",
"]",
"as",
"$",
"r1pages",
")",
"{",
"$",
"r1text",
"=",
"$",
"r1pages",
"[",
"'revisions'",
"]",
"[",
"0",
"]",
"[",
"'*'",
"]",
";",
"}",
"foreach",
"(",
"$",
"r2",
"[",
"'query'",
"]",
"[",
"'pages'",
"]",
"as",
"$",
"r2pages",
")",
"{",
"$",
"r2text",
"=",
"$",
"r2pages",
"[",
"'revisions'",
"]",
"[",
"0",
"]",
"[",
"'*'",
"]",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"\"raw\"",
")",
"return",
"array",
"(",
"$",
"r1text",
",",
"$",
"r2text",
",",
"$",
"r3text",
")",
";",
"return",
"Diff",
"::",
"load",
"(",
"$",
"method",
",",
"$",
"r1text",
",",
"$",
"r2text",
",",
"$",
"r3text",
")",
";",
"}",
"}"
] |
Generate a diff between two or three revision IDs
@access public
@param string $method Revision method. Options: unified, inline, context, threeway, raw
(default: 'unified')
@param mixed $rev1
@param mixed $rev2
@param mixed $rev3
@return string|bool False on failure
@see Diff::load
@fixme: this uses Diff::load, which has been deprecated and Plugin removed from codebase
|
[
"Generate",
"a",
"diff",
"between",
"two",
"or",
"three",
"revision",
"IDs"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2242-L2301
|
233,703
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.get_tokens
|
public function get_tokens( $force = false ) {
Hooks::runHook( 'GetTokens', array( &$this->tokens ) );
if( !$force && !empty( $this->tokens ) ) return $this->tokens;
$tokens = $this->apiQuery(
array(
'action' => 'tokens',
'type' => 'block|delete|deleteglobalaccount|edit|email|import|move|options|patrol|protect|setglobalaccountstatus|unblock|watch'
)
);
foreach( $tokens['tokens'] as $y => $z ){
if( in_string( 'token', $y ) ) {
$this->tokens[str_replace( 'token', '', $y )] = $z;
}
}
$token = $this->apiQuery(
array(
'action' => 'query',
'list' => 'users',
'ususers' => $this->username,
'ustoken' => 'userrights'
)
);
if( isset( $token['query']['users'][0]['userrightstoken'] ) ) {
$this->tokens['userrights'] = $token['query']['users'][0]['userrightstoken'];
} else {
pecho( "Error retrieving userrights token...\n\n", PECHO_FATAL );
return array();
}
return $this->tokens;
}
|
php
|
public function get_tokens( $force = false ) {
Hooks::runHook( 'GetTokens', array( &$this->tokens ) );
if( !$force && !empty( $this->tokens ) ) return $this->tokens;
$tokens = $this->apiQuery(
array(
'action' => 'tokens',
'type' => 'block|delete|deleteglobalaccount|edit|email|import|move|options|patrol|protect|setglobalaccountstatus|unblock|watch'
)
);
foreach( $tokens['tokens'] as $y => $z ){
if( in_string( 'token', $y ) ) {
$this->tokens[str_replace( 'token', '', $y )] = $z;
}
}
$token = $this->apiQuery(
array(
'action' => 'query',
'list' => 'users',
'ususers' => $this->username,
'ustoken' => 'userrights'
)
);
if( isset( $token['query']['users'][0]['userrightstoken'] ) ) {
$this->tokens['userrights'] = $token['query']['users'][0]['userrightstoken'];
} else {
pecho( "Error retrieving userrights token...\n\n", PECHO_FATAL );
return array();
}
return $this->tokens;
}
|
[
"public",
"function",
"get_tokens",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"Hooks",
"::",
"runHook",
"(",
"'GetTokens'",
",",
"array",
"(",
"&",
"$",
"this",
"->",
"tokens",
")",
")",
";",
"if",
"(",
"!",
"$",
"force",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"tokens",
")",
")",
"return",
"$",
"this",
"->",
"tokens",
";",
"$",
"tokens",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"array",
"(",
"'action'",
"=>",
"'tokens'",
",",
"'type'",
"=>",
"'block|delete|deleteglobalaccount|edit|email|import|move|options|patrol|protect|setglobalaccountstatus|unblock|watch'",
")",
")",
";",
"foreach",
"(",
"$",
"tokens",
"[",
"'tokens'",
"]",
"as",
"$",
"y",
"=>",
"$",
"z",
")",
"{",
"if",
"(",
"in_string",
"(",
"'token'",
",",
"$",
"y",
")",
")",
"{",
"$",
"this",
"->",
"tokens",
"[",
"str_replace",
"(",
"'token'",
",",
"''",
",",
"$",
"y",
")",
"]",
"=",
"$",
"z",
";",
"}",
"}",
"$",
"token",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"array",
"(",
"'action'",
"=>",
"'query'",
",",
"'list'",
"=>",
"'users'",
",",
"'ususers'",
"=>",
"$",
"this",
"->",
"username",
",",
"'ustoken'",
"=>",
"'userrights'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"token",
"[",
"'query'",
"]",
"[",
"'users'",
"]",
"[",
"0",
"]",
"[",
"'userrightstoken'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"tokens",
"[",
"'userrights'",
"]",
"=",
"$",
"token",
"[",
"'query'",
"]",
"[",
"'users'",
"]",
"[",
"0",
"]",
"[",
"'userrightstoken'",
"]",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Error retrieving userrights token...\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tokens",
";",
"}"
] |
Regenerate and return edit tokens
@access public
@param bool $force Whether to force use of the API, not cache.
@return array Edit tokens
|
[
"Regenerate",
"and",
"return",
"edit",
"tokens"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2310-L2346
|
233,704
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.get_namespaces
|
public function get_namespaces( $force = false ) {
if( is_null( $this->namespaces ) || $force ) {
$tArray = array(
'meta' => 'siteinfo',
'action' => 'query',
'siprop' => 'namespaces'
);
$tRes = $this->apiQuery( $tArray );
foreach( $tRes['query']['namespaces'] as $namespace ){
$this->namespaces[$namespace['id']] = $namespace['*'];
$this->allowSubpages[$namespace['id']] = ( ( isset( $namespace['subpages'] ) ) ? true : false );
}
}
return $this->namespaces;
}
|
php
|
public function get_namespaces( $force = false ) {
if( is_null( $this->namespaces ) || $force ) {
$tArray = array(
'meta' => 'siteinfo',
'action' => 'query',
'siprop' => 'namespaces'
);
$tRes = $this->apiQuery( $tArray );
foreach( $tRes['query']['namespaces'] as $namespace ){
$this->namespaces[$namespace['id']] = $namespace['*'];
$this->allowSubpages[$namespace['id']] = ( ( isset( $namespace['subpages'] ) ) ? true : false );
}
}
return $this->namespaces;
}
|
[
"public",
"function",
"get_namespaces",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"namespaces",
")",
"||",
"$",
"force",
")",
"{",
"$",
"tArray",
"=",
"array",
"(",
"'meta'",
"=>",
"'siteinfo'",
",",
"'action'",
"=>",
"'query'",
",",
"'siprop'",
"=>",
"'namespaces'",
")",
";",
"$",
"tRes",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"$",
"tArray",
")",
";",
"foreach",
"(",
"$",
"tRes",
"[",
"'query'",
"]",
"[",
"'namespaces'",
"]",
"as",
"$",
"namespace",
")",
"{",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"namespace",
"[",
"'id'",
"]",
"]",
"=",
"$",
"namespace",
"[",
"'*'",
"]",
";",
"$",
"this",
"->",
"allowSubpages",
"[",
"$",
"namespace",
"[",
"'id'",
"]",
"]",
"=",
"(",
"(",
"isset",
"(",
"$",
"namespace",
"[",
"'subpages'",
"]",
")",
")",
"?",
"true",
":",
"false",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"namespaces",
";",
"}"
] |
Returns an array of the namespaces used on the current wiki.
@access public
@param bool $force Whether or not to force an update of any cached values first.
@return array The namespaces in use in the format index => local name.
|
[
"Returns",
"an",
"array",
"of",
"the",
"namespaces",
"used",
"on",
"the",
"current",
"wiki",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2366-L2381
|
233,705
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.removeNamespace
|
public function removeNamespace( $title ) {
$this->get_namespaces();
$exploded = explode( ':', $title, 2 );
foreach( $this->namespaces as $namespace ){
if( $namespace == $exploded[0] ) {
return $exploded[1];
}
}
return $title;
}
|
php
|
public function removeNamespace( $title ) {
$this->get_namespaces();
$exploded = explode( ':', $title, 2 );
foreach( $this->namespaces as $namespace ){
if( $namespace == $exploded[0] ) {
return $exploded[1];
}
}
return $title;
}
|
[
"public",
"function",
"removeNamespace",
"(",
"$",
"title",
")",
"{",
"$",
"this",
"->",
"get_namespaces",
"(",
")",
";",
"$",
"exploded",
"=",
"explode",
"(",
"':'",
",",
"$",
"title",
",",
"2",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"if",
"(",
"$",
"namespace",
"==",
"$",
"exploded",
"[",
"0",
"]",
")",
"{",
"return",
"$",
"exploded",
"[",
"1",
"]",
";",
"}",
"}",
"return",
"$",
"title",
";",
"}"
] |
Removes the namespace from a title
@access public
@param string $title Title to remove namespace from
@return string
|
[
"Removes",
"the",
"namespace",
"from",
"a",
"title"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2391-L2403
|
233,706
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.get_allow_subpages
|
public function get_allow_subpages( $force = false ) {
if( is_null( $this->allowSubpages ) || $force ) {
$this->get_namespaces( true );
}
return $this->allowSubpages;
}
|
php
|
public function get_allow_subpages( $force = false ) {
if( is_null( $this->allowSubpages ) || $force ) {
$this->get_namespaces( true );
}
return $this->allowSubpages;
}
|
[
"public",
"function",
"get_allow_subpages",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"allowSubpages",
")",
"||",
"$",
"force",
")",
"{",
"$",
"this",
"->",
"get_namespaces",
"(",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"allowSubpages",
";",
"}"
] |
Returns an array of subpage-allowing namespaces.
@access public
@param bool $force Whether or not to force an update of any cached values first.
@return array An array of namespaces that allow subpages.
|
[
"Returns",
"an",
"array",
"of",
"subpage",
"-",
"allowing",
"namespaces",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2412-L2417
|
233,707
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.compare
|
public function compare( $fromtitle = null, $fromid = null, $fromrev = null, $totitle = null, $toid = null, $torev = null ) {
pecho( "Getting differences...\n\n", PECHO_NORMAL );
$apiArray = array(
'action' => 'compare'
);
if( !is_null( $fromrev ) ) {
$apiArray['fromrev'] = $fromrev;
} else {
if( !is_null( $fromid ) ) {
$apiArray['fromid'] = $fromid;
} else {
if( !is_null( $fromtitle ) ) {
$apiArray['fromtitle'] = $fromtitle;
} else {
pecho( "Error: a from parameter must be specified.\n\n", PECHO_FATAL );
return false;
}
}
}
if( !is_null( $torev ) ) {
$apiArray['torev'] = $torev;
} else {
if( !is_null( $toid ) ) {
$apiArray['toid'] = $toid;
} else {
if( !is_null( $totitle ) ) {
$apiArray['totitle'] = $totitle;
} else {
pecho( "Error: a to parameter must be specified.\n\n", PECHO_FATAL );
return false;
}
}
}
$results = $this->apiQuery( $apiArray );
if( isset( $results['compare']['*'] ) ) {
return $results['compare']['*'];
} else {
pecho( "Compare failure... Please check your parameters.\n\n", PECHO_FATAL );
return false;
}
}
|
php
|
public function compare( $fromtitle = null, $fromid = null, $fromrev = null, $totitle = null, $toid = null, $torev = null ) {
pecho( "Getting differences...\n\n", PECHO_NORMAL );
$apiArray = array(
'action' => 'compare'
);
if( !is_null( $fromrev ) ) {
$apiArray['fromrev'] = $fromrev;
} else {
if( !is_null( $fromid ) ) {
$apiArray['fromid'] = $fromid;
} else {
if( !is_null( $fromtitle ) ) {
$apiArray['fromtitle'] = $fromtitle;
} else {
pecho( "Error: a from parameter must be specified.\n\n", PECHO_FATAL );
return false;
}
}
}
if( !is_null( $torev ) ) {
$apiArray['torev'] = $torev;
} else {
if( !is_null( $toid ) ) {
$apiArray['toid'] = $toid;
} else {
if( !is_null( $totitle ) ) {
$apiArray['totitle'] = $totitle;
} else {
pecho( "Error: a to parameter must be specified.\n\n", PECHO_FATAL );
return false;
}
}
}
$results = $this->apiQuery( $apiArray );
if( isset( $results['compare']['*'] ) ) {
return $results['compare']['*'];
} else {
pecho( "Compare failure... Please check your parameters.\n\n", PECHO_FATAL );
return false;
}
}
|
[
"public",
"function",
"compare",
"(",
"$",
"fromtitle",
"=",
"null",
",",
"$",
"fromid",
"=",
"null",
",",
"$",
"fromrev",
"=",
"null",
",",
"$",
"totitle",
"=",
"null",
",",
"$",
"toid",
"=",
"null",
",",
"$",
"torev",
"=",
"null",
")",
"{",
"pecho",
"(",
"\"Getting differences...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"$",
"apiArray",
"=",
"array",
"(",
"'action'",
"=>",
"'compare'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"fromrev",
")",
")",
"{",
"$",
"apiArray",
"[",
"'fromrev'",
"]",
"=",
"$",
"fromrev",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"fromid",
")",
")",
"{",
"$",
"apiArray",
"[",
"'fromid'",
"]",
"=",
"$",
"fromid",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"fromtitle",
")",
")",
"{",
"$",
"apiArray",
"[",
"'fromtitle'",
"]",
"=",
"$",
"fromtitle",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Error: a from parameter must be specified.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"torev",
")",
")",
"{",
"$",
"apiArray",
"[",
"'torev'",
"]",
"=",
"$",
"torev",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"toid",
")",
")",
"{",
"$",
"apiArray",
"[",
"'toid'",
"]",
"=",
"$",
"toid",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"totitle",
")",
")",
"{",
"$",
"apiArray",
"[",
"'totitle'",
"]",
"=",
"$",
"totitle",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Error: a to parameter must be specified.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"$",
"results",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"$",
"apiArray",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"results",
"[",
"'compare'",
"]",
"[",
"'*'",
"]",
")",
")",
"{",
"return",
"$",
"results",
"[",
"'compare'",
"]",
"[",
"'*'",
"]",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Compare failure... Please check your parameters.\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Get the difference between 2 pages
@access public
@param string $fromtitle First title to compare
@param string $fromid First page ID to compare
@param string $fromrev First revision to compare
@param string $totitle Second title to compare
@param string $toid Second page ID to compare
@param string $torev Second revision to compare
@return array
|
[
"Get",
"the",
"difference",
"between",
"2",
"pages"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2511-L2553
|
233,708
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.opensearch
|
public function opensearch( $text = '', $limit = 10, $namespaces = array( 0 ), $suggest = true ) {
$apiArray = array(
'search' => $text,
'action' => 'opensearch',
'limit' => $limit,
'namespace' => implode( '|', $namespaces )
);
if( $suggest ) $apiArray['suggest'] = '';
$OSres = $this->get_http()->get( $this->get_base_url(), $apiArray );
return ( $OSres === false || is_null( $OSres ) ? false : json_decode( $OSres, true ) );
}
|
php
|
public function opensearch( $text = '', $limit = 10, $namespaces = array( 0 ), $suggest = true ) {
$apiArray = array(
'search' => $text,
'action' => 'opensearch',
'limit' => $limit,
'namespace' => implode( '|', $namespaces )
);
if( $suggest ) $apiArray['suggest'] = '';
$OSres = $this->get_http()->get( $this->get_base_url(), $apiArray );
return ( $OSres === false || is_null( $OSres ) ? false : json_decode( $OSres, true ) );
}
|
[
"public",
"function",
"opensearch",
"(",
"$",
"text",
"=",
"''",
",",
"$",
"limit",
"=",
"10",
",",
"$",
"namespaces",
"=",
"array",
"(",
"0",
")",
",",
"$",
"suggest",
"=",
"true",
")",
"{",
"$",
"apiArray",
"=",
"array",
"(",
"'search'",
"=>",
"$",
"text",
",",
"'action'",
"=>",
"'opensearch'",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"'namespace'",
"=>",
"implode",
"(",
"'|'",
",",
"$",
"namespaces",
")",
")",
";",
"if",
"(",
"$",
"suggest",
")",
"$",
"apiArray",
"[",
"'suggest'",
"]",
"=",
"''",
";",
"$",
"OSres",
"=",
"$",
"this",
"->",
"get_http",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"get_base_url",
"(",
")",
",",
"$",
"apiArray",
")",
";",
"return",
"(",
"$",
"OSres",
"===",
"false",
"||",
"is_null",
"(",
"$",
"OSres",
")",
"?",
"false",
":",
"json_decode",
"(",
"$",
"OSres",
",",
"true",
")",
")",
";",
"}"
] |
Search the wiki using the OpenSearch protocol.
@access public
@param string $text Search string. Default empty.
@param int $limit Maximum amount of results to return. Default 10.
@param array $namespaces Namespaces to search. Default array(0).
@param bool $suggest Do nothing if $wgEnableOpenSearchSuggest is false. Default true.
@return array
|
[
"Search",
"the",
"wiki",
"using",
"the",
"OpenSearch",
"protocol",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2565-L2578
|
233,709
|
MW-Peachy/Peachy
|
Includes/Wiki.php
|
Wiki.options
|
public function options( $reset = false, $resetoptions = array( 'all' ), $changeoptions = array(), $optionname = null, $optionvalue = null ) {
$this->get_tokens();
$apiArray = array(
'action' => 'options',
'token' => $this->tokens['options']
);
if( $reset ) {
$apiArray['reset'] = '';
$apiArray['resetkinds'] = implode( '|', $resetoptions );
}
if( !empty( $changeoptions ) ) $apiArray['change'] = implode( '|', $changeoptions );
if( !is_null( $optionname ) ) $apiArray['optionname'] = $optionname;
if( !is_null( $optionvalue ) ) $apiArray['optionvalue'] = $optionvalue;
$result = $this->apiQuery( $apiArray, true );
if( isset( $result['options'] ) && $result['options'] == 'success' ) {
if( isset( $result['warnings'] ) ) pecho( "Options set successfully, however a warning was thrown:\n" . print_r( $result['warnings'], true ), PECHO_WARN );
return true;
} else {
pecho( "Options error...\n\n" . print_r( $result, true ), PECHO_FATAL );
return false;
}
}
|
php
|
public function options( $reset = false, $resetoptions = array( 'all' ), $changeoptions = array(), $optionname = null, $optionvalue = null ) {
$this->get_tokens();
$apiArray = array(
'action' => 'options',
'token' => $this->tokens['options']
);
if( $reset ) {
$apiArray['reset'] = '';
$apiArray['resetkinds'] = implode( '|', $resetoptions );
}
if( !empty( $changeoptions ) ) $apiArray['change'] = implode( '|', $changeoptions );
if( !is_null( $optionname ) ) $apiArray['optionname'] = $optionname;
if( !is_null( $optionvalue ) ) $apiArray['optionvalue'] = $optionvalue;
$result = $this->apiQuery( $apiArray, true );
if( isset( $result['options'] ) && $result['options'] == 'success' ) {
if( isset( $result['warnings'] ) ) pecho( "Options set successfully, however a warning was thrown:\n" . print_r( $result['warnings'], true ), PECHO_WARN );
return true;
} else {
pecho( "Options error...\n\n" . print_r( $result, true ), PECHO_FATAL );
return false;
}
}
|
[
"public",
"function",
"options",
"(",
"$",
"reset",
"=",
"false",
",",
"$",
"resetoptions",
"=",
"array",
"(",
"'all'",
")",
",",
"$",
"changeoptions",
"=",
"array",
"(",
")",
",",
"$",
"optionname",
"=",
"null",
",",
"$",
"optionvalue",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"get_tokens",
"(",
")",
";",
"$",
"apiArray",
"=",
"array",
"(",
"'action'",
"=>",
"'options'",
",",
"'token'",
"=>",
"$",
"this",
"->",
"tokens",
"[",
"'options'",
"]",
")",
";",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"apiArray",
"[",
"'reset'",
"]",
"=",
"''",
";",
"$",
"apiArray",
"[",
"'resetkinds'",
"]",
"=",
"implode",
"(",
"'|'",
",",
"$",
"resetoptions",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"changeoptions",
")",
")",
"$",
"apiArray",
"[",
"'change'",
"]",
"=",
"implode",
"(",
"'|'",
",",
"$",
"changeoptions",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"optionname",
")",
")",
"$",
"apiArray",
"[",
"'optionname'",
"]",
"=",
"$",
"optionname",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"optionvalue",
")",
")",
"$",
"apiArray",
"[",
"'optionvalue'",
"]",
"=",
"$",
"optionvalue",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiQuery",
"(",
"$",
"apiArray",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'options'",
"]",
")",
"&&",
"$",
"result",
"[",
"'options'",
"]",
"==",
"'success'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'warnings'",
"]",
")",
")",
"pecho",
"(",
"\"Options set successfully, however a warning was thrown:\\n\"",
".",
"print_r",
"(",
"$",
"result",
"[",
"'warnings'",
"]",
",",
"true",
")",
",",
"PECHO_WARN",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Options error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
",",
"true",
")",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Change preferences of the current user.
@access public
@param bool $reset Resets preferences to the site defaults. Default false.
@param array|string $resetoptions List of types of options to reset when the "reset" option is set. Default 'all'.
@param array|string $changeoptions PartList of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters. If no value is given (not even an equals sign), e.g., optionname|otheroption|..., the option will be reset to its default value. Default empty.
@param string $optionname A name of a option which should have an optionvalue set. Default null.
@param string $optionvalue A value of the option specified by the optionname, can contain pipe characters. Default null.
@return boolean
|
[
"Change",
"preferences",
"of",
"the",
"current",
"user",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Wiki.php#L2607-L2632
|
233,710
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/DescriptorProtoMeta.php
|
DescriptorProtoMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new DescriptorProto();
case 1:
return new DescriptorProto(func_get_arg(0));
case 2:
return new DescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new DescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new DescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new DescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new DescriptorProto(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 DescriptorProto(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 DescriptorProto(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 DescriptorProto();
case 1:
return new DescriptorProto(func_get_arg(0));
case 2:
return new DescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new DescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new DescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new DescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new DescriptorProto(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 DescriptorProto(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 DescriptorProto(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",
"DescriptorProto",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"DescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"DescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"DescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"DescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"DescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"DescriptorProto",
"(",
"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",
"DescriptorProto",
"(",
"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",
"DescriptorProto",
"(",
"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\DescriptorProto
@throws \InvalidArgumentException
@return DescriptorProto
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/DescriptorProtoMeta.php#L68-L92
|
233,711
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/DescriptorProtoMeta.php
|
DescriptorProtoMeta.reset
|
public static function reset($object)
{
if (!($object instanceof DescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto.');
}
$object->name = NULL;
$object->field = NULL;
$object->extension = NULL;
$object->nestedType = NULL;
$object->enumType = NULL;
$object->extensionRange = NULL;
$object->oneofDecl = NULL;
$object->options = NULL;
$object->reservedRange = NULL;
$object->reservedName = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof DescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto.');
}
$object->name = NULL;
$object->field = NULL;
$object->extension = NULL;
$object->nestedType = NULL;
$object->enumType = NULL;
$object->extensionRange = NULL;
$object->oneofDecl = NULL;
$object->options = NULL;
$object->reservedRange = NULL;
$object->reservedName = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"DescriptorProto",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\DescriptorProto.'",
")",
";",
"}",
"$",
"object",
"->",
"name",
"=",
"NULL",
";",
"$",
"object",
"->",
"field",
"=",
"NULL",
";",
"$",
"object",
"->",
"extension",
"=",
"NULL",
";",
"$",
"object",
"->",
"nestedType",
"=",
"NULL",
";",
"$",
"object",
"->",
"enumType",
"=",
"NULL",
";",
"$",
"object",
"->",
"extensionRange",
"=",
"NULL",
";",
"$",
"object",
"->",
"oneofDecl",
"=",
"NULL",
";",
"$",
"object",
"->",
"options",
"=",
"NULL",
";",
"$",
"object",
"->",
"reservedRange",
"=",
"NULL",
";",
"$",
"object",
"->",
"reservedName",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\DescriptorProto to default values
@param DescriptorProto $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/DescriptorProtoMeta.php#L105-L120
|
233,712
|
venca-x/social-login
|
src/FacebookLogin.php
|
FacebookLogin.getMe
|
public function getMe($fields)
{
$accessTokenObject = $this->helper->getAccessToken($this->callBackUrl);
if ($accessTokenObject == null) {
throw new Exception('User not allowed permissions');
}
if ($fields == '' || !is_array($fields) || count($fields) == 0) {
//array is empty
$fields = [self::ID];//set ID field
}
try {
if (isset($_SESSION['facebook_access_token'])) {
$this->fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
} else {
$_SESSION['facebook_access_token'] = (string) $accessTokenObject;
}
$client = $this->fb->getOAuth2Client();
$accessToken = $client->getLongLivedAccessToken($accessTokenObject->getValue());
$response = $this->fb->get('/me?fields=' . implode(',', $fields), $accessToken);
$this->setSocialLoginCookie(self::SOCIAL_NAME);
return $response->getDecodedBody();
} catch (Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
throw new Exception($e->getMessage());
} catch (Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
throw new Exception($e->getMessage());
}
}
|
php
|
public function getMe($fields)
{
$accessTokenObject = $this->helper->getAccessToken($this->callBackUrl);
if ($accessTokenObject == null) {
throw new Exception('User not allowed permissions');
}
if ($fields == '' || !is_array($fields) || count($fields) == 0) {
//array is empty
$fields = [self::ID];//set ID field
}
try {
if (isset($_SESSION['facebook_access_token'])) {
$this->fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
} else {
$_SESSION['facebook_access_token'] = (string) $accessTokenObject;
}
$client = $this->fb->getOAuth2Client();
$accessToken = $client->getLongLivedAccessToken($accessTokenObject->getValue());
$response = $this->fb->get('/me?fields=' . implode(',', $fields), $accessToken);
$this->setSocialLoginCookie(self::SOCIAL_NAME);
return $response->getDecodedBody();
} catch (Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
throw new Exception($e->getMessage());
} catch (Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
throw new Exception($e->getMessage());
}
}
|
[
"public",
"function",
"getMe",
"(",
"$",
"fields",
")",
"{",
"$",
"accessTokenObject",
"=",
"$",
"this",
"->",
"helper",
"->",
"getAccessToken",
"(",
"$",
"this",
"->",
"callBackUrl",
")",
";",
"if",
"(",
"$",
"accessTokenObject",
"==",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'User not allowed permissions'",
")",
";",
"}",
"if",
"(",
"$",
"fields",
"==",
"''",
"||",
"!",
"is_array",
"(",
"$",
"fields",
")",
"||",
"count",
"(",
"$",
"fields",
")",
"==",
"0",
")",
"{",
"//array is empty",
"$",
"fields",
"=",
"[",
"self",
"::",
"ID",
"]",
";",
"//set ID field",
"}",
"try",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'facebook_access_token'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"fb",
"->",
"setDefaultAccessToken",
"(",
"$",
"_SESSION",
"[",
"'facebook_access_token'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"_SESSION",
"[",
"'facebook_access_token'",
"]",
"=",
"(",
"string",
")",
"$",
"accessTokenObject",
";",
"}",
"$",
"client",
"=",
"$",
"this",
"->",
"fb",
"->",
"getOAuth2Client",
"(",
")",
";",
"$",
"accessToken",
"=",
"$",
"client",
"->",
"getLongLivedAccessToken",
"(",
"$",
"accessTokenObject",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"fb",
"->",
"get",
"(",
"'/me?fields='",
".",
"implode",
"(",
"','",
",",
"$",
"fields",
")",
",",
"$",
"accessToken",
")",
";",
"$",
"this",
"->",
"setSocialLoginCookie",
"(",
"self",
"::",
"SOCIAL_NAME",
")",
";",
"return",
"$",
"response",
"->",
"getDecodedBody",
"(",
")",
";",
"}",
"catch",
"(",
"Facebook",
"\\",
"Exceptions",
"\\",
"FacebookResponseException",
"$",
"e",
")",
"{",
"// When Graph returns an error",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Facebook",
"\\",
"Exceptions",
"\\",
"FacebookSDKException",
"$",
"e",
")",
"{",
"// When validation fails or other local issues",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Return info about facebook user
@param $fields
@return array
@throws Exception
|
[
"Return",
"info",
"about",
"facebook",
"user"
] |
ca2ae72b30f1d4e1a5bd78c06cd72faefd625dab
|
https://github.com/venca-x/social-login/blob/ca2ae72b30f1d4e1a5bd78c06cd72faefd625dab/src/FacebookLogin.php#L210-L244
|
233,713
|
kaliop-uk/kueueingbundle
|
Service/WorkerManager.php
|
WorkerManager.getWorkersCommands
|
public function getWorkersCommands($env = null)
{
$procs = array();
foreach ($this->getWorkersNames() as $name) {
$procs[$name] = $this->getWorkerCommand($name, $env);
}
return $procs;
}
|
php
|
public function getWorkersCommands($env = null)
{
$procs = array();
foreach ($this->getWorkersNames() as $name) {
$procs[$name] = $this->getWorkerCommand($name, $env);
}
return $procs;
}
|
[
"public",
"function",
"getWorkersCommands",
"(",
"$",
"env",
"=",
"null",
")",
"{",
"$",
"procs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getWorkersNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"$",
"procs",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"getWorkerCommand",
"(",
"$",
"name",
",",
"$",
"env",
")",
";",
"}",
"return",
"$",
"procs",
";",
"}"
] |
Returns the list of commands for all workers configured to be running as daemons
@param string $env
@return array key: worker name, value: command to execute to start the worker
@throws \Exception
|
[
"Returns",
"the",
"list",
"of",
"commands",
"for",
"all",
"workers",
"configured",
"to",
"be",
"running",
"as",
"daemons"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/WorkerManager.php#L32-L39
|
233,714
|
kaliop-uk/kueueingbundle
|
Service/WorkerManager.php
|
WorkerManager.getWorkerCommand
|
public function getWorkerCommand($name, $env = null, $unescaped = false)
{
$defs = $this->workersList;
if (!isset($defs[$name])) {
throw new \Exception("No worker configuration for $name");
}
$workerDef = $defs[$name];
if (empty($workerDef['queue_name']) || (isset($workerDef['options']) && !is_array($workerDef['options']))) {
throw new \Exception("Bad worker configuration for $name");
}
$cmd = $this->getConsoleCommand($env, $unescaped) .
" kaliop_queueing:consumer " . ($unescaped ? $workerDef['queue_name'] : escapeshellarg($workerDef['queue_name'])) .
" --label=" . ($unescaped ? $name : escapeshellarg($name)) . " -w";
if (isset($workerDef['options'])) {
foreach ($workerDef['options'] as $name => $value) {
$cmd .= ' ' . (strlen($name) == 1 ? '-' : '--') . $name . '=' . ($unescaped ? $value : escapeshellarg($value));
}
}
return $cmd;
}
|
php
|
public function getWorkerCommand($name, $env = null, $unescaped = false)
{
$defs = $this->workersList;
if (!isset($defs[$name])) {
throw new \Exception("No worker configuration for $name");
}
$workerDef = $defs[$name];
if (empty($workerDef['queue_name']) || (isset($workerDef['options']) && !is_array($workerDef['options']))) {
throw new \Exception("Bad worker configuration for $name");
}
$cmd = $this->getConsoleCommand($env, $unescaped) .
" kaliop_queueing:consumer " . ($unescaped ? $workerDef['queue_name'] : escapeshellarg($workerDef['queue_name'])) .
" --label=" . ($unescaped ? $name : escapeshellarg($name)) . " -w";
if (isset($workerDef['options'])) {
foreach ($workerDef['options'] as $name => $value) {
$cmd .= ' ' . (strlen($name) == 1 ? '-' : '--') . $name . '=' . ($unescaped ? $value : escapeshellarg($value));
}
}
return $cmd;
}
|
[
"public",
"function",
"getWorkerCommand",
"(",
"$",
"name",
",",
"$",
"env",
"=",
"null",
",",
"$",
"unescaped",
"=",
"false",
")",
"{",
"$",
"defs",
"=",
"$",
"this",
"->",
"workersList",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"defs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"No worker configuration for $name\"",
")",
";",
"}",
"$",
"workerDef",
"=",
"$",
"defs",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"workerDef",
"[",
"'queue_name'",
"]",
")",
"||",
"(",
"isset",
"(",
"$",
"workerDef",
"[",
"'options'",
"]",
")",
"&&",
"!",
"is_array",
"(",
"$",
"workerDef",
"[",
"'options'",
"]",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Bad worker configuration for $name\"",
")",
";",
"}",
"$",
"cmd",
"=",
"$",
"this",
"->",
"getConsoleCommand",
"(",
"$",
"env",
",",
"$",
"unescaped",
")",
".",
"\" kaliop_queueing:consumer \"",
".",
"(",
"$",
"unescaped",
"?",
"$",
"workerDef",
"[",
"'queue_name'",
"]",
":",
"escapeshellarg",
"(",
"$",
"workerDef",
"[",
"'queue_name'",
"]",
")",
")",
".",
"\" --label=\"",
".",
"(",
"$",
"unescaped",
"?",
"$",
"name",
":",
"escapeshellarg",
"(",
"$",
"name",
")",
")",
".",
"\" -w\"",
";",
"if",
"(",
"isset",
"(",
"$",
"workerDef",
"[",
"'options'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"workerDef",
"[",
"'options'",
"]",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"cmd",
".=",
"' '",
".",
"(",
"strlen",
"(",
"$",
"name",
")",
"==",
"1",
"?",
"'-'",
":",
"'--'",
")",
".",
"$",
"name",
".",
"'='",
".",
"(",
"$",
"unescaped",
"?",
"$",
"value",
":",
"escapeshellarg",
"(",
"$",
"value",
")",
")",
";",
"}",
"}",
"return",
"$",
"cmd",
";",
"}"
] |
Returns the command line of a worker configured to be running as daemon
@param string $name
@param string $env set it to non null to force execution using a specific environment
@param bool $unescaped do not add shell escaping to the command. NB: never use this option for executing stuff, only for grepping
@return string
@throws \Exception
@todo make queue_name optional: take it from $name if not set (it is only used to allow many workers for the same queue)
@todo allow to take path to php binary from config
@todo filter out any undesirable cli options from the ones given by the user
@todo tighten security: option names should be checked against the valid ones in the rabbitmq:consumer process
@todo get the name of the console command from himself
|
[
"Returns",
"the",
"command",
"line",
"of",
"a",
"worker",
"configured",
"to",
"be",
"running",
"as",
"daemon"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/WorkerManager.php#L64-L83
|
233,715
|
kaliop-uk/kueueingbundle
|
Service/WorkerManager.php
|
WorkerManager.getConsoleCommand
|
public function getConsoleCommand($env = null, $unescaped = false)
{
$phpFinder = new PhpExecutableFinder;
if (!$php = $phpFinder->find()) {
throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again');
}
$out = $php . ' ' . escapeshellcmd($this->kernelRootDir . DIRECTORY_SEPARATOR . "console");
if ($env != '') {
$out .= ' --env=' . ($unescaped ? $env : escapeshellarg($env));
}
return $out;
}
|
php
|
public function getConsoleCommand($env = null, $unescaped = false)
{
$phpFinder = new PhpExecutableFinder;
if (!$php = $phpFinder->find()) {
throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again');
}
$out = $php . ' ' . escapeshellcmd($this->kernelRootDir . DIRECTORY_SEPARATOR . "console");
if ($env != '') {
$out .= ' --env=' . ($unescaped ? $env : escapeshellarg($env));
}
return $out;
}
|
[
"public",
"function",
"getConsoleCommand",
"(",
"$",
"env",
"=",
"null",
",",
"$",
"unescaped",
"=",
"false",
")",
"{",
"$",
"phpFinder",
"=",
"new",
"PhpExecutableFinder",
";",
"if",
"(",
"!",
"$",
"php",
"=",
"$",
"phpFinder",
"->",
"find",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The php executable could not be found, add it to your PATH environment variable and try again'",
")",
";",
"}",
"$",
"out",
"=",
"$",
"php",
".",
"' '",
".",
"escapeshellcmd",
"(",
"$",
"this",
"->",
"kernelRootDir",
".",
"DIRECTORY_SEPARATOR",
".",
"\"console\"",
")",
";",
"if",
"(",
"$",
"env",
"!=",
"''",
")",
"{",
"$",
"out",
".=",
"' --env='",
".",
"(",
"$",
"unescaped",
"?",
"$",
"env",
":",
"escapeshellarg",
"(",
"$",
"env",
")",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Generates the php command to run the sf console
@param string $env when not null an environment is set for the cmd to execute
@param bool $unescaped do not add shell escaping to the command. NB: never use this option for executing stuff, only for grepping
@return string
@throws \RuntimeException
@todo should get the name of the 'console' file in some kind of flexible way as well?
|
[
"Generates",
"the",
"php",
"command",
"to",
"run",
"the",
"sf",
"console"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/WorkerManager.php#L95-L107
|
233,716
|
yeephp/yeephp
|
Yee/Http/Util.php
|
Util.serializeCookies
|
public static function serializeCookies(\Yee\Http\Headers &$headers, \Yee\Http\Cookies $cookies, array $config)
{
if ($config['cookies.encrypt']) {
foreach ($cookies as $name => $settings) {
if (is_string($settings['expires'])) {
$expires = strtotime($settings['expires']);
} else {
$expires = (int) $settings['expires'];
}
$settings['value'] = static::encodeSecureCookie(
$settings['value'],
$expires,
$config['cookies.secret_key'],
$config['cookies.cipher'],
$config['cookies.cipher_mode']
);
static::setCookieHeader($headers, $name, $settings);
}
} else {
foreach ($cookies as $name => $settings) {
static::setCookieHeader($headers, $name, $settings);
}
}
}
|
php
|
public static function serializeCookies(\Yee\Http\Headers &$headers, \Yee\Http\Cookies $cookies, array $config)
{
if ($config['cookies.encrypt']) {
foreach ($cookies as $name => $settings) {
if (is_string($settings['expires'])) {
$expires = strtotime($settings['expires']);
} else {
$expires = (int) $settings['expires'];
}
$settings['value'] = static::encodeSecureCookie(
$settings['value'],
$expires,
$config['cookies.secret_key'],
$config['cookies.cipher'],
$config['cookies.cipher_mode']
);
static::setCookieHeader($headers, $name, $settings);
}
} else {
foreach ($cookies as $name => $settings) {
static::setCookieHeader($headers, $name, $settings);
}
}
}
|
[
"public",
"static",
"function",
"serializeCookies",
"(",
"\\",
"Yee",
"\\",
"Http",
"\\",
"Headers",
"&",
"$",
"headers",
",",
"\\",
"Yee",
"\\",
"Http",
"\\",
"Cookies",
"$",
"cookies",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"[",
"'cookies.encrypt'",
"]",
")",
"{",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"name",
"=>",
"$",
"settings",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"settings",
"[",
"'expires'",
"]",
")",
")",
"{",
"$",
"expires",
"=",
"strtotime",
"(",
"$",
"settings",
"[",
"'expires'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"expires",
"=",
"(",
"int",
")",
"$",
"settings",
"[",
"'expires'",
"]",
";",
"}",
"$",
"settings",
"[",
"'value'",
"]",
"=",
"static",
"::",
"encodeSecureCookie",
"(",
"$",
"settings",
"[",
"'value'",
"]",
",",
"$",
"expires",
",",
"$",
"config",
"[",
"'cookies.secret_key'",
"]",
",",
"$",
"config",
"[",
"'cookies.cipher'",
"]",
",",
"$",
"config",
"[",
"'cookies.cipher_mode'",
"]",
")",
";",
"static",
"::",
"setCookieHeader",
"(",
"$",
"headers",
",",
"$",
"name",
",",
"$",
"settings",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"name",
"=>",
"$",
"settings",
")",
"{",
"static",
"::",
"setCookieHeader",
"(",
"$",
"headers",
",",
"$",
"name",
",",
"$",
"settings",
")",
";",
"}",
"}",
"}"
] |
Serialize Response cookies into raw HTTP header
@param \Yee\Http\Headers $headers The Response headers
@param \Yee\Http\Cookies $cookies The Response cookies
@param array $config The Yee app settings
|
[
"Serialize",
"Response",
"cookies",
"into",
"raw",
"HTTP",
"header"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L185-L209
|
233,717
|
yeephp/yeephp
|
Yee/Http/Util.php
|
Util.decodeSecureCookie
|
public static function decodeSecureCookie($value, $secret, $algorithm, $mode)
{
if ($value) {
$value = explode('|', $value);
if (count($value) === 3 && ((int) $value[0] === 0 || (int) $value[0] > time())) {
$key = hash_hmac('sha1', $value[0], $secret);
$iv = self::getIv($value[0], $secret);
$data = self::decrypt(
base64_decode($value[1]),
$key,
$iv,
array(
'algorithm' => $algorithm,
'mode' => $mode
)
);
$verificationString = hash_hmac('sha1', $value[0] . $data, $key);
if ($verificationString === $value[2]) {
return $data;
}
}
}
return false;
}
|
php
|
public static function decodeSecureCookie($value, $secret, $algorithm, $mode)
{
if ($value) {
$value = explode('|', $value);
if (count($value) === 3 && ((int) $value[0] === 0 || (int) $value[0] > time())) {
$key = hash_hmac('sha1', $value[0], $secret);
$iv = self::getIv($value[0], $secret);
$data = self::decrypt(
base64_decode($value[1]),
$key,
$iv,
array(
'algorithm' => $algorithm,
'mode' => $mode
)
);
$verificationString = hash_hmac('sha1', $value[0] . $data, $key);
if ($verificationString === $value[2]) {
return $data;
}
}
}
return false;
}
|
[
"public",
"static",
"function",
"decodeSecureCookie",
"(",
"$",
"value",
",",
"$",
"secret",
",",
"$",
"algorithm",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"explode",
"(",
"'|'",
",",
"$",
"value",
")",
";",
"if",
"(",
"count",
"(",
"$",
"value",
")",
"===",
"3",
"&&",
"(",
"(",
"int",
")",
"$",
"value",
"[",
"0",
"]",
"===",
"0",
"||",
"(",
"int",
")",
"$",
"value",
"[",
"0",
"]",
">",
"time",
"(",
")",
")",
")",
"{",
"$",
"key",
"=",
"hash_hmac",
"(",
"'sha1'",
",",
"$",
"value",
"[",
"0",
"]",
",",
"$",
"secret",
")",
";",
"$",
"iv",
"=",
"self",
"::",
"getIv",
"(",
"$",
"value",
"[",
"0",
"]",
",",
"$",
"secret",
")",
";",
"$",
"data",
"=",
"self",
"::",
"decrypt",
"(",
"base64_decode",
"(",
"$",
"value",
"[",
"1",
"]",
")",
",",
"$",
"key",
",",
"$",
"iv",
",",
"array",
"(",
"'algorithm'",
"=>",
"$",
"algorithm",
",",
"'mode'",
"=>",
"$",
"mode",
")",
")",
";",
"$",
"verificationString",
"=",
"hash_hmac",
"(",
"'sha1'",
",",
"$",
"value",
"[",
"0",
"]",
".",
"$",
"data",
",",
"$",
"key",
")",
";",
"if",
"(",
"$",
"verificationString",
"===",
"$",
"value",
"[",
"2",
"]",
")",
"{",
"return",
"$",
"data",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Decode secure cookie value
This method will decode the secure value of an HTTP cookie. The
cookie value is encrypted and hashed so that its value is
secure and checked for integrity when read in subsequent requests.
@param string $value The secure HTTP cookie value
@param string $secret The secret key used to hash the cookie value
@param int $algorithm The algorithm to use for encryption
@param int $mode The algorithm mode to use for encryption
@return bool|string
|
[
"Decode",
"secure",
"cookie",
"value"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L258-L282
|
233,718
|
yeephp/yeephp
|
Yee/View.php
|
View.setData
|
public function setData()
{
$args = func_get_args();
if (count($args) === 1 && is_array($args[0])) {
$this->data->replace($args[0]);
} elseif (count($args) === 2) {
// Ensure original behavior is maintained. DO NOT invoke stored Closures.
if (is_object($args[1]) && method_exists($args[1], '__invoke')) {
$this->data->set($args[0], $this->data->protect($args[1]));
} else {
$this->data->set($args[0], $args[1]);
}
} else {
throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`');
}
}
|
php
|
public function setData()
{
$args = func_get_args();
if (count($args) === 1 && is_array($args[0])) {
$this->data->replace($args[0]);
} elseif (count($args) === 2) {
// Ensure original behavior is maintained. DO NOT invoke stored Closures.
if (is_object($args[1]) && method_exists($args[1], '__invoke')) {
$this->data->set($args[0], $this->data->protect($args[1]));
} else {
$this->data->set($args[0], $args[1]);
}
} else {
throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`');
}
}
|
[
"public",
"function",
"setData",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"===",
"1",
"&&",
"is_array",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"replace",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"args",
")",
"===",
"2",
")",
"{",
"// Ensure original behavior is maintained. DO NOT invoke stored Closures.",
"if",
"(",
"is_object",
"(",
"$",
"args",
"[",
"1",
"]",
")",
"&&",
"method_exists",
"(",
"$",
"args",
"[",
"1",
"]",
",",
"'__invoke'",
")",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"set",
"(",
"$",
"args",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"data",
"->",
"protect",
"(",
"$",
"args",
"[",
"1",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"->",
"set",
"(",
"$",
"args",
"[",
"0",
"]",
",",
"$",
"args",
"[",
"1",
"]",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`'",
")",
";",
"}",
"}"
] |
DEPRECATION WARNING! This method will be removed in the next major point release
Set data for view
|
[
"DEPRECATION",
"WARNING!",
"This",
"method",
"will",
"be",
"removed",
"in",
"the",
"next",
"major",
"point",
"release"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/View.php#L165-L180
|
233,719
|
budde377/Part
|
lib/util/file/LogFileImpl.php
|
LogFileImpl.log
|
public function log($message, $level, &$createDumpFile = false)
{
$this->create();
$array = array($level, $t = time(), $message);
if($createDumpFile !== false){
$createDumpFile = new DumpFileImpl($this->getParentFolder()->getAbsolutePath()."/dump-".uniqid());
$this->dumparray[$array[] = $createDumpFile->getFilename()] = $createDumpFile;
}
fputcsv($r = $this->getResource(), $array);
fclose($r);
return $t;
}
|
php
|
public function log($message, $level, &$createDumpFile = false)
{
$this->create();
$array = array($level, $t = time(), $message);
if($createDumpFile !== false){
$createDumpFile = new DumpFileImpl($this->getParentFolder()->getAbsolutePath()."/dump-".uniqid());
$this->dumparray[$array[] = $createDumpFile->getFilename()] = $createDumpFile;
}
fputcsv($r = $this->getResource(), $array);
fclose($r);
return $t;
}
|
[
"public",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"level",
",",
"&",
"$",
"createDumpFile",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"create",
"(",
")",
";",
"$",
"array",
"=",
"array",
"(",
"$",
"level",
",",
"$",
"t",
"=",
"time",
"(",
")",
",",
"$",
"message",
")",
";",
"if",
"(",
"$",
"createDumpFile",
"!==",
"false",
")",
"{",
"$",
"createDumpFile",
"=",
"new",
"DumpFileImpl",
"(",
"$",
"this",
"->",
"getParentFolder",
"(",
")",
"->",
"getAbsolutePath",
"(",
")",
".",
"\"/dump-\"",
".",
"uniqid",
"(",
")",
")",
";",
"$",
"this",
"->",
"dumparray",
"[",
"$",
"array",
"[",
"]",
"=",
"$",
"createDumpFile",
"->",
"getFilename",
"(",
")",
"]",
"=",
"$",
"createDumpFile",
";",
"}",
"fputcsv",
"(",
"$",
"r",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
",",
"$",
"array",
")",
";",
"fclose",
"(",
"$",
"r",
")",
";",
"return",
"$",
"t",
";",
"}"
] |
Will log a message and write to file.
@param string $message
@param int $level
@param bool|DumpFile $createDumpFile
@return int
|
[
"Will",
"log",
"a",
"message",
"and",
"write",
"to",
"file",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/LogFileImpl.php#L24-L39
|
233,720
|
budde377/Part
|
lib/util/file/LogFileImpl.php
|
LogFileImpl.clearLog
|
public function clearLog()
{
$this->listLog();
foreach($this->dumparray as $df){
/** @var $df DumpFile */
$df->delete();
}
$this->setAccessMode(File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH);
$this->write("");
$this->setAccessMode(File::FILE_MODE_RW_POINTER_AT_END);
}
|
php
|
public function clearLog()
{
$this->listLog();
foreach($this->dumparray as $df){
/** @var $df DumpFile */
$df->delete();
}
$this->setAccessMode(File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH);
$this->write("");
$this->setAccessMode(File::FILE_MODE_RW_POINTER_AT_END);
}
|
[
"public",
"function",
"clearLog",
"(",
")",
"{",
"$",
"this",
"->",
"listLog",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"dumparray",
"as",
"$",
"df",
")",
"{",
"/** @var $df DumpFile */",
"$",
"df",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setAccessMode",
"(",
"File",
"::",
"FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH",
")",
";",
"$",
"this",
"->",
"write",
"(",
"\"\"",
")",
";",
"$",
"this",
"->",
"setAccessMode",
"(",
"File",
"::",
"FILE_MODE_RW_POINTER_AT_END",
")",
";",
"}"
] |
Will clear the log and remove all dump files.
@return void
|
[
"Will",
"clear",
"the",
"log",
"and",
"remove",
"all",
"dump",
"files",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/LogFileImpl.php#L74-L85
|
233,721
|
yarcode/yii2-email-manager
|
src/models/Template.php
|
Template.validateTwig
|
public function validateTwig($attribute)
{
$twig = $this->getTwig(new \Twig_Loader_String());
try {
$twig->render($this->$attribute);
} catch (\Exception $e) {
$message = "Error compiling {$attribute}: " . $e->getMessage();
$this->addError($attribute, $message);
}
}
|
php
|
public function validateTwig($attribute)
{
$twig = $this->getTwig(new \Twig_Loader_String());
try {
$twig->render($this->$attribute);
} catch (\Exception $e) {
$message = "Error compiling {$attribute}: " . $e->getMessage();
$this->addError($attribute, $message);
}
}
|
[
"public",
"function",
"validateTwig",
"(",
"$",
"attribute",
")",
"{",
"$",
"twig",
"=",
"$",
"this",
"->",
"getTwig",
"(",
"new",
"\\",
"Twig_Loader_String",
"(",
")",
")",
";",
"try",
"{",
"$",
"twig",
"->",
"render",
"(",
"$",
"this",
"->",
"$",
"attribute",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"\"Error compiling {$attribute}: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"$",
"message",
")",
";",
"}",
"}"
] |
Validator for twig attributes
@param $attribute
|
[
"Validator",
"for",
"twig",
"attributes"
] |
4e83eae67199fc2b9eca9f08dcf59cc0440c385a
|
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L78-L88
|
233,722
|
yarcode/yii2-email-manager
|
src/models/Template.php
|
Template.getTwig
|
protected function getTwig(\Twig_LoaderInterface $loader)
{
$twig = new \Twig_Environment($loader);
$twig->setCache(false);
return $twig;
}
|
php
|
protected function getTwig(\Twig_LoaderInterface $loader)
{
$twig = new \Twig_Environment($loader);
$twig->setCache(false);
return $twig;
}
|
[
"protected",
"function",
"getTwig",
"(",
"\\",
"Twig_LoaderInterface",
"$",
"loader",
")",
"{",
"$",
"twig",
"=",
"new",
"\\",
"Twig_Environment",
"(",
"$",
"loader",
")",
";",
"$",
"twig",
"->",
"setCache",
"(",
"false",
")",
";",
"return",
"$",
"twig",
";",
"}"
] |
Twig instance factory
@param \Twig_LoaderInterface $loader
@return \Twig_Environment
|
[
"Twig",
"instance",
"factory"
] |
4e83eae67199fc2b9eca9f08dcf59cc0440c385a
|
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L96-L102
|
233,723
|
yarcode/yii2-email-manager
|
src/models/Template.php
|
Template.queue
|
public function queue($to, array $params = [], $priority = 0, $files = [], $bcc = null)
{
$text = nl2br($this->renderAttribute('text', $params));
$subject = $this->renderAttribute('subject', $params);
EmailManager::getInstance()->queue(
$this->from,
$to,
$subject,
$text,
$priority,
$files,
$bcc
);
return true;
}
|
php
|
public function queue($to, array $params = [], $priority = 0, $files = [], $bcc = null)
{
$text = nl2br($this->renderAttribute('text', $params));
$subject = $this->renderAttribute('subject', $params);
EmailManager::getInstance()->queue(
$this->from,
$to,
$subject,
$text,
$priority,
$files,
$bcc
);
return true;
}
|
[
"public",
"function",
"queue",
"(",
"$",
"to",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"priority",
"=",
"0",
",",
"$",
"files",
"=",
"[",
"]",
",",
"$",
"bcc",
"=",
"null",
")",
"{",
"$",
"text",
"=",
"nl2br",
"(",
"$",
"this",
"->",
"renderAttribute",
"(",
"'text'",
",",
"$",
"params",
")",
")",
";",
"$",
"subject",
"=",
"$",
"this",
"->",
"renderAttribute",
"(",
"'subject'",
",",
"$",
"params",
")",
";",
"EmailManager",
"::",
"getInstance",
"(",
")",
"->",
"queue",
"(",
"$",
"this",
"->",
"from",
",",
"$",
"to",
",",
"$",
"subject",
",",
"$",
"text",
",",
"$",
"priority",
",",
"$",
"files",
",",
"$",
"bcc",
")",
";",
"return",
"true",
";",
"}"
] |
Queues current template for sending with the given priority
@param $to
@param array $params
@param int $priority
@param array $files
@param null $bcc
@return bool
@throws \yii\base\InvalidConfigException
|
[
"Queues",
"current",
"template",
"for",
"sending",
"with",
"the",
"given",
"priority"
] |
4e83eae67199fc2b9eca9f08dcf59cc0440c385a
|
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L129-L143
|
233,724
|
yarcode/yii2-email-manager
|
src/models/Template.php
|
Template.renderAttribute
|
public function renderAttribute($attribute, array $params)
{
$twig = $this->getTwig(new EmailTemplateLoader([
'attributeName' => $attribute,
]));
try {
$result = $twig->render($this->shortcut, $params);
} catch (\Exception $e) {
$result = 'Error compiling email ' . $attribute . ': ' . $e->getMessage();
}
return $result;
}
|
php
|
public function renderAttribute($attribute, array $params)
{
$twig = $this->getTwig(new EmailTemplateLoader([
'attributeName' => $attribute,
]));
try {
$result = $twig->render($this->shortcut, $params);
} catch (\Exception $e) {
$result = 'Error compiling email ' . $attribute . ': ' . $e->getMessage();
}
return $result;
}
|
[
"public",
"function",
"renderAttribute",
"(",
"$",
"attribute",
",",
"array",
"$",
"params",
")",
"{",
"$",
"twig",
"=",
"$",
"this",
"->",
"getTwig",
"(",
"new",
"EmailTemplateLoader",
"(",
"[",
"'attributeName'",
"=>",
"$",
"attribute",
",",
"]",
")",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"twig",
"->",
"render",
"(",
"$",
"this",
"->",
"shortcut",
",",
"$",
"params",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"result",
"=",
"'Error compiling email '",
".",
"$",
"attribute",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Renders attribute using twig
@param string $attribute
@param array $params
@return string
|
[
"Renders",
"attribute",
"using",
"twig"
] |
4e83eae67199fc2b9eca9f08dcf59cc0440c385a
|
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L152-L165
|
233,725
|
budde377/Part
|
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
|
GenericObjectTypeHandlerImpl.whitelistType
|
public function whitelistType($type)
{
foreach (func_get_args() as $arg) {
if (!in_array($arg, $this->types)) {
continue;
}
if (isset($this->alias[$arg])) {
call_user_func_array([$this, "whitelistType"], $this->alias[$arg]);
}
$this->typeWhitelist[] = $arg;
}
}
|
php
|
public function whitelistType($type)
{
foreach (func_get_args() as $arg) {
if (!in_array($arg, $this->types)) {
continue;
}
if (isset($this->alias[$arg])) {
call_user_func_array([$this, "whitelistType"], $this->alias[$arg]);
}
$this->typeWhitelist[] = $arg;
}
}
|
[
"public",
"function",
"whitelistType",
"(",
"$",
"type",
")",
"{",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"arg",
",",
"$",
"this",
"->",
"types",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"arg",
"]",
")",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"\"whitelistType\"",
"]",
",",
"$",
"this",
"->",
"alias",
"[",
"$",
"arg",
"]",
")",
";",
"}",
"$",
"this",
"->",
"typeWhitelist",
"[",
"]",
"=",
"$",
"arg",
";",
"}",
"}"
] |
Whitelists a type, if no type is whitelisted; all found types are whitelisted.
@param string $type , ...
|
[
"Whitelists",
"a",
"type",
"if",
"no",
"type",
"is",
"whitelisted",
";",
"all",
"found",
"types",
"are",
"whitelisted",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L227-L240
|
233,726
|
budde377/Part
|
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
|
GenericObjectTypeHandlerImpl.whitelistFunction
|
public function whitelistFunction($type, $functionName)
{
if (isset($this->alias[$type])) {
foreach ($this->alias[$type] as $target) {
call_user_func_array([$this, "whitelistFunction"], array_merge([$target], array_slice(func_get_args(), 1)));
}
return;
}
$first = true;
foreach (func_get_args() as $arg) {
if ($first) {
$first = false;
continue;
}
$this->functionWhitelist[$type][] = $arg;
}
}
|
php
|
public function whitelistFunction($type, $functionName)
{
if (isset($this->alias[$type])) {
foreach ($this->alias[$type] as $target) {
call_user_func_array([$this, "whitelistFunction"], array_merge([$target], array_slice(func_get_args(), 1)));
}
return;
}
$first = true;
foreach (func_get_args() as $arg) {
if ($first) {
$first = false;
continue;
}
$this->functionWhitelist[$type][] = $arg;
}
}
|
[
"public",
"function",
"whitelistFunction",
"(",
"$",
"type",
",",
"$",
"functionName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"type",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"type",
"]",
"as",
"$",
"target",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"\"whitelistFunction\"",
"]",
",",
"array_merge",
"(",
"[",
"$",
"target",
"]",
",",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"1",
")",
")",
")",
";",
"}",
"return",
";",
"}",
"$",
"first",
"=",
"true",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"first",
")",
"{",
"$",
"first",
"=",
"false",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"functionWhitelist",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"arg",
";",
"}",
"}"
] |
Whitelists a function, if no function is whitelisted; all found types are whitelisted.
@param string $type
@param string $functionName , ...
|
[
"Whitelists",
"a",
"function",
"if",
"no",
"function",
"is",
"whitelisted",
";",
"all",
"found",
"types",
"are",
"whitelisted",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L247-L268
|
233,727
|
budde377/Part
|
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
|
GenericObjectTypeHandlerImpl.addAlias
|
public function addAlias($alias, array $target)
{
$this->alias[$alias] = isset($this->alias[$alias]) ? array_merge($this->alias[$alias], $target) : $target;
if (in_array($alias, $this->types)) {
return;
}
$this->types[] = $alias;
}
|
php
|
public function addAlias($alias, array $target)
{
$this->alias[$alias] = isset($this->alias[$alias]) ? array_merge($this->alias[$alias], $target) : $target;
if (in_array($alias, $this->types)) {
return;
}
$this->types[] = $alias;
}
|
[
"public",
"function",
"addAlias",
"(",
"$",
"alias",
",",
"array",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"alias",
"[",
"$",
"alias",
"]",
"=",
"isset",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"alias",
"]",
")",
"?",
"array_merge",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"alias",
"]",
",",
"$",
"target",
")",
":",
"$",
"target",
";",
"if",
"(",
"in_array",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"types",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"types",
"[",
"]",
"=",
"$",
"alias",
";",
"}"
] |
Adds an alias.
If the alias already exists the types are merged.
@param string $alias
@param array $target
|
[
"Adds",
"an",
"alias",
".",
"If",
"the",
"alias",
"already",
"exists",
"the",
"types",
"are",
"merged",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L602-L611
|
233,728
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Controllers/AdminController.php
|
AdminController.index
|
public function index()
{
return View::make('core::admin.index')
->with('users', $this->users->all())
->with('user', $this->auth->user())
->with('locale', $this->loadLanguage());
}
|
php
|
public function index()
{
return View::make('core::admin.index')
->with('users', $this->users->all())
->with('user', $this->auth->user())
->with('locale', $this->loadLanguage());
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"return",
"View",
"::",
"make",
"(",
"'core::admin.index'",
")",
"->",
"with",
"(",
"'users'",
",",
"$",
"this",
"->",
"users",
"->",
"all",
"(",
")",
")",
"->",
"with",
"(",
"'user'",
",",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
")",
"->",
"with",
"(",
"'locale'",
",",
"$",
"this",
"->",
"loadLanguage",
"(",
")",
")",
";",
"}"
] |
Get the main admin view.
|
[
"Get",
"the",
"main",
"admin",
"view",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/AdminController.php#L35-L41
|
233,729
|
budde377/Part
|
lib/model/page/PageOrderImpl.php
|
PageOrderImpl.getPageOrder
|
public function getPageOrder(Page $parentPage = null)
{
if ($parentPage instanceof Page) {
$parentPageString = $parentPage->getID();
} else {
$parentPageString = '';
}
if (!isset($this->pageOrder[$parentPageString])) {
return [];
}
$retArray = [];
foreach ($this->pageOrder[$parentPageString] as $id) {
$retArray[] = $this->activePages[$id];
}
return $retArray;
}
|
php
|
public function getPageOrder(Page $parentPage = null)
{
if ($parentPage instanceof Page) {
$parentPageString = $parentPage->getID();
} else {
$parentPageString = '';
}
if (!isset($this->pageOrder[$parentPageString])) {
return [];
}
$retArray = [];
foreach ($this->pageOrder[$parentPageString] as $id) {
$retArray[] = $this->activePages[$id];
}
return $retArray;
}
|
[
"public",
"function",
"getPageOrder",
"(",
"Page",
"$",
"parentPage",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parentPage",
"instanceof",
"Page",
")",
"{",
"$",
"parentPageString",
"=",
"$",
"parentPage",
"->",
"getID",
"(",
")",
";",
"}",
"else",
"{",
"$",
"parentPageString",
"=",
"''",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"pageOrder",
"[",
"$",
"parentPageString",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"retArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"pageOrder",
"[",
"$",
"parentPageString",
"]",
"as",
"$",
"id",
")",
"{",
"$",
"retArray",
"[",
"]",
"=",
"$",
"this",
"->",
"activePages",
"[",
"$",
"id",
"]",
";",
"}",
"return",
"$",
"retArray",
";",
"}"
] |
This will return pageOrder. If null is given, it will return top-level
order, else if valid page id is given, it will return the order of the
sub-list. The return array will, if non-empty, contain instances of Page
If invalid id is provided, it will return empty array
@param null|Page $parentPage
@throws MalformedParameterException
@return array
|
[
"This",
"will",
"return",
"pageOrder",
".",
"If",
"null",
"is",
"given",
"it",
"will",
"return",
"top",
"-",
"level",
"order",
"else",
"if",
"valid",
"page",
"id",
"is",
"given",
"it",
"will",
"return",
"the",
"order",
"of",
"the",
"sub",
"-",
"list",
".",
"The",
"return",
"array",
"will",
"if",
"non",
"-",
"empty",
"contain",
"instances",
"of",
"Page",
"If",
"invalid",
"id",
"is",
"provided",
"it",
"will",
"return",
"empty",
"array"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L86-L103
|
233,730
|
budde377/Part
|
lib/model/page/PageOrderImpl.php
|
PageOrderImpl.listPages
|
public function listPages($listMode = PageOrder::LIST_ALL)
{
$retArray = array();
if ($listMode == PageOrder::LIST_INACTIVE || $listMode == PageOrder::LIST_ALL) {
foreach ($this->inactivePages as $page) {
$retArray[] = $page;
}
}
if ($listMode == PageOrder::LIST_ALL || $listMode == PageOrder::LIST_ACTIVE) {
foreach ($this->activePages as $page) {
$retArray[] = $page;
}
}
return $retArray;
}
|
php
|
public function listPages($listMode = PageOrder::LIST_ALL)
{
$retArray = array();
if ($listMode == PageOrder::LIST_INACTIVE || $listMode == PageOrder::LIST_ALL) {
foreach ($this->inactivePages as $page) {
$retArray[] = $page;
}
}
if ($listMode == PageOrder::LIST_ALL || $listMode == PageOrder::LIST_ACTIVE) {
foreach ($this->activePages as $page) {
$retArray[] = $page;
}
}
return $retArray;
}
|
[
"public",
"function",
"listPages",
"(",
"$",
"listMode",
"=",
"PageOrder",
"::",
"LIST_ALL",
")",
"{",
"$",
"retArray",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"listMode",
"==",
"PageOrder",
"::",
"LIST_INACTIVE",
"||",
"$",
"listMode",
"==",
"PageOrder",
"::",
"LIST_ALL",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"inactivePages",
"as",
"$",
"page",
")",
"{",
"$",
"retArray",
"[",
"]",
"=",
"$",
"page",
";",
"}",
"}",
"if",
"(",
"$",
"listMode",
"==",
"PageOrder",
"::",
"LIST_ALL",
"||",
"$",
"listMode",
"==",
"PageOrder",
"::",
"LIST_ACTIVE",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"activePages",
"as",
"$",
"page",
")",
"{",
"$",
"retArray",
"[",
"]",
"=",
"$",
"page",
";",
"}",
"}",
"return",
"$",
"retArray",
";",
"}"
] |
Will list all pages in an array as instances of Page
@param int $listMode Must be of ListPageEnum
@return array
|
[
"Will",
"list",
"all",
"pages",
"in",
"an",
"array",
"as",
"instances",
"of",
"Page"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L163-L179
|
233,731
|
budde377/Part
|
lib/model/page/PageOrderImpl.php
|
PageOrderImpl.deactivatePage
|
public function deactivatePage(Page $page)
{
if (!$this->isActive($page)) {
return;
}
$this->deactivatePageId($page->getID());
}
|
php
|
public function deactivatePage(Page $page)
{
if (!$this->isActive($page)) {
return;
}
$this->deactivatePageId($page->getID());
}
|
[
"public",
"function",
"deactivatePage",
"(",
"Page",
"$",
"page",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isActive",
"(",
"$",
"page",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"deactivatePageId",
"(",
"$",
"page",
"->",
"getID",
"(",
")",
")",
";",
"}"
] |
Will deactivate a page and all it's sub pages.
The page order remains the same
@param Page $page
@return void
|
[
"Will",
"deactivate",
"a",
"page",
"and",
"all",
"it",
"s",
"sub",
"pages",
".",
"The",
"page",
"order",
"remains",
"the",
"same"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L223-L232
|
233,732
|
budde377/Part
|
lib/model/page/PageOrderImpl.php
|
PageOrderImpl.deletePage
|
public function deletePage(Page $page)
{
$findPage = $this->findPage($page);
if ($findPage === false) {
return false;
}
$deleteStm = $this->connection->prepare("DELETE FROM Page WHERE page_id=?");
$deleteStm->execute([$page->getID()]);
if (!$deleteStm->rowCount() > 0) {
return false;
}
if ($findPage == 'active') {
unset($this->activePages[$page->getID()]);
} else {
unset($this->inactivePages[$page->getID()]);
}
return true;
}
|
php
|
public function deletePage(Page $page)
{
$findPage = $this->findPage($page);
if ($findPage === false) {
return false;
}
$deleteStm = $this->connection->prepare("DELETE FROM Page WHERE page_id=?");
$deleteStm->execute([$page->getID()]);
if (!$deleteStm->rowCount() > 0) {
return false;
}
if ($findPage == 'active') {
unset($this->activePages[$page->getID()]);
} else {
unset($this->inactivePages[$page->getID()]);
}
return true;
}
|
[
"public",
"function",
"deletePage",
"(",
"Page",
"$",
"page",
")",
"{",
"$",
"findPage",
"=",
"$",
"this",
"->",
"findPage",
"(",
"$",
"page",
")",
";",
"if",
"(",
"$",
"findPage",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"deleteStm",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"DELETE FROM Page WHERE page_id=?\"",
")",
";",
"$",
"deleteStm",
"->",
"execute",
"(",
"[",
"$",
"page",
"->",
"getID",
"(",
")",
"]",
")",
";",
"if",
"(",
"!",
"$",
"deleteStm",
"->",
"rowCount",
"(",
")",
">",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"findPage",
"==",
"'active'",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"activePages",
"[",
"$",
"page",
"->",
"getID",
"(",
")",
"]",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"inactivePages",
"[",
"$",
"page",
"->",
"getID",
"(",
")",
"]",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
This will delete a page from page order and in general
@param Page $page
@return bool
|
[
"This",
"will",
"delete",
"a",
"page",
"from",
"page",
"order",
"and",
"in",
"general"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L262-L281
|
233,733
|
budde377/Part
|
lib/model/page/PageOrderImpl.php
|
PageOrderImpl.getPagePath
|
public function getPagePath(Page $page)
{
if (($status = $this->findPage($page)) == 'inactive') {
return array();
} else if ($status === false) {
return false;
}
return $this->recursiveCalculatePath($page);
}
|
php
|
public function getPagePath(Page $page)
{
if (($status = $this->findPage($page)) == 'inactive') {
return array();
} else if ($status === false) {
return false;
}
return $this->recursiveCalculatePath($page);
}
|
[
"public",
"function",
"getPagePath",
"(",
"Page",
"$",
"page",
")",
"{",
"if",
"(",
"(",
"$",
"status",
"=",
"$",
"this",
"->",
"findPage",
"(",
"$",
"page",
")",
")",
"==",
"'inactive'",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"recursiveCalculatePath",
"(",
"$",
"page",
")",
";",
"}"
] |
Will return the path of an page as an array.
If the page is at top level an array containing an single entrance will be returned
Else a numeric array with the top level as first entrance, and lowest level as last entrance
will be returned.
If a page is inactive, an empty array will be returned.
If a page is not found, FALSE will be returned.
@param Page $page
@return bool | array
|
[
"Will",
"return",
"the",
"path",
"of",
"an",
"page",
"as",
"an",
"array",
".",
"If",
"the",
"page",
"is",
"at",
"top",
"level",
"an",
"array",
"containing",
"an",
"single",
"entrance",
"will",
"be",
"returned",
"Else",
"a",
"numeric",
"array",
"with",
"the",
"top",
"level",
"as",
"first",
"entrance",
"and",
"lowest",
"level",
"as",
"last",
"entrance",
"will",
"be",
"returned",
".",
"If",
"a",
"page",
"is",
"inactive",
"an",
"empty",
"array",
"will",
"be",
"returned",
".",
"If",
"a",
"page",
"is",
"not",
"found",
"FALSE",
"will",
"be",
"returned",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L377-L386
|
233,734
|
meare/juggler
|
src/HttpClient/GuzzleClient.php
|
GuzzleClient.convertToMountebankException
|
private function convertToMountebankException(ClientException $e)
{
return $this->exceptionFactory->createInstanceFromMountebankResponse(
(string)$e->getResponse()->getBody()
);
}
|
php
|
private function convertToMountebankException(ClientException $e)
{
return $this->exceptionFactory->createInstanceFromMountebankResponse(
(string)$e->getResponse()->getBody()
);
}
|
[
"private",
"function",
"convertToMountebankException",
"(",
"ClientException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"exceptionFactory",
"->",
"createInstanceFromMountebankResponse",
"(",
"(",
"string",
")",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
")",
")",
";",
"}"
] |
Creates MountebankException instance from mountebank response
@param ClientException $e
@return MountebankException
|
[
"Creates",
"MountebankException",
"instance",
"from",
"mountebank",
"response"
] |
11ec398c16e01c986679f53f8ece2c1e97ba4e29
|
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/HttpClient/GuzzleClient.php#L114-L119
|
233,735
|
meare/juggler
|
src/Exception/MountebankExceptionFactory.php
|
MountebankExceptionFactory.createInstanceFromMountebankResponse
|
public function createInstanceFromMountebankResponse($response_body)
{
$errors = \GuzzleHttp\json_decode($response_body, true)['errors'];
$first_error = reset($errors);
return $this->createInstance(
$first_error['code'],
$first_error['message'],
isset($first_error['source']) ? $first_error['source'] : null,
isset($first_error['data']) ? $first_error['data'] : null
);
}
|
php
|
public function createInstanceFromMountebankResponse($response_body)
{
$errors = \GuzzleHttp\json_decode($response_body, true)['errors'];
$first_error = reset($errors);
return $this->createInstance(
$first_error['code'],
$first_error['message'],
isset($first_error['source']) ? $first_error['source'] : null,
isset($first_error['data']) ? $first_error['data'] : null
);
}
|
[
"public",
"function",
"createInstanceFromMountebankResponse",
"(",
"$",
"response_body",
")",
"{",
"$",
"errors",
"=",
"\\",
"GuzzleHttp",
"\\",
"json_decode",
"(",
"$",
"response_body",
",",
"true",
")",
"[",
"'errors'",
"]",
";",
"$",
"first_error",
"=",
"reset",
"(",
"$",
"errors",
")",
";",
"return",
"$",
"this",
"->",
"createInstance",
"(",
"$",
"first_error",
"[",
"'code'",
"]",
",",
"$",
"first_error",
"[",
"'message'",
"]",
",",
"isset",
"(",
"$",
"first_error",
"[",
"'source'",
"]",
")",
"?",
"$",
"first_error",
"[",
"'source'",
"]",
":",
"null",
",",
"isset",
"(",
"$",
"first_error",
"[",
"'data'",
"]",
")",
"?",
"$",
"first_error",
"[",
"'data'",
"]",
":",
"null",
")",
";",
"}"
] |
Takes first error from mountebank response and wraps it into according MountebankException
@param string $response_body
@return MountebankException
|
[
"Takes",
"first",
"error",
"from",
"mountebank",
"response",
"and",
"wraps",
"it",
"into",
"according",
"MountebankException"
] |
11ec398c16e01c986679f53f8ece2c1e97ba4e29
|
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Exception/MountebankExceptionFactory.php#L37-L48
|
233,736
|
baleen/migrations
|
src/Delta/Comparator/ReversedComparator.php
|
ReversedComparator.compare
|
public function compare(DeltaInterface $version1, DeltaInterface $version2)
{
return $this->internalComparator->compare($version1, $version2) * -1;
}
|
php
|
public function compare(DeltaInterface $version1, DeltaInterface $version2)
{
return $this->internalComparator->compare($version1, $version2) * -1;
}
|
[
"public",
"function",
"compare",
"(",
"DeltaInterface",
"$",
"version1",
",",
"DeltaInterface",
"$",
"version2",
")",
"{",
"return",
"$",
"this",
"->",
"internalComparator",
"->",
"compare",
"(",
"$",
"version1",
",",
"$",
"version2",
")",
"*",
"-",
"1",
";",
"}"
] |
Compares two versions with each other using the internal comparator, and returns the opposite result.
@param DeltaInterface $version1
@param DeltaInterface $version2
@return int
|
[
"Compares",
"two",
"versions",
"with",
"each",
"other",
"using",
"the",
"internal",
"comparator",
"and",
"returns",
"the",
"opposite",
"result",
"."
] |
cfc8c439858cf4f0d4119af9eb67de493da8d95c
|
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Comparator/ReversedComparator.php#L52-L55
|
233,737
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.containsFile
|
public function containsFile(File $file)
{
if(!$file->exists()){
return false;
}
$p1 = $this->filesDir->getAbsolutePath();
$p2 = $file->getParentFolder()->getParentFolder()->getAbsolutePath();
return $p1 == $p2;
}
|
php
|
public function containsFile(File $file)
{
if(!$file->exists()){
return false;
}
$p1 = $this->filesDir->getAbsolutePath();
$p2 = $file->getParentFolder()->getParentFolder()->getAbsolutePath();
return $p1 == $p2;
}
|
[
"public",
"function",
"containsFile",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"file",
"->",
"exists",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"p1",
"=",
"$",
"this",
"->",
"filesDir",
"->",
"getAbsolutePath",
"(",
")",
";",
"$",
"p2",
"=",
"$",
"file",
"->",
"getParentFolder",
"(",
")",
"->",
"getParentFolder",
"(",
")",
"->",
"getAbsolutePath",
"(",
")",
";",
"return",
"$",
"p1",
"==",
"$",
"p2",
";",
"}"
] |
Check if file is in library
@param File $file
@return bool TRUE if contained in library else FASLE
|
[
"Check",
"if",
"file",
"is",
"in",
"library"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L37-L45
|
233,738
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.removeFromWhitelist
|
public function removeFromWhitelist(File $file)
{
if(!$this->whitelistContainsFile($file)){
return false;
}
if(($key = array_search($this->filePath($file), $this->whiteList)) !== false) {
unset($this->whiteList[$key]);
}
$this->writeWhitelist();
return !$this->whitelistContainsFile($file);
}
|
php
|
public function removeFromWhitelist(File $file)
{
if(!$this->whitelistContainsFile($file)){
return false;
}
if(($key = array_search($this->filePath($file), $this->whiteList)) !== false) {
unset($this->whiteList[$key]);
}
$this->writeWhitelist();
return !$this->whitelistContainsFile($file);
}
|
[
"public",
"function",
"removeFromWhitelist",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"whitelistContainsFile",
"(",
"$",
"file",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"$",
"key",
"=",
"array_search",
"(",
"$",
"this",
"->",
"filePath",
"(",
"$",
"file",
")",
",",
"$",
"this",
"->",
"whiteList",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"whiteList",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"this",
"->",
"writeWhitelist",
"(",
")",
";",
"return",
"!",
"$",
"this",
"->",
"whitelistContainsFile",
"(",
"$",
"file",
")",
";",
"}"
] |
Remove a file from the whitelist
@param File $file
@return boolean TRUE on success else FALSE
|
[
"Remove",
"a",
"file",
"from",
"the",
"whitelist"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L110-L121
|
233,739
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.addToLibrary
|
public function addToLibrary(User $user, File $file)
{
$folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId());
$ext = $file->getExtension() == ""?"":".".$file->getExtension();
$name = str_replace(".", "", uniqid("",true)).$ext;
return $this->addToLibraryHelper($folder, $file, $name);
}
|
php
|
public function addToLibrary(User $user, File $file)
{
$folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId());
$ext = $file->getExtension() == ""?"":".".$file->getExtension();
$name = str_replace(".", "", uniqid("",true)).$ext;
return $this->addToLibraryHelper($folder, $file, $name);
}
|
[
"public",
"function",
"addToLibrary",
"(",
"User",
"$",
"user",
",",
"File",
"$",
"file",
")",
"{",
"$",
"folder",
"=",
"new",
"FolderImpl",
"(",
"$",
"this",
"->",
"filesDir",
"->",
"getAbsolutePath",
"(",
")",
".",
"\"/\"",
".",
"$",
"user",
"->",
"getUniqueId",
"(",
")",
")",
";",
"$",
"ext",
"=",
"$",
"file",
"->",
"getExtension",
"(",
")",
"==",
"\"\"",
"?",
"\"\"",
":",
"\".\"",
".",
"$",
"file",
"->",
"getExtension",
"(",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"\"",
",",
"uniqid",
"(",
"\"\"",
",",
"true",
")",
")",
".",
"$",
"ext",
";",
"return",
"$",
"this",
"->",
"addToLibraryHelper",
"(",
"$",
"folder",
",",
"$",
"file",
",",
"$",
"name",
")",
";",
"}"
] |
This will copy the file given to a implementation specific location.
@param \ChristianBudde\Part\model\user\User $user The uploading user
@param File $file The file to be uploaded.
@return File The location of the new file
|
[
"This",
"will",
"copy",
"the",
"file",
"given",
"to",
"a",
"implementation",
"specific",
"location",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L133-L139
|
233,740
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.cleanLibrary
|
public function cleanLibrary(User $user = null)
{
foreach($this->getFileList($user) as $file){
/** @var $file File */
if(!$this->whitelistContainsFile($file)){
/** @var $vf File */
foreach($this->listVersionsToOriginal($file) as $vf){
$vf->delete();
}
$file->delete();
}
}
}
|
php
|
public function cleanLibrary(User $user = null)
{
foreach($this->getFileList($user) as $file){
/** @var $file File */
if(!$this->whitelistContainsFile($file)){
/** @var $vf File */
foreach($this->listVersionsToOriginal($file) as $vf){
$vf->delete();
}
$file->delete();
}
}
}
|
[
"public",
"function",
"cleanLibrary",
"(",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFileList",
"(",
"$",
"user",
")",
"as",
"$",
"file",
")",
"{",
"/** @var $file File */",
"if",
"(",
"!",
"$",
"this",
"->",
"whitelistContainsFile",
"(",
"$",
"file",
")",
")",
"{",
"/** @var $vf File */",
"foreach",
"(",
"$",
"this",
"->",
"listVersionsToOriginal",
"(",
"$",
"file",
")",
"as",
"$",
"vf",
")",
"{",
"$",
"vf",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"file",
"->",
"delete",
"(",
")",
";",
"}",
"}",
"}"
] |
This will clean the library from any file not present in the white-list
If the user argument is not null, only files uploaded by this user will be subject
to cleaning, else the whole library is checked.
@param \ChristianBudde\Part\model\user\User $user
@return bool TRUE on success else FALSE
|
[
"This",
"will",
"clean",
"the",
"library",
"from",
"any",
"file",
"not",
"present",
"in",
"the",
"white",
"-",
"list",
"If",
"the",
"user",
"argument",
"is",
"not",
"null",
"only",
"files",
"uploaded",
"by",
"this",
"user",
"will",
"be",
"subject",
"to",
"cleaning",
"else",
"the",
"whole",
"library",
"is",
"checked",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L159-L171
|
233,741
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.removeFromLibrary
|
public function removeFromLibrary(File $file)
{
if(!$this->containsFile($file)){
return false;
}
if($this->whitelistContainsFile($file)){
$this->removeFromWhitelist($file);
}
$file->delete();
return !$this->containsFile($file);
}
|
php
|
public function removeFromLibrary(File $file)
{
if(!$this->containsFile($file)){
return false;
}
if($this->whitelistContainsFile($file)){
$this->removeFromWhitelist($file);
}
$file->delete();
return !$this->containsFile($file);
}
|
[
"public",
"function",
"removeFromLibrary",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"containsFile",
"(",
"$",
"file",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"whitelistContainsFile",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"removeFromWhitelist",
"(",
"$",
"file",
")",
";",
"}",
"$",
"file",
"->",
"delete",
"(",
")",
";",
"return",
"!",
"$",
"this",
"->",
"containsFile",
"(",
"$",
"file",
")",
";",
"}"
] |
Will remove a file from library.
@param File $file
@return bool TRUE on success else FALSE
|
[
"Will",
"remove",
"a",
"file",
"from",
"library",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L201-L211
|
233,742
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.findOriginalFileToVersion
|
public function findOriginalFileToVersion(File $file)
{
if(!$this->containsFile($file)){
return null;
}
preg_match("/([^-]+)(-.*)?/", $file->getBasename(), $matches);
$ext = $file->getExtension() == ""?"":".".$file->getExtension();
return new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$matches[1].$ext);
}
|
php
|
public function findOriginalFileToVersion(File $file)
{
if(!$this->containsFile($file)){
return null;
}
preg_match("/([^-]+)(-.*)?/", $file->getBasename(), $matches);
$ext = $file->getExtension() == ""?"":".".$file->getExtension();
return new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$matches[1].$ext);
}
|
[
"public",
"function",
"findOriginalFileToVersion",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"containsFile",
"(",
"$",
"file",
")",
")",
"{",
"return",
"null",
";",
"}",
"preg_match",
"(",
"\"/([^-]+)(-.*)?/\"",
",",
"$",
"file",
"->",
"getBasename",
"(",
")",
",",
"$",
"matches",
")",
";",
"$",
"ext",
"=",
"$",
"file",
"->",
"getExtension",
"(",
")",
"==",
"\"\"",
"?",
"\"\"",
":",
"\".\"",
".",
"$",
"file",
"->",
"getExtension",
"(",
")",
";",
"return",
"new",
"FileImpl",
"(",
"$",
"file",
"->",
"getParentFolder",
"(",
")",
"->",
"getAbsolutePath",
"(",
")",
".",
"\"/\"",
".",
"$",
"matches",
"[",
"1",
"]",
".",
"$",
"ext",
")",
";",
"}"
] |
Given a version file this will return the original.
If the given file isn't in the library, null will be returned.
If the given file isn't a version of a file, null will be returned.
@param File $file
@return File
|
[
"Given",
"a",
"version",
"file",
"this",
"will",
"return",
"the",
"original",
".",
"If",
"the",
"given",
"file",
"isn",
"t",
"in",
"the",
"library",
"null",
"will",
"be",
"returned",
".",
"If",
"the",
"given",
"file",
"isn",
"t",
"a",
"version",
"of",
"a",
"file",
"null",
"will",
"be",
"returned",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L256-L265
|
233,743
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.listVersionsToOriginal
|
public function listVersionsToOriginal(File $file)
{
if(!$this->containsFile($file)){
return array();
}
if($this->isVersion($file)){
return array();
}
return array_filter($file->getParentFolder()->listFolder(Folder::LIST_FOLDER_FILES), function(File $f) use ($file){
return $this->isVersion($f) && strpos($f->getBasename(), $file->getBasename()) === 0;
});
}
|
php
|
public function listVersionsToOriginal(File $file)
{
if(!$this->containsFile($file)){
return array();
}
if($this->isVersion($file)){
return array();
}
return array_filter($file->getParentFolder()->listFolder(Folder::LIST_FOLDER_FILES), function(File $f) use ($file){
return $this->isVersion($f) && strpos($f->getBasename(), $file->getBasename()) === 0;
});
}
|
[
"public",
"function",
"listVersionsToOriginal",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"containsFile",
"(",
"$",
"file",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"$",
"file",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"array_filter",
"(",
"$",
"file",
"->",
"getParentFolder",
"(",
")",
"->",
"listFolder",
"(",
"Folder",
"::",
"LIST_FOLDER_FILES",
")",
",",
"function",
"(",
"File",
"$",
"f",
")",
"use",
"(",
"$",
"file",
")",
"{",
"return",
"$",
"this",
"->",
"isVersion",
"(",
"$",
"f",
")",
"&&",
"strpos",
"(",
"$",
"f",
"->",
"getBasename",
"(",
")",
",",
"$",
"file",
"->",
"getBasename",
"(",
")",
")",
"===",
"0",
";",
"}",
")",
";",
"}"
] |
Will list the versions of a given file.
@param File $file
@return array
|
[
"Will",
"list",
"the",
"versions",
"of",
"a",
"given",
"file",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L272-L285
|
233,744
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.containsVersionOfFile
|
public function containsVersionOfFile($file, $version)
{
$f = $this->findVersionOfFile($file, $version);
return $f != null;
}
|
php
|
public function containsVersionOfFile($file, $version)
{
$f = $this->findVersionOfFile($file, $version);
return $f != null;
}
|
[
"public",
"function",
"containsVersionOfFile",
"(",
"$",
"file",
",",
"$",
"version",
")",
"{",
"$",
"f",
"=",
"$",
"this",
"->",
"findVersionOfFile",
"(",
"$",
"file",
",",
"$",
"version",
")",
";",
"return",
"$",
"f",
"!=",
"null",
";",
"}"
] |
Will check if a version of the given file already exists.
@param File $file
@param string $version
@return bool
|
[
"Will",
"check",
"if",
"a",
"version",
"of",
"the",
"given",
"file",
"already",
"exists",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L314-L318
|
233,745
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.findVersionOfFile
|
public function findVersionOfFile($file, $version)
{
if($file == null || ($f2 = $this->findOriginalFileToVersion($file)) == null ||
$file->getAbsoluteFilePath() != $f2->getAbsoluteFilePath()){
return null;
}
$name = $this->versionFileName($file, $version);
$f = new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$name);
return $this->containsFile($f)?$f:null;
}
|
php
|
public function findVersionOfFile($file, $version)
{
if($file == null || ($f2 = $this->findOriginalFileToVersion($file)) == null ||
$file->getAbsoluteFilePath() != $f2->getAbsoluteFilePath()){
return null;
}
$name = $this->versionFileName($file, $version);
$f = new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$name);
return $this->containsFile($f)?$f:null;
}
|
[
"public",
"function",
"findVersionOfFile",
"(",
"$",
"file",
",",
"$",
"version",
")",
"{",
"if",
"(",
"$",
"file",
"==",
"null",
"||",
"(",
"$",
"f2",
"=",
"$",
"this",
"->",
"findOriginalFileToVersion",
"(",
"$",
"file",
")",
")",
"==",
"null",
"||",
"$",
"file",
"->",
"getAbsoluteFilePath",
"(",
")",
"!=",
"$",
"f2",
"->",
"getAbsoluteFilePath",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"versionFileName",
"(",
"$",
"file",
",",
"$",
"version",
")",
";",
"$",
"f",
"=",
"new",
"FileImpl",
"(",
"$",
"file",
"->",
"getParentFolder",
"(",
")",
"->",
"getAbsolutePath",
"(",
")",
".",
"\"/\"",
".",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"containsFile",
"(",
"$",
"f",
")",
"?",
"$",
"f",
":",
"null",
";",
"}"
] |
This will return the desired version of the file, if it exists, else null.
@param File $file
@param string $version
@return File
|
[
"This",
"will",
"return",
"the",
"desired",
"version",
"of",
"the",
"file",
"if",
"it",
"exists",
"else",
"null",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L326-L335
|
233,746
|
budde377/Part
|
lib/util/file/FileLibraryImpl.php
|
FileLibraryImpl.uploadToLibrary
|
public function uploadToLibrary(User $user, array $fileArray)
{
$nameFile = new FileImpl(isset($fileArray['name'])?$fileArray['name']:$fileArray['tmp_name']);
$file = new FileImpl($fileArray['tmp_name']);
$folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId());
$ext = $nameFile->getExtension() == ""?"":".".$nameFile->getExtension();
$name = str_replace(".", "", uniqid("",true)).$ext;
if(!$this->filesDir->exists()){
$this->filesDir->create();
}
if(!$folder->exists()){
$folder->create();
}
$f = new FileImpl($folder->getAbsolutePath().'/'.$name);
move_uploaded_file($file->getAbsoluteFilePath(),$f->getAbsoluteFilePath());
return $f;
}
|
php
|
public function uploadToLibrary(User $user, array $fileArray)
{
$nameFile = new FileImpl(isset($fileArray['name'])?$fileArray['name']:$fileArray['tmp_name']);
$file = new FileImpl($fileArray['tmp_name']);
$folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId());
$ext = $nameFile->getExtension() == ""?"":".".$nameFile->getExtension();
$name = str_replace(".", "", uniqid("",true)).$ext;
if(!$this->filesDir->exists()){
$this->filesDir->create();
}
if(!$folder->exists()){
$folder->create();
}
$f = new FileImpl($folder->getAbsolutePath().'/'.$name);
move_uploaded_file($file->getAbsoluteFilePath(),$f->getAbsoluteFilePath());
return $f;
}
|
[
"public",
"function",
"uploadToLibrary",
"(",
"User",
"$",
"user",
",",
"array",
"$",
"fileArray",
")",
"{",
"$",
"nameFile",
"=",
"new",
"FileImpl",
"(",
"isset",
"(",
"$",
"fileArray",
"[",
"'name'",
"]",
")",
"?",
"$",
"fileArray",
"[",
"'name'",
"]",
":",
"$",
"fileArray",
"[",
"'tmp_name'",
"]",
")",
";",
"$",
"file",
"=",
"new",
"FileImpl",
"(",
"$",
"fileArray",
"[",
"'tmp_name'",
"]",
")",
";",
"$",
"folder",
"=",
"new",
"FolderImpl",
"(",
"$",
"this",
"->",
"filesDir",
"->",
"getAbsolutePath",
"(",
")",
".",
"\"/\"",
".",
"$",
"user",
"->",
"getUniqueId",
"(",
")",
")",
";",
"$",
"ext",
"=",
"$",
"nameFile",
"->",
"getExtension",
"(",
")",
"==",
"\"\"",
"?",
"\"\"",
":",
"\".\"",
".",
"$",
"nameFile",
"->",
"getExtension",
"(",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"\"",
",",
"uniqid",
"(",
"\"\"",
",",
"true",
")",
")",
".",
"$",
"ext",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"filesDir",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"filesDir",
"->",
"create",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"folder",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"folder",
"->",
"create",
"(",
")",
";",
"}",
"$",
"f",
"=",
"new",
"FileImpl",
"(",
"$",
"folder",
"->",
"getAbsolutePath",
"(",
")",
".",
"'/'",
".",
"$",
"name",
")",
";",
"move_uploaded_file",
"(",
"$",
"file",
"->",
"getAbsoluteFilePath",
"(",
")",
",",
"$",
"f",
"->",
"getAbsoluteFilePath",
"(",
")",
")",
";",
"return",
"$",
"f",
";",
"}"
] |
Will move a file to the library. It will use move_upload_file
function.
@param \ChristianBudde\Part\model\user\User $user The uploading user
@param array $fileArray The file array to be added
@return File Will return newly added file
|
[
"Will",
"move",
"a",
"file",
"to",
"the",
"library",
".",
"It",
"will",
"use",
"move_upload_file",
"function",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L353-L370
|
233,747
|
kaliop-uk/kueueingbundle
|
Command/ConsumerCommand.php
|
ConsumerCommand.initConsumer
|
protected function initConsumer($input) {
// set up signal handlers first, in case something goes on during consumer constructor
$handleSignals = extension_loaded('pcntl') && (!$input->getOption('without-signals'));
if ($handleSignals && !function_exists('pcntl_signal')) {
throw new \BadFunctionCallException("Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called.");
}
if ($handleSignals && !function_exists('pcntl_signal_dispatch')) {
throw new \BadFunctionCallException("Function 'pcntl_signal_dispatch' is referenced in the php.ini 'disable_functions' and can't be called.");
}
if ($handleSignals) {
pcntl_signal(SIGTERM, array($this, 'haltConsumer'));
pcntl_signal(SIGINT, array($this, 'haltConsumer'));
pcntl_signal(SIGHUP, array($this, 'restartConsumer'));
}
$this->consumer = $this->driver->getConsumer($input->getArgument('name'));
if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) {
$this->consumer->setMemoryLimit($input->getOption('memory-limit'));
}
if (($routingKey = $input->getOption('route')) !== '') {
$this->consumer->setRoutingKey($routingKey);
}
if (self::$label != '' && is_callable(array($this->consumer, 'setLabel'))) {
$this->consumer->setLabel(self::$label);
}
if ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) {
$this->consumer->setHandleSignals($handleSignals);
}
}
|
php
|
protected function initConsumer($input) {
// set up signal handlers first, in case something goes on during consumer constructor
$handleSignals = extension_loaded('pcntl') && (!$input->getOption('without-signals'));
if ($handleSignals && !function_exists('pcntl_signal')) {
throw new \BadFunctionCallException("Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called.");
}
if ($handleSignals && !function_exists('pcntl_signal_dispatch')) {
throw new \BadFunctionCallException("Function 'pcntl_signal_dispatch' is referenced in the php.ini 'disable_functions' and can't be called.");
}
if ($handleSignals) {
pcntl_signal(SIGTERM, array($this, 'haltConsumer'));
pcntl_signal(SIGINT, array($this, 'haltConsumer'));
pcntl_signal(SIGHUP, array($this, 'restartConsumer'));
}
$this->consumer = $this->driver->getConsumer($input->getArgument('name'));
if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) {
$this->consumer->setMemoryLimit($input->getOption('memory-limit'));
}
if (($routingKey = $input->getOption('route')) !== '') {
$this->consumer->setRoutingKey($routingKey);
}
if (self::$label != '' && is_callable(array($this->consumer, 'setLabel'))) {
$this->consumer->setLabel(self::$label);
}
if ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) {
$this->consumer->setHandleSignals($handleSignals);
}
}
|
[
"protected",
"function",
"initConsumer",
"(",
"$",
"input",
")",
"{",
"// set up signal handlers first, in case something goes on during consumer constructor",
"$",
"handleSignals",
"=",
"extension_loaded",
"(",
"'pcntl'",
")",
"&&",
"(",
"!",
"$",
"input",
"->",
"getOption",
"(",
"'without-signals'",
")",
")",
";",
"if",
"(",
"$",
"handleSignals",
"&&",
"!",
"function_exists",
"(",
"'pcntl_signal'",
")",
")",
"{",
"throw",
"new",
"\\",
"BadFunctionCallException",
"(",
"\"Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called.\"",
")",
";",
"}",
"if",
"(",
"$",
"handleSignals",
"&&",
"!",
"function_exists",
"(",
"'pcntl_signal_dispatch'",
")",
")",
"{",
"throw",
"new",
"\\",
"BadFunctionCallException",
"(",
"\"Function 'pcntl_signal_dispatch' is referenced in the php.ini 'disable_functions' and can't be called.\"",
")",
";",
"}",
"if",
"(",
"$",
"handleSignals",
")",
"{",
"pcntl_signal",
"(",
"SIGTERM",
",",
"array",
"(",
"$",
"this",
",",
"'haltConsumer'",
")",
")",
";",
"pcntl_signal",
"(",
"SIGINT",
",",
"array",
"(",
"$",
"this",
",",
"'haltConsumer'",
")",
")",
";",
"pcntl_signal",
"(",
"SIGHUP",
",",
"array",
"(",
"$",
"this",
",",
"'restartConsumer'",
")",
")",
";",
"}",
"$",
"this",
"->",
"consumer",
"=",
"$",
"this",
"->",
"driver",
"->",
"getConsumer",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'name'",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'memory-limit'",
")",
")",
"&&",
"ctype_digit",
"(",
"(",
"string",
")",
"$",
"input",
"->",
"getOption",
"(",
"'memory-limit'",
")",
")",
"&&",
"$",
"input",
"->",
"getOption",
"(",
"'memory-limit'",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"consumer",
"->",
"setMemoryLimit",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'memory-limit'",
")",
")",
";",
"}",
"if",
"(",
"(",
"$",
"routingKey",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'route'",
")",
")",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"consumer",
"->",
"setRoutingKey",
"(",
"$",
"routingKey",
")",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"label",
"!=",
"''",
"&&",
"is_callable",
"(",
"array",
"(",
"$",
"this",
"->",
"consumer",
",",
"'setLabel'",
")",
")",
")",
"{",
"$",
"this",
"->",
"consumer",
"->",
"setLabel",
"(",
"self",
"::",
"$",
"label",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"consumer",
"instanceof",
"\\",
"Kaliop",
"\\",
"QueueingBundle",
"\\",
"Queue",
"\\",
"SignalHandlingConsumerInterface",
")",
"{",
"$",
"this",
"->",
"consumer",
"->",
"setHandleSignals",
"(",
"$",
"handleSignals",
")",
";",
"}",
"}"
] |
Reimplemented to allow drivers to give us a Consumer.
Also, only set the routing key to the consumer if it has been passed on the command line
@param $input
|
[
"Reimplemented",
"to",
"allow",
"drivers",
"to",
"give",
"us",
"a",
"Consumer",
".",
"Also",
"only",
"set",
"the",
"routing",
"key",
"to",
"the",
"consumer",
"if",
"it",
"has",
"been",
"passed",
"on",
"the",
"command",
"line"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Command/ConsumerCommand.php#L102-L136
|
233,748
|
kaliop-uk/kueueingbundle
|
Command/ConsumerCommand.php
|
ConsumerCommand.haltConsumer
|
public function haltConsumer($sigNo)
{
if ($this->consumer instanceof BaseConsumer) {
// Process current message, then halt consumer
$this->consumer->forceStopConsumer();
// Halt consumer if waiting for a new message from the queue
try {
$this->consumer->stopConsuming();
} catch (AMQPTimeoutException $e) {
// exit gracefully with a message
echo("Stopped because: Received stop signal $sigNo\n");
}
} elseif ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) {
$this->consumer->forceStop("Received stop signal $sigNo");
} else {
exit();
}
}
|
php
|
public function haltConsumer($sigNo)
{
if ($this->consumer instanceof BaseConsumer) {
// Process current message, then halt consumer
$this->consumer->forceStopConsumer();
// Halt consumer if waiting for a new message from the queue
try {
$this->consumer->stopConsuming();
} catch (AMQPTimeoutException $e) {
// exit gracefully with a message
echo("Stopped because: Received stop signal $sigNo\n");
}
} elseif ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) {
$this->consumer->forceStop("Received stop signal $sigNo");
} else {
exit();
}
}
|
[
"public",
"function",
"haltConsumer",
"(",
"$",
"sigNo",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"consumer",
"instanceof",
"BaseConsumer",
")",
"{",
"// Process current message, then halt consumer",
"$",
"this",
"->",
"consumer",
"->",
"forceStopConsumer",
"(",
")",
";",
"// Halt consumer if waiting for a new message from the queue",
"try",
"{",
"$",
"this",
"->",
"consumer",
"->",
"stopConsuming",
"(",
")",
";",
"}",
"catch",
"(",
"AMQPTimeoutException",
"$",
"e",
")",
"{",
"// exit gracefully with a message",
"echo",
"(",
"\"Stopped because: Received stop signal $sigNo\\n\"",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"consumer",
"instanceof",
"\\",
"Kaliop",
"\\",
"QueueingBundle",
"\\",
"Queue",
"\\",
"SignalHandlingConsumerInterface",
")",
"{",
"$",
"this",
"->",
"consumer",
"->",
"forceStop",
"(",
"\"Received stop signal $sigNo\"",
")",
";",
"}",
"else",
"{",
"exit",
"(",
")",
";",
"}",
"}"
] |
Reimplementation of stopConsumer to allow non-amqp consumer to react gracefully to stop signals
@param int $sigNo
|
[
"Reimplementation",
"of",
"stopConsumer",
"to",
"allow",
"non",
"-",
"amqp",
"consumer",
"to",
"react",
"gracefully",
"to",
"stop",
"signals"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Command/ConsumerCommand.php#L142-L163
|
233,749
|
skrz/meta
|
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
|
ReservedRangeMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ReservedRange();
case 1:
return new ReservedRange(func_get_arg(0));
case 2:
return new ReservedRange(func_get_arg(0), func_get_arg(1));
case 3:
return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ReservedRange(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 ReservedRange(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 ReservedRange(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 ReservedRange();
case 1:
return new ReservedRange(func_get_arg(0));
case 2:
return new ReservedRange(func_get_arg(0), func_get_arg(1));
case 3:
return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ReservedRange(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 ReservedRange(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 ReservedRange(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",
"ReservedRange",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ReservedRange",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ReservedRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ReservedRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ReservedRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ReservedRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ReservedRange",
"(",
"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",
"ReservedRange",
"(",
"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",
"ReservedRange",
"(",
"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\DescriptorProto\ReservedRange
@throws \InvalidArgumentException
@return ReservedRange
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto",
"\\",
"ReservedRange"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L58-L82
|
233,750
|
skrz/meta
|
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
|
ReservedRangeMeta.reset
|
public static function reset($object)
{
if (!($object instanceof ReservedRange)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ReservedRange.');
}
$object->start = NULL;
$object->end = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof ReservedRange)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ReservedRange.');
}
$object->start = NULL;
$object->end = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"ReservedRange",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\DescriptorProto\\ReservedRange.'",
")",
";",
"}",
"$",
"object",
"->",
"start",
"=",
"NULL",
";",
"$",
"object",
"->",
"end",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\DescriptorProto\ReservedRange to default values
@param ReservedRange $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto",
"\\",
"ReservedRange",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L95-L102
|
233,751
|
skrz/meta
|
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
|
ReservedRangeMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->start)) {
hash_update($ctx, 'start');
hash_update($ctx, (string)$object->start);
}
if (isset($object->end)) {
hash_update($ctx, 'end');
hash_update($ctx, (string)$object->end);
}
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->start)) {
hash_update($ctx, 'start');
hash_update($ctx, (string)$object->start);
}
if (isset($object->end)) {
hash_update($ctx, 'end');
hash_update($ctx, (string)$object->end);
}
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",
"->",
"start",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'start'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"start",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"end",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'end'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"end",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\DescriptorProto\ReservedRange
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto",
"\\",
"ReservedRange"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L114-L137
|
233,752
|
skrz/meta
|
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
|
ReservedRangeMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->start) && ($filter === null || isset($filter['start']))) {
$output .= "\x08";
$output .= Binary::encodeVarint($object->start);
}
if (isset($object->end) && ($filter === null || isset($filter['end']))) {
$output .= "\x10";
$output .= Binary::encodeVarint($object->end);
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->start) && ($filter === null || isset($filter['start']))) {
$output .= "\x08";
$output .= Binary::encodeVarint($object->start);
}
if (isset($object->end) && ($filter === null || isset($filter['end']))) {
$output .= "\x10";
$output .= Binary::encodeVarint($object->end);
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"start",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'start'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x08\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"object",
"->",
"start",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"end",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'end'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x10\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"object",
"->",
"end",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\DescriptorProto\ReservedRange to Protocol Buffers message.
@param ReservedRange $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto",
"\\",
"ReservedRange",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L213-L228
|
233,753
|
bigwhoop/sentence-breaker
|
src/Rules/RulePattern.php
|
RulePattern.getTokensOffsetRelativeToStartToken
|
public function getTokensOffsetRelativeToStartToken($startTokenName)
{
$startTokenIdx = null;
foreach ($this->tokens as $idx => $token) {
if ($token->getTokenName() === $startTokenName) {
$startTokenIdx = $idx;
} elseif ($token->isStartToken()) {
$startTokenIdx = $idx;
}
}
if ($startTokenIdx === null) {
throw new ConfigurationException('No start token found for pattern '.print_r($this, true));
}
$numTokens = count($this->tokens);
$offsets = array_map(function ($idx) use ($startTokenIdx) {
return $idx - $startTokenIdx;
}, range(0, $numTokens - 1));
return array_combine($offsets, $this->tokens);
}
|
php
|
public function getTokensOffsetRelativeToStartToken($startTokenName)
{
$startTokenIdx = null;
foreach ($this->tokens as $idx => $token) {
if ($token->getTokenName() === $startTokenName) {
$startTokenIdx = $idx;
} elseif ($token->isStartToken()) {
$startTokenIdx = $idx;
}
}
if ($startTokenIdx === null) {
throw new ConfigurationException('No start token found for pattern '.print_r($this, true));
}
$numTokens = count($this->tokens);
$offsets = array_map(function ($idx) use ($startTokenIdx) {
return $idx - $startTokenIdx;
}, range(0, $numTokens - 1));
return array_combine($offsets, $this->tokens);
}
|
[
"public",
"function",
"getTokensOffsetRelativeToStartToken",
"(",
"$",
"startTokenName",
")",
"{",
"$",
"startTokenIdx",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"tokens",
"as",
"$",
"idx",
"=>",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"->",
"getTokenName",
"(",
")",
"===",
"$",
"startTokenName",
")",
"{",
"$",
"startTokenIdx",
"=",
"$",
"idx",
";",
"}",
"elseif",
"(",
"$",
"token",
"->",
"isStartToken",
"(",
")",
")",
"{",
"$",
"startTokenIdx",
"=",
"$",
"idx",
";",
"}",
"}",
"if",
"(",
"$",
"startTokenIdx",
"===",
"null",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"'No start token found for pattern '",
".",
"print_r",
"(",
"$",
"this",
",",
"true",
")",
")",
";",
"}",
"$",
"numTokens",
"=",
"count",
"(",
"$",
"this",
"->",
"tokens",
")",
";",
"$",
"offsets",
"=",
"array_map",
"(",
"function",
"(",
"$",
"idx",
")",
"use",
"(",
"$",
"startTokenIdx",
")",
"{",
"return",
"$",
"idx",
"-",
"$",
"startTokenIdx",
";",
"}",
",",
"range",
"(",
"0",
",",
"$",
"numTokens",
"-",
"1",
")",
")",
";",
"return",
"array_combine",
"(",
"$",
"offsets",
",",
"$",
"this",
"->",
"tokens",
")",
";",
"}"
] |
Returns the offset for each token relative to the start token.
Let's say we have the following tokens: T_A, T_B, T_C, T_D
If the $startTokenName were T_A we'd return: 0, 1, 2, 3
If the $startTokenName were T_C we'd return: -2, -1, 0, 1
@param string $startTokenName
@return RulePatternToken[]
@throws ConfigurationException
|
[
"Returns",
"the",
"offset",
"for",
"each",
"token",
"relative",
"to",
"the",
"start",
"token",
"."
] |
7b3d72ed84082c512cc0335b6e230f033274ea8d
|
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Rules/RulePattern.php#L78-L101
|
233,754
|
calcinai/php-mmap
|
lib/MMap/StreamWrapper.php
|
StreamWrapper.parseURI
|
private static function parseURI($uri){
//Remove protocol (for clarity).
$uri = substr($uri, strlen('mmap://'));
$parts = explode('?', $uri);
$file_name_block_size = explode(':', $parts[0]);
if(!isset($file_name_block_size[1])){
throw new \Exception(sprintf('%s is not a valid uri', $uri));
}
$parsed = [];
list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size;
if(isset($parts[1])){
//Extra params
parse_str($parts[1], $parsed['options']);
} else {
$parsed['options'] = [];
}
return $parsed;
}
|
php
|
private static function parseURI($uri){
//Remove protocol (for clarity).
$uri = substr($uri, strlen('mmap://'));
$parts = explode('?', $uri);
$file_name_block_size = explode(':', $parts[0]);
if(!isset($file_name_block_size[1])){
throw new \Exception(sprintf('%s is not a valid uri', $uri));
}
$parsed = [];
list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size;
if(isset($parts[1])){
//Extra params
parse_str($parts[1], $parsed['options']);
} else {
$parsed['options'] = [];
}
return $parsed;
}
|
[
"private",
"static",
"function",
"parseURI",
"(",
"$",
"uri",
")",
"{",
"//Remove protocol (for clarity).",
"$",
"uri",
"=",
"substr",
"(",
"$",
"uri",
",",
"strlen",
"(",
"'mmap://'",
")",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'?'",
",",
"$",
"uri",
")",
";",
"$",
"file_name_block_size",
"=",
"explode",
"(",
"':'",
",",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"file_name_block_size",
"[",
"1",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'%s is not a valid uri'",
",",
"$",
"uri",
")",
")",
";",
"}",
"$",
"parsed",
"=",
"[",
"]",
";",
"list",
"(",
"$",
"parsed",
"[",
"'file_name'",
"]",
",",
"$",
"parsed",
"[",
"'block_size'",
"]",
")",
"=",
"$",
"file_name_block_size",
";",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"//Extra params",
"parse_str",
"(",
"$",
"parts",
"[",
"1",
"]",
",",
"$",
"parsed",
"[",
"'options'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"parsed",
"[",
"'options'",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"parsed",
";",
"}"
] |
Can't parse_url as it's too malformed
@param $uri
@return array
@throws \Exception
|
[
"Can",
"t",
"parse_url",
"as",
"it",
"s",
"too",
"malformed"
] |
67a8f56727ecd255b0d61c1dc4ea0604f84fb294
|
https://github.com/calcinai/php-mmap/blob/67a8f56727ecd255b0d61c1dc4ea0604f84fb294/lib/MMap/StreamWrapper.php#L151-L174
|
233,755
|
fab2s/NodalFlow
|
src/PayloadNodeFactory.php
|
PayloadNodeFactory.create
|
public static function create($payload, $isAReturningVal, $isATraversable = false)
{
if (\is_array($payload) || \is_string($payload)) {
return new CallableNode($payload, $isAReturningVal, $isATraversable);
}
if ($payload instanceof \Closure) {
// distinguishing Closures actually is surrealistic
return new ClosureNode($payload, $isAReturningVal, $isATraversable);
}
if ($payload instanceof FlowInterface) {
return new BranchNode($payload, $isAReturningVal);
}
throw new NodalFlowException('Payload not supported, must be Callable or Flow');
}
|
php
|
public static function create($payload, $isAReturningVal, $isATraversable = false)
{
if (\is_array($payload) || \is_string($payload)) {
return new CallableNode($payload, $isAReturningVal, $isATraversable);
}
if ($payload instanceof \Closure) {
// distinguishing Closures actually is surrealistic
return new ClosureNode($payload, $isAReturningVal, $isATraversable);
}
if ($payload instanceof FlowInterface) {
return new BranchNode($payload, $isAReturningVal);
}
throw new NodalFlowException('Payload not supported, must be Callable or Flow');
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"payload",
",",
"$",
"isAReturningVal",
",",
"$",
"isATraversable",
"=",
"false",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"payload",
")",
"||",
"\\",
"is_string",
"(",
"$",
"payload",
")",
")",
"{",
"return",
"new",
"CallableNode",
"(",
"$",
"payload",
",",
"$",
"isAReturningVal",
",",
"$",
"isATraversable",
")",
";",
"}",
"if",
"(",
"$",
"payload",
"instanceof",
"\\",
"Closure",
")",
"{",
"// distinguishing Closures actually is surrealistic",
"return",
"new",
"ClosureNode",
"(",
"$",
"payload",
",",
"$",
"isAReturningVal",
",",
"$",
"isATraversable",
")",
";",
"}",
"if",
"(",
"$",
"payload",
"instanceof",
"FlowInterface",
")",
"{",
"return",
"new",
"BranchNode",
"(",
"$",
"payload",
",",
"$",
"isAReturningVal",
")",
";",
"}",
"throw",
"new",
"NodalFlowException",
"(",
"'Payload not supported, must be Callable or Flow'",
")",
";",
"}"
] |
Instantiate the proper Payload Node for the payload
@param mixed $payload
@param bool $isAReturningVal
@param bool $isATraversable
@throws NodalFlowException
@return PayloadNodeInterface
|
[
"Instantiate",
"the",
"proper",
"Payload",
"Node",
"for",
"the",
"payload"
] |
da5d458ffea3e6e954d7ee734f938f4be5e46728
|
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/PayloadNodeFactory.php#L35-L51
|
233,756
|
jkphl/dom-factory
|
src/Domfactory/Domain/Dom.php
|
Dom.load
|
public function load($source)
{
$source = mb_convert_encoding($source, 'HTML-ENTITIES', mb_detect_encoding($source));
$dom = new \DOMDocument();
// Try to load the source as standard XML document first, then as HTML document
if (!$dom->loadXML($source, LIBXML_NOWARNING | LIBXML_NOERROR)) {
$dom = $this->htmlParser->loadHTML($source);
}
return $dom;
}
|
php
|
public function load($source)
{
$source = mb_convert_encoding($source, 'HTML-ENTITIES', mb_detect_encoding($source));
$dom = new \DOMDocument();
// Try to load the source as standard XML document first, then as HTML document
if (!$dom->loadXML($source, LIBXML_NOWARNING | LIBXML_NOERROR)) {
$dom = $this->htmlParser->loadHTML($source);
}
return $dom;
}
|
[
"public",
"function",
"load",
"(",
"$",
"source",
")",
"{",
"$",
"source",
"=",
"mb_convert_encoding",
"(",
"$",
"source",
",",
"'HTML-ENTITIES'",
",",
"mb_detect_encoding",
"(",
"$",
"source",
")",
")",
";",
"$",
"dom",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"// Try to load the source as standard XML document first, then as HTML document",
"if",
"(",
"!",
"$",
"dom",
"->",
"loadXML",
"(",
"$",
"source",
",",
"LIBXML_NOWARNING",
"|",
"LIBXML_NOERROR",
")",
")",
"{",
"$",
"dom",
"=",
"$",
"this",
"->",
"htmlParser",
"->",
"loadHTML",
"(",
"$",
"source",
")",
";",
"}",
"return",
"$",
"dom",
";",
"}"
] |
Create a DOM document from a string
@param string $source XML/HTML string
@return \DOMDocument DOM document
|
[
"Create",
"a",
"DOM",
"document",
"from",
"a",
"string"
] |
460595b73b214510b29f483d61358296d2825143
|
https://github.com/jkphl/dom-factory/blob/460595b73b214510b29f483d61358296d2825143/src/Domfactory/Domain/Dom.php#L70-L81
|
233,757
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
|
EnumValueDescriptorProtoMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new EnumValueDescriptorProto();
case 1:
return new EnumValueDescriptorProto(func_get_arg(0));
case 2:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new EnumValueDescriptorProto(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 EnumValueDescriptorProto(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 EnumValueDescriptorProto(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 EnumValueDescriptorProto();
case 1:
return new EnumValueDescriptorProto(func_get_arg(0));
case 2:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new EnumValueDescriptorProto(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 EnumValueDescriptorProto(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 EnumValueDescriptorProto(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",
"EnumValueDescriptorProto",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"EnumValueDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"EnumValueDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"EnumValueDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"EnumValueDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"EnumValueDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"EnumValueDescriptorProto",
"(",
"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",
"EnumValueDescriptorProto",
"(",
"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",
"EnumValueDescriptorProto",
"(",
"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\EnumValueDescriptorProto
@throws \InvalidArgumentException
@return EnumValueDescriptorProto
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"EnumValueDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L59-L83
|
233,758
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
|
EnumValueDescriptorProtoMeta.reset
|
public static function reset($object)
{
if (!($object instanceof EnumValueDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumValueDescriptorProto.');
}
$object->name = NULL;
$object->number = NULL;
$object->options = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof EnumValueDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumValueDescriptorProto.');
}
$object->name = NULL;
$object->number = NULL;
$object->options = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"EnumValueDescriptorProto",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\EnumValueDescriptorProto.'",
")",
";",
"}",
"$",
"object",
"->",
"name",
"=",
"NULL",
";",
"$",
"object",
"->",
"number",
"=",
"NULL",
";",
"$",
"object",
"->",
"options",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\EnumValueDescriptorProto to default values
@param EnumValueDescriptorProto $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"EnumValueDescriptorProto",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L96-L104
|
233,759
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
|
EnumValueDescriptorProtoMeta.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->number)) {
hash_update($ctx, 'number');
hash_update($ctx, (string)$object->number);
}
if (isset($object->options)) {
hash_update($ctx, 'options');
EnumValueOptionsMeta::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->number)) {
hash_update($ctx, 'number');
hash_update($ctx, (string)$object->number);
}
if (isset($object->options)) {
hash_update($ctx, 'options');
EnumValueOptionsMeta::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",
"->",
"number",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'number'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"number",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"options",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'options'",
")",
";",
"EnumValueOptionsMeta",
"::",
"hash",
"(",
"$",
"object",
"->",
"options",
",",
"$",
"ctx",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\EnumValueDescriptorProto
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"EnumValueDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L116-L144
|
233,760
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
|
EnumValueDescriptorProtoMeta.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->number) && ($filter === null || isset($filter['number']))) {
$output .= "\x10";
$output .= Binary::encodeVarint($object->number);
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x1a";
$buffer = EnumValueOptionsMeta::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->number) && ($filter === null || isset($filter['number']))) {
$output .= "\x10";
$output .= Binary::encodeVarint($object->number);
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x1a";
$buffer = EnumValueOptionsMeta::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",
"->",
"number",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'number'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x10\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"object",
"->",
"number",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"options",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'options'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x1a\"",
";",
"$",
"buffer",
"=",
"EnumValueOptionsMeta",
"::",
"toProtobuf",
"(",
"$",
"object",
"->",
"options",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'options'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\EnumValueDescriptorProto to Protocol Buffers message.
@param EnumValueDescriptorProto $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"EnumValueDescriptorProto",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L243-L266
|
233,761
|
meare/juggler
|
src/Juggler.php
|
Juggler.getImposter
|
public function getImposter($port, $replayable = false, $remove_proxies = false)
{
return $this->abstractImposterBuilder->build($this->getImposterContract($port, $replayable, $remove_proxies));
}
|
php
|
public function getImposter($port, $replayable = false, $remove_proxies = false)
{
return $this->abstractImposterBuilder->build($this->getImposterContract($port, $replayable, $remove_proxies));
}
|
[
"public",
"function",
"getImposter",
"(",
"$",
"port",
",",
"$",
"replayable",
"=",
"false",
",",
"$",
"remove_proxies",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"abstractImposterBuilder",
"->",
"build",
"(",
"$",
"this",
"->",
"getImposterContract",
"(",
"$",
"port",
",",
"$",
"replayable",
",",
"$",
"remove_proxies",
")",
")",
";",
"}"
] |
Retrieves contract and builds Imposter
@param int $port
@param bool $replayable
@param bool $remove_proxies
@throws MountebankException
@return Imposter
|
[
"Retrieves",
"contract",
"and",
"builds",
"Imposter"
] |
11ec398c16e01c986679f53f8ece2c1e97ba4e29
|
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Juggler.php#L159-L162
|
233,762
|
meare/juggler
|
src/Juggler.php
|
Juggler.composeQueryString
|
private function composeQueryString($replayable, $remove_proxies)
{
return http_build_query(array_filter([
self::PARAM_REPLAYABLE => $replayable ? 'true' : null,
self::PARAM_REMOVE_PROXIES => $remove_proxies ? 'true' : null,
]));
}
|
php
|
private function composeQueryString($replayable, $remove_proxies)
{
return http_build_query(array_filter([
self::PARAM_REPLAYABLE => $replayable ? 'true' : null,
self::PARAM_REMOVE_PROXIES => $remove_proxies ? 'true' : null,
]));
}
|
[
"private",
"function",
"composeQueryString",
"(",
"$",
"replayable",
",",
"$",
"remove_proxies",
")",
"{",
"return",
"http_build_query",
"(",
"array_filter",
"(",
"[",
"self",
"::",
"PARAM_REPLAYABLE",
"=>",
"$",
"replayable",
"?",
"'true'",
":",
"null",
",",
"self",
"::",
"PARAM_REMOVE_PROXIES",
"=>",
"$",
"remove_proxies",
"?",
"'true'",
":",
"null",
",",
"]",
")",
")",
";",
"}"
] |
mountebank API only supports string 'true' as boolean param value
@param bool $replayable
@param bool $remove_proxies
@return string
|
[
"mountebank",
"API",
"only",
"supports",
"string",
"true",
"as",
"boolean",
"param",
"value"
] |
11ec398c16e01c986679f53f8ece2c1e97ba4e29
|
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Juggler.php#L284-L290
|
233,763
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
|
CodeGeneratorRequestMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new CodeGeneratorRequest();
case 1:
return new CodeGeneratorRequest(func_get_arg(0));
case 2:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1));
case 3:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new CodeGeneratorRequest(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 CodeGeneratorRequest(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 CodeGeneratorRequest(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 CodeGeneratorRequest();
case 1:
return new CodeGeneratorRequest(func_get_arg(0));
case 2:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1));
case 3:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new CodeGeneratorRequest(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 CodeGeneratorRequest(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 CodeGeneratorRequest(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",
"CodeGeneratorRequest",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"CodeGeneratorRequest",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"CodeGeneratorRequest",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"CodeGeneratorRequest",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"CodeGeneratorRequest",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"CodeGeneratorRequest",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"CodeGeneratorRequest",
"(",
"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",
"CodeGeneratorRequest",
"(",
"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",
"CodeGeneratorRequest",
"(",
"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\CodeGeneratorRequest
@throws \InvalidArgumentException
@return CodeGeneratorRequest
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorRequest"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L60-L84
|
233,764
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
|
CodeGeneratorRequestMeta.reset
|
public static function reset($object)
{
if (!($object instanceof CodeGeneratorRequest)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorRequest.');
}
$object->fileToGenerate = NULL;
$object->parameter = NULL;
$object->protoFile = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof CodeGeneratorRequest)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorRequest.');
}
$object->fileToGenerate = NULL;
$object->parameter = NULL;
$object->protoFile = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"CodeGeneratorRequest",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\Compiler\\CodeGeneratorRequest.'",
")",
";",
"}",
"$",
"object",
"->",
"fileToGenerate",
"=",
"NULL",
";",
"$",
"object",
"->",
"parameter",
"=",
"NULL",
";",
"$",
"object",
"->",
"protoFile",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\Compiler\CodeGeneratorRequest to default values
@param CodeGeneratorRequest $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorRequest",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L97-L105
|
233,765
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
|
CodeGeneratorRequestMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->fileToGenerate)) {
hash_update($ctx, 'fileToGenerate');
foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (isset($object->parameter)) {
hash_update($ctx, 'parameter');
hash_update($ctx, (string)$object->parameter);
}
if (isset($object->protoFile)) {
hash_update($ctx, 'protoFile');
foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $v0) {
FileDescriptorProtoMeta::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->fileToGenerate)) {
hash_update($ctx, 'fileToGenerate');
foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (isset($object->parameter)) {
hash_update($ctx, 'parameter');
hash_update($ctx, (string)$object->parameter);
}
if (isset($object->protoFile)) {
hash_update($ctx, 'protoFile');
foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $v0) {
FileDescriptorProtoMeta::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",
"->",
"fileToGenerate",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'fileToGenerate'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"fileToGenerate",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"fileToGenerate",
":",
"(",
"array",
")",
"$",
"object",
"->",
"fileToGenerate",
"as",
"$",
"v0",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"v0",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"parameter",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'parameter'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"parameter",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"protoFile",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'protoFile'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"protoFile",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"protoFile",
":",
"(",
"array",
")",
"$",
"object",
"->",
"protoFile",
"as",
"$",
"v0",
")",
"{",
"FileDescriptorProtoMeta",
"::",
"hash",
"(",
"$",
"v0",
",",
"$",
"ctx",
")",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\Compiler\CodeGeneratorRequest
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorRequest"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L117-L149
|
233,766
|
skrz/meta
|
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
|
CodeGeneratorRequestMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->fileToGenerate) && ($filter === null || isset($filter['fileToGenerate']))) {
foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $k => $v) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($v));
$output .= $v;
}
}
if (isset($object->parameter) && ($filter === null || isset($filter['parameter']))) {
$output .= "\x12";
$output .= Binary::encodeVarint(strlen($object->parameter));
$output .= $object->parameter;
}
if (isset($object->protoFile) && ($filter === null || isset($filter['protoFile']))) {
foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $k => $v) {
$output .= "\x7a";
$buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['protoFile']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->fileToGenerate) && ($filter === null || isset($filter['fileToGenerate']))) {
foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $k => $v) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($v));
$output .= $v;
}
}
if (isset($object->parameter) && ($filter === null || isset($filter['parameter']))) {
$output .= "\x12";
$output .= Binary::encodeVarint(strlen($object->parameter));
$output .= $object->parameter;
}
if (isset($object->protoFile) && ($filter === null || isset($filter['protoFile']))) {
foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $k => $v) {
$output .= "\x7a";
$buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['protoFile']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"fileToGenerate",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'fileToGenerate'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"fileToGenerate",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"fileToGenerate",
":",
"(",
"array",
")",
"$",
"object",
"->",
"fileToGenerate",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\x0a\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"v",
")",
")",
";",
"$",
"output",
".=",
"$",
"v",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"parameter",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'parameter'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x12\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"parameter",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"parameter",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"protoFile",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'protoFile'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"protoFile",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"protoFile",
":",
"(",
"array",
")",
"$",
"object",
"->",
"protoFile",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\x7a\"",
";",
"$",
"buffer",
"=",
"FileDescriptorProtoMeta",
"::",
"toProtobuf",
"(",
"$",
"v",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'protoFile'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\Compiler\CodeGeneratorRequest to Protocol Buffers message.
@param CodeGeneratorRequest $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorRequest",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L263-L291
|
233,767
|
iron-io/laraworker
|
commands/UploadWorker.php
|
UploadWorker.getPushType
|
protected function getPushType($queue_name)
{
if ($this->option('push_queue_type')) return $this->option('push_queue_type');
try {
return $this->getQueue($queue_name)->push_type;
} catch (\Exception $e) {
return 'multicast';
}
}
|
php
|
protected function getPushType($queue_name)
{
if ($this->option('push_queue_type')) return $this->option('push_queue_type');
try {
return $this->getQueue($queue_name)->push_type;
} catch (\Exception $e) {
return 'multicast';
}
}
|
[
"protected",
"function",
"getPushType",
"(",
"$",
"queue_name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'push_queue_type'",
")",
")",
"return",
"$",
"this",
"->",
"option",
"(",
"'push_queue_type'",
")",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"getQueue",
"(",
"$",
"queue_name",
")",
"->",
"push_type",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"'multicast'",
";",
"}",
"}"
] |
Get the push type for the queue.
@param $queue_name
@return string
|
[
"Get",
"the",
"push",
"type",
"for",
"the",
"queue",
"."
] |
2b3461d31863267abbd74611f25f5f2922585ccf
|
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L108-L117
|
233,768
|
iron-io/laraworker
|
commands/UploadWorker.php
|
UploadWorker.need_to_update_queue
|
protected function need_to_update_queue($queue_name)
{
foreach ($this->getCurrentSubscribers($queue_name) as $subscriber) {
if ($subscriber->url == $this->subscriber_url)
return false;
}
return true;
}
|
php
|
protected function need_to_update_queue($queue_name)
{
foreach ($this->getCurrentSubscribers($queue_name) as $subscriber) {
if ($subscriber->url == $this->subscriber_url)
return false;
}
return true;
}
|
[
"protected",
"function",
"need_to_update_queue",
"(",
"$",
"queue_name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getCurrentSubscribers",
"(",
"$",
"queue_name",
")",
"as",
"$",
"subscriber",
")",
"{",
"if",
"(",
"$",
"subscriber",
"->",
"url",
"==",
"$",
"this",
"->",
"subscriber_url",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Get list of subscribers and compare it with current subscriber url
@param $queue_name
@internal param $subscriber_url
@return bool
|
[
"Get",
"list",
"of",
"subscribers",
"and",
"compare",
"it",
"with",
"current",
"subscriber",
"url"
] |
2b3461d31863267abbd74611f25f5f2922585ccf
|
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L167-L174
|
233,769
|
iron-io/laraworker
|
commands/UploadWorker.php
|
UploadWorker.update_queue
|
protected function update_queue($iron, $queue_name)
{
$this->info("<info>Creating or updating push queue <comment>$this->iron_worker_name</comment></info>");
$iron->getIron()->updateQueue($queue_name, $this->getQueueOptions($queue_name));
$this->line("<info>Push Queue <comment>$queue_name</comment> with subscriber <comment>$this->subscriber_url</comment> created or updated.</info>" . PHP_EOL);
}
|
php
|
protected function update_queue($iron, $queue_name)
{
$this->info("<info>Creating or updating push queue <comment>$this->iron_worker_name</comment></info>");
$iron->getIron()->updateQueue($queue_name, $this->getQueueOptions($queue_name));
$this->line("<info>Push Queue <comment>$queue_name</comment> with subscriber <comment>$this->subscriber_url</comment> created or updated.</info>" . PHP_EOL);
}
|
[
"protected",
"function",
"update_queue",
"(",
"$",
"iron",
",",
"$",
"queue_name",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"<info>Creating or updating push queue <comment>$this->iron_worker_name</comment></info>\"",
")",
";",
"$",
"iron",
"->",
"getIron",
"(",
")",
"->",
"updateQueue",
"(",
"$",
"queue_name",
",",
"$",
"this",
"->",
"getQueueOptions",
"(",
"$",
"queue_name",
")",
")",
";",
"$",
"this",
"->",
"line",
"(",
"\"<info>Push Queue <comment>$queue_name</comment> with subscriber <comment>$this->subscriber_url</comment> created or updated.</info>\"",
".",
"PHP_EOL",
")",
";",
"}"
] |
Update push queue
@param $iron
@param $queue_name
|
[
"Update",
"push",
"queue"
] |
2b3461d31863267abbd74611f25f5f2922585ccf
|
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L195-L200
|
233,770
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/OneofDescriptorProtoMeta.php
|
OneofDescriptorProtoMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new OneofDescriptorProto();
case 1:
return new OneofDescriptorProto(func_get_arg(0));
case 2:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new OneofDescriptorProto(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 OneofDescriptorProto(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 OneofDescriptorProto(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 OneofDescriptorProto();
case 1:
return new OneofDescriptorProto(func_get_arg(0));
case 2:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new OneofDescriptorProto(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 OneofDescriptorProto(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 OneofDescriptorProto(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",
"OneofDescriptorProto",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"OneofDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"OneofDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"OneofDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"OneofDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"OneofDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"OneofDescriptorProto",
"(",
"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",
"OneofDescriptorProto",
"(",
"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",
"OneofDescriptorProto",
"(",
"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\OneofDescriptorProto
@throws \InvalidArgumentException
@return OneofDescriptorProto
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"OneofDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/OneofDescriptorProtoMeta.php#L57-L81
|
233,771
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Repositories/DbUserRepository.php
|
DbUserRepository.validForCreation
|
public function validForCreation($first_name, $last_name, $email, $password)
{
return $this->validateUser($first_name, $last_name, $email, $password);
}
|
php
|
public function validForCreation($first_name, $last_name, $email, $password)
{
return $this->validateUser($first_name, $last_name, $email, $password);
}
|
[
"public",
"function",
"validForCreation",
"(",
"$",
"first_name",
",",
"$",
"last_name",
",",
"$",
"email",
",",
"$",
"password",
")",
"{",
"return",
"$",
"this",
"->",
"validateUser",
"(",
"$",
"first_name",
",",
"$",
"last_name",
",",
"$",
"email",
",",
"$",
"password",
")",
";",
"}"
] |
Validate that the given user is valid for creation.
@param string $first_name
@param string $last_name
@param string $email
@param string $password
@return \Illuminate\Support\MessageBag
|
[
"Validate",
"that",
"the",
"given",
"user",
"is",
"valid",
"for",
"creation",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L90-L93
|
233,772
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Repositories/DbUserRepository.php
|
DbUserRepository.validForUpdate
|
public function validForUpdate($id, $first_name, $last_name, $email, $password)
{
return $this->validateUser($first_name, $last_name, $email, $password, $id);
}
|
php
|
public function validForUpdate($id, $first_name, $last_name, $email, $password)
{
return $this->validateUser($first_name, $last_name, $email, $password, $id);
}
|
[
"public",
"function",
"validForUpdate",
"(",
"$",
"id",
",",
"$",
"first_name",
",",
"$",
"last_name",
",",
"$",
"email",
",",
"$",
"password",
")",
"{",
"return",
"$",
"this",
"->",
"validateUser",
"(",
"$",
"first_name",
",",
"$",
"last_name",
",",
"$",
"email",
",",
"$",
"password",
",",
"$",
"id",
")",
";",
"}"
] |
Validate that the given user is valid for updating.
@param int $id
@param string $first_name
@param string $last_name
@param string $email
@param string $password
@return \Illuminate\Support\MessageBag
|
[
"Validate",
"that",
"the",
"given",
"user",
"is",
"valid",
"for",
"updating",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L105-L108
|
233,773
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Repositories/DbUserRepository.php
|
DbUserRepository.validateUser
|
protected function validateUser($first_name, $last_name, $email, $password, $id = null)
{
$rules = array(
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|unique:users,email',
);
if ($id)
{
$rules['email'] .= ','.$id;
}
else
{
$rules['password'] = 'required|min:6';
}
$validator = Validator::make(
compact('first_name', 'last_name', 'email', 'password'), $rules
);
$validator->passes();
return $validator->errors();
}
|
php
|
protected function validateUser($first_name, $last_name, $email, $password, $id = null)
{
$rules = array(
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|unique:users,email',
);
if ($id)
{
$rules['email'] .= ','.$id;
}
else
{
$rules['password'] = 'required|min:6';
}
$validator = Validator::make(
compact('first_name', 'last_name', 'email', 'password'), $rules
);
$validator->passes();
return $validator->errors();
}
|
[
"protected",
"function",
"validateUser",
"(",
"$",
"first_name",
",",
"$",
"last_name",
",",
"$",
"email",
",",
"$",
"password",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"rules",
"=",
"array",
"(",
"'first_name'",
"=>",
"'required|max:255'",
",",
"'last_name'",
"=>",
"'required|max:255'",
",",
"'email'",
"=>",
"'required|email|unique:users,email'",
",",
")",
";",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"rules",
"[",
"'email'",
"]",
".=",
"','",
".",
"$",
"id",
";",
"}",
"else",
"{",
"$",
"rules",
"[",
"'password'",
"]",
"=",
"'required|min:6'",
";",
"}",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"compact",
"(",
"'first_name'",
",",
"'last_name'",
",",
"'email'",
",",
"'password'",
")",
",",
"$",
"rules",
")",
";",
"$",
"validator",
"->",
"passes",
"(",
")",
";",
"return",
"$",
"validator",
"->",
"errors",
"(",
")",
";",
"}"
] |
Validate the given user data.
@param string $first_name
@param stirng $last_name
@param string $email
@param string $password
@param int $id
@return \Illuminate\Support\MessageBag
|
[
"Validate",
"the",
"given",
"user",
"data",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L121-L145
|
233,774
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Repositories/DbUserRepository.php
|
DbUserRepository.login
|
public function login($email, $password, $remember = false)
{
$user = User::where('email', $email)->first();
if ($user and Hash::check($password, $user->password))
{
$this->auth->login($user, $remember);
return true;
}
return false;
}
|
php
|
public function login($email, $password, $remember = false)
{
$user = User::where('email', $email)->first();
if ($user and Hash::check($password, $user->password))
{
$this->auth->login($user, $remember);
return true;
}
return false;
}
|
[
"public",
"function",
"login",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"remember",
"=",
"false",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"where",
"(",
"'email'",
",",
"$",
"email",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"user",
"and",
"Hash",
"::",
"check",
"(",
"$",
"password",
",",
"$",
"user",
"->",
"password",
")",
")",
"{",
"$",
"this",
"->",
"auth",
"->",
"login",
"(",
"$",
"user",
",",
"$",
"remember",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Log the user into the application.
If the credentials are invalid, returns false, else returns true.
@param string $email
@param stirng $password
@param bool $remember
@return bool
|
[
"Log",
"the",
"user",
"into",
"the",
"application",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L157-L169
|
233,775
|
matrozov/yii2-couchbase
|
src/Bucket.php
|
Bucket.batchInsert
|
public function batchInsert($rows)
{
$insertedIds = $this->db->batchInsert($this->name, $rows);
foreach ($rows as $key => $row) {
$rows[$key]['_id'] = $insertedIds[$key];
}
return $rows;
}
|
php
|
public function batchInsert($rows)
{
$insertedIds = $this->db->batchInsert($this->name, $rows);
foreach ($rows as $key => $row) {
$rows[$key]['_id'] = $insertedIds[$key];
}
return $rows;
}
|
[
"public",
"function",
"batchInsert",
"(",
"$",
"rows",
")",
"{",
"$",
"insertedIds",
"=",
"$",
"this",
"->",
"db",
"->",
"batchInsert",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"rows",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"$",
"rows",
"[",
"$",
"key",
"]",
"[",
"'_id'",
"]",
"=",
"$",
"insertedIds",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"rows",
";",
"}"
] |
Inserts several new rows into bucket.
@param array $rows array of arrays or objects to be inserted.
@return string[] inserted data, each row will have "_id" key assigned to it.
@throws Exception
@throws \yii\base\InvalidConfigException
|
[
"Inserts",
"several",
"new",
"rows",
"into",
"bucket",
"."
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L72-L81
|
233,776
|
matrozov/yii2-couchbase
|
src/Bucket.php
|
Bucket.delete
|
public function delete($condition = [], $options = [])
{
return $this->db->delete($this->name, $condition, $options);
}
|
php
|
public function delete($condition = [], $options = [])
{
return $this->db->delete($this->name, $condition, $options);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"condition",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"delete",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"condition",
",",
"$",
"options",
")",
";",
"}"
] |
Delete data from the bucket.
@param array $condition description of records to remove.
@param array $options list of options in format: optionName => optionValue.
@return int|bool number of updated documents or whether operation was successful.
@throws Exception
@throws \yii\base\InvalidConfigException
|
[
"Delete",
"data",
"from",
"the",
"bucket",
"."
] |
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
|
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L152-L155
|
233,777
|
yeephp/yeephp
|
Yee/Managers/RoutingCacheManager.php
|
RoutingCacheManager.hasChanged
|
protected function hasChanged($classFile)
{
$className = $this->className($classFile);
$cacheFile = $this->cacheFile($className);
$cacheDate = file_exists($cacheFile) ? filemtime($cacheFile) : 0;
$fileDate = filemtime($classFile);
return ($fileDate != $cacheDate);
}
|
php
|
protected function hasChanged($classFile)
{
$className = $this->className($classFile);
$cacheFile = $this->cacheFile($className);
$cacheDate = file_exists($cacheFile) ? filemtime($cacheFile) : 0;
$fileDate = filemtime($classFile);
return ($fileDate != $cacheDate);
}
|
[
"protected",
"function",
"hasChanged",
"(",
"$",
"classFile",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"className",
"(",
"$",
"classFile",
")",
";",
"$",
"cacheFile",
"=",
"$",
"this",
"->",
"cacheFile",
"(",
"$",
"className",
")",
";",
"$",
"cacheDate",
"=",
"file_exists",
"(",
"$",
"cacheFile",
")",
"?",
"filemtime",
"(",
"$",
"cacheFile",
")",
":",
"0",
";",
"$",
"fileDate",
"=",
"filemtime",
"(",
"$",
"classFile",
")",
";",
"return",
"(",
"$",
"fileDate",
"!=",
"$",
"cacheDate",
")",
";",
"}"
] |
Indicates if the classfile has a diferent modify time that cache file
@param $classFile
@return bool
|
[
"Indicates",
"if",
"the",
"classfile",
"has",
"a",
"diferent",
"modify",
"time",
"that",
"cache",
"file"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L145-L153
|
233,778
|
yeephp/yeephp
|
Yee/Managers/RoutingCacheManager.php
|
RoutingCacheManager.setDateFromClassFile
|
protected function setDateFromClassFile($classFile)
{
$className = $this->className($classFile);
$cacheFile = $this->cacheFile($className);
$fileDate = filemtime($classFile);
touch($cacheFile, $fileDate);
}
|
php
|
protected function setDateFromClassFile($classFile)
{
$className = $this->className($classFile);
$cacheFile = $this->cacheFile($className);
$fileDate = filemtime($classFile);
touch($cacheFile, $fileDate);
}
|
[
"protected",
"function",
"setDateFromClassFile",
"(",
"$",
"classFile",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"className",
"(",
"$",
"classFile",
")",
";",
"$",
"cacheFile",
"=",
"$",
"this",
"->",
"cacheFile",
"(",
"$",
"className",
")",
";",
"$",
"fileDate",
"=",
"filemtime",
"(",
"$",
"classFile",
")",
";",
"touch",
"(",
"$",
"cacheFile",
",",
"$",
"fileDate",
")",
";",
"}"
] |
Sets the modify time of cache file according to classfile
@param $classFile
|
[
"Sets",
"the",
"modify",
"time",
"of",
"cache",
"file",
"according",
"to",
"classfile"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L167-L173
|
233,779
|
yeephp/yeephp
|
Yee/Managers/RoutingCacheManager.php
|
RoutingCacheManager.className
|
protected function className($classFile)
{
$classFile = str_replace($this->rootDir, "", $classFile);
$className = str_replace(array(".php", "/"), array("", "_"), $classFile);
return $className;
}
|
php
|
protected function className($classFile)
{
$classFile = str_replace($this->rootDir, "", $classFile);
$className = str_replace(array(".php", "/"), array("", "_"), $classFile);
return $className;
}
|
[
"protected",
"function",
"className",
"(",
"$",
"classFile",
")",
"{",
"$",
"classFile",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"rootDir",
",",
"\"\"",
",",
"$",
"classFile",
")",
";",
"$",
"className",
"=",
"str_replace",
"(",
"array",
"(",
"\".php\"",
",",
"\"/\"",
")",
",",
"array",
"(",
"\"\"",
",",
"\"_\"",
")",
",",
"$",
"classFile",
")",
";",
"return",
"$",
"className",
";",
"}"
] |
Extracts the className through the classfile name
@param $classFile
@return mixed
@throws \Exception
|
[
"Extracts",
"the",
"className",
"through",
"the",
"classfile",
"name"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L183-L189
|
233,780
|
yeephp/yeephp
|
Yee/Managers/RoutingCacheManager.php
|
RoutingCacheManager.readdir
|
protected static function readdir($dir)
{
$entries = array();
foreach (scandir($dir) as $entry) {
if(($entry != '.') && ($entry != '..')){
$current = "$dir/$entry";
if($current != $dir){
if(is_dir($current)){
$aux = self::readdir($current);
$entries = array_merge($entries, $aux);
}else{
if(preg_match("/\w*?Controller.php/", $entry)){
$entries[] = $current;
}
}
}
}
}
return $entries;
}
|
php
|
protected static function readdir($dir)
{
$entries = array();
foreach (scandir($dir) as $entry) {
if(($entry != '.') && ($entry != '..')){
$current = "$dir/$entry";
if($current != $dir){
if(is_dir($current)){
$aux = self::readdir($current);
$entries = array_merge($entries, $aux);
}else{
if(preg_match("/\w*?Controller.php/", $entry)){
$entries[] = $current;
}
}
}
}
}
return $entries;
}
|
[
"protected",
"static",
"function",
"readdir",
"(",
"$",
"dir",
")",
"{",
"$",
"entries",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"scandir",
"(",
"$",
"dir",
")",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"(",
"$",
"entry",
"!=",
"'.'",
")",
"&&",
"(",
"$",
"entry",
"!=",
"'..'",
")",
")",
"{",
"$",
"current",
"=",
"\"$dir/$entry\"",
";",
"if",
"(",
"$",
"current",
"!=",
"$",
"dir",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"current",
")",
")",
"{",
"$",
"aux",
"=",
"self",
"::",
"readdir",
"(",
"$",
"current",
")",
";",
"$",
"entries",
"=",
"array_merge",
"(",
"$",
"entries",
",",
"$",
"aux",
")",
";",
"}",
"else",
"{",
"if",
"(",
"preg_match",
"(",
"\"/\\w*?Controller.php/\"",
",",
"$",
"entry",
")",
")",
"{",
"$",
"entries",
"[",
"]",
"=",
"$",
"current",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"entries",
";",
"}"
] |
Reads the contents of this dir and returns only dirs
that have first letter capitalized
@return array
|
[
"Reads",
"the",
"contents",
"of",
"this",
"dir",
"and",
"returns",
"only",
"dirs",
"that",
"have",
"first",
"letter",
"capitalized"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L264-L284
|
233,781
|
yeephp/yeephp
|
Yee/Managers/RoutingCacheManager.php
|
RoutingCacheManager.loadPath
|
protected function loadPath($path)
{
$controllers = self::readdir($path);
if(count($controllers)){
foreach($controllers as $controller){
$this->loadRoute($controller);
}
}
}
|
php
|
protected function loadPath($path)
{
$controllers = self::readdir($path);
if(count($controllers)){
foreach($controllers as $controller){
$this->loadRoute($controller);
}
}
}
|
[
"protected",
"function",
"loadPath",
"(",
"$",
"path",
")",
"{",
"$",
"controllers",
"=",
"self",
"::",
"readdir",
"(",
"$",
"path",
")",
";",
"if",
"(",
"count",
"(",
"$",
"controllers",
")",
")",
"{",
"foreach",
"(",
"$",
"controllers",
"as",
"$",
"controller",
")",
"{",
"$",
"this",
"->",
"loadRoute",
"(",
"$",
"controller",
")",
";",
"}",
"}",
"}"
] |
Load all Controller classes in an entire path
@param $path
|
[
"Load",
"all",
"Controller",
"classes",
"in",
"an",
"entire",
"path"
] |
6107f60ceaf0811a6550872bd669580ac282cb1f
|
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L291-L299
|
233,782
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
|
ClassWithNoPropertyMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithNoProperty();
case 1:
return new ClassWithNoProperty(func_get_arg(0));
case 2:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithNoProperty(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 ClassWithNoProperty(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 ClassWithNoProperty(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 ClassWithNoProperty();
case 1:
return new ClassWithNoProperty(func_get_arg(0));
case 2:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithNoProperty(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 ClassWithNoProperty(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 ClassWithNoProperty(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",
"ClassWithNoProperty",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ClassWithNoProperty",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ClassWithNoProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ClassWithNoProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ClassWithNoProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ClassWithNoProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ClassWithNoProperty",
"(",
"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",
"ClassWithNoProperty",
"(",
"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",
"ClassWithNoProperty",
"(",
"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\ClassWithNoProperty
@throws \InvalidArgumentException
@return ClassWithNoProperty
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithNoProperty"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L64-L88
|
233,783
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
|
ClassWithNoPropertyMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
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 (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",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithNoProperty"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L118-L131
|
233,784
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
|
ClassWithNoPropertyMeta.toArray
|
public static function toArray($object, $group = NULL, $filter = NULL)
{
if ($object === null) {
return null;
}
if (!isset(self::$groups[$group])) {
throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.');
} else {
$id = self::$groups[$group];
}
if (!($object instanceof ClassWithNoProperty)) {
throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.');
}
if (Stack::$objects === null) {
Stack::$objects = new \SplObjectStorage();
}
if (Stack::$objects->contains($object)) {
return null;
}
Stack::$objects->attach($object);
try {
$output = array();
} catch (\Exception $e) {
Stack::$objects->detach($object);
throw $e;
}
Stack::$objects->detach($object);
return $output;
}
|
php
|
public static function toArray($object, $group = NULL, $filter = NULL)
{
if ($object === null) {
return null;
}
if (!isset(self::$groups[$group])) {
throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.');
} else {
$id = self::$groups[$group];
}
if (!($object instanceof ClassWithNoProperty)) {
throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.');
}
if (Stack::$objects === null) {
Stack::$objects = new \SplObjectStorage();
}
if (Stack::$objects->contains($object)) {
return null;
}
Stack::$objects->attach($object);
try {
$output = array();
} catch (\Exception $e) {
Stack::$objects->detach($object);
throw $e;
}
Stack::$objects->detach($object);
return $output;
}
|
[
"public",
"static",
"function",
"toArray",
"(",
"$",
"object",
",",
"$",
"group",
"=",
"NULL",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"groups",
"[",
"$",
"group",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Group \\''",
".",
"$",
"group",
".",
"'\\' not supported for '",
".",
"'Skrz\\\\Meta\\\\Fixtures\\\\Protobuf\\\\ClassWithNoProperty'",
".",
"'.'",
")",
";",
"}",
"else",
"{",
"$",
"id",
"=",
"self",
"::",
"$",
"groups",
"[",
"$",
"group",
"]",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"ClassWithNoProperty",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty.'",
")",
";",
"}",
"if",
"(",
"Stack",
"::",
"$",
"objects",
"===",
"null",
")",
"{",
"Stack",
"::",
"$",
"objects",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"}",
"if",
"(",
"Stack",
"::",
"$",
"objects",
"->",
"contains",
"(",
"$",
"object",
")",
")",
"{",
"return",
"null",
";",
"}",
"Stack",
"::",
"$",
"objects",
"->",
"attach",
"(",
"$",
"object",
")",
";",
"try",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"Stack",
"::",
"$",
"objects",
"->",
"detach",
"(",
"$",
"object",
")",
";",
"throw",
"$",
"e",
";",
"}",
"Stack",
"::",
"$",
"objects",
"->",
"detach",
"(",
"$",
"object",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Serializes \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty to array
@param ClassWithNoProperty $object
@param string $group
@param array $filter
@throws \Exception
@return array
|
[
"Serializes",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithNoProperty",
"to",
"array"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L174-L209
|
233,785
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
|
ClassWithNoPropertyMeta.fromObject
|
public static function fromObject($input, $group = NULL, $object = NULL)
{
$input = (array)$input;
if (!isset(self::$groups[$group])) {
throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.');
} else {
$id = self::$groups[$group];
}
if ($object === null) {
$object = new ClassWithNoProperty();
} elseif (!($object instanceof ClassWithNoProperty)) {
throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.');
}
return $object;
}
|
php
|
public static function fromObject($input, $group = NULL, $object = NULL)
{
$input = (array)$input;
if (!isset(self::$groups[$group])) {
throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.');
} else {
$id = self::$groups[$group];
}
if ($object === null) {
$object = new ClassWithNoProperty();
} elseif (!($object instanceof ClassWithNoProperty)) {
throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.');
}
return $object;
}
|
[
"public",
"static",
"function",
"fromObject",
"(",
"$",
"input",
",",
"$",
"group",
"=",
"NULL",
",",
"$",
"object",
"=",
"NULL",
")",
"{",
"$",
"input",
"=",
"(",
"array",
")",
"$",
"input",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"groups",
"[",
"$",
"group",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Group \\''",
".",
"$",
"group",
".",
"'\\' not supported for '",
".",
"'Skrz\\\\Meta\\\\Fixtures\\\\Protobuf\\\\ClassWithNoProperty'",
".",
"'.'",
")",
";",
"}",
"else",
"{",
"$",
"id",
"=",
"self",
"::",
"$",
"groups",
"[",
"$",
"group",
"]",
";",
"}",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"ClassWithNoProperty",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"ClassWithNoProperty",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty.'",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] |
Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty object from object
@param object $input
@param string $group
@param ClassWithNoProperty $object
@throws \Exception
@return ClassWithNoProperty
|
[
"Creates",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithNoProperty",
"object",
"from",
"object"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L223-L240
|
233,786
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
|
ClassWithNoPropertyMeta.fromProtobuf
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new ClassWithNoProperty();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
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 ClassWithNoProperty();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
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",
"ClassWithNoProperty",
"(",
")",
";",
"}",
"if",
"(",
"$",
"end",
"===",
"null",
")",
"{",
"$",
"end",
"=",
"strlen",
"(",
"$",
"input",
")",
";",
"}",
"while",
"(",
"$",
"start",
"<",
"$",
"end",
")",
"{",
"$",
"tag",
"=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"$",
"wireType",
"=",
"$",
"tag",
"&",
"0x7",
";",
"$",
"number",
"=",
"$",
"tag",
">>",
"3",
";",
"switch",
"(",
"$",
"number",
")",
"{",
"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\ClassWithNoProperty object from serialized Protocol Buffers message.
@param string $input
@param ClassWithNoProperty $object
@param int $start
@param int $end
@throws \Exception
@return ClassWithNoProperty
|
[
"Creates",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithNoProperty",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L304-L340
|
233,787
|
kaliop-uk/kueueingbundle
|
Adapter/RabbitMq/Producer.php
|
Producer.queueDeclare
|
protected function queueDeclare()
{
if (null !== $this->queueOptions['name']) {
list($queueName, $msgCount, $consumerCount) = $this->getChannel()->queue_declare($this->queueOptions['name'], $this->queueOptions['passive'],
$this->queueOptions['durable'], $this->queueOptions['exclusive'],
$this->queueOptions['auto_delete'], $this->queueOptions['nowait'],
$this->queueOptions['arguments'], $this->queueOptions['ticket']);
if (isset($this->queueOptions['routing_keys']) && count($this->queueOptions['routing_keys']) > 0) {
foreach ($this->queueOptions['routing_keys'] as $routingKey) {
$this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $routingKey);
}
} else {
$this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $this->routingKey);
}
$this->queueStats = array(
'message_count' => $msgCount,
'consumer_count' => $consumerCount
);
$this->queueDeclared = true;
}
}
|
php
|
protected function queueDeclare()
{
if (null !== $this->queueOptions['name']) {
list($queueName, $msgCount, $consumerCount) = $this->getChannel()->queue_declare($this->queueOptions['name'], $this->queueOptions['passive'],
$this->queueOptions['durable'], $this->queueOptions['exclusive'],
$this->queueOptions['auto_delete'], $this->queueOptions['nowait'],
$this->queueOptions['arguments'], $this->queueOptions['ticket']);
if (isset($this->queueOptions['routing_keys']) && count($this->queueOptions['routing_keys']) > 0) {
foreach ($this->queueOptions['routing_keys'] as $routingKey) {
$this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $routingKey);
}
} else {
$this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $this->routingKey);
}
$this->queueStats = array(
'message_count' => $msgCount,
'consumer_count' => $consumerCount
);
$this->queueDeclared = true;
}
}
|
[
"protected",
"function",
"queueDeclare",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"queueOptions",
"[",
"'name'",
"]",
")",
"{",
"list",
"(",
"$",
"queueName",
",",
"$",
"msgCount",
",",
"$",
"consumerCount",
")",
"=",
"$",
"this",
"->",
"getChannel",
"(",
")",
"->",
"queue_declare",
"(",
"$",
"this",
"->",
"queueOptions",
"[",
"'name'",
"]",
",",
"$",
"this",
"->",
"queueOptions",
"[",
"'passive'",
"]",
",",
"$",
"this",
"->",
"queueOptions",
"[",
"'durable'",
"]",
",",
"$",
"this",
"->",
"queueOptions",
"[",
"'exclusive'",
"]",
",",
"$",
"this",
"->",
"queueOptions",
"[",
"'auto_delete'",
"]",
",",
"$",
"this",
"->",
"queueOptions",
"[",
"'nowait'",
"]",
",",
"$",
"this",
"->",
"queueOptions",
"[",
"'arguments'",
"]",
",",
"$",
"this",
"->",
"queueOptions",
"[",
"'ticket'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queueOptions",
"[",
"'routing_keys'",
"]",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"queueOptions",
"[",
"'routing_keys'",
"]",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"queueOptions",
"[",
"'routing_keys'",
"]",
"as",
"$",
"routingKey",
")",
"{",
"$",
"this",
"->",
"getChannel",
"(",
")",
"->",
"queue_bind",
"(",
"$",
"queueName",
",",
"$",
"this",
"->",
"exchangeOptions",
"[",
"'name'",
"]",
",",
"$",
"routingKey",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"getChannel",
"(",
")",
"->",
"queue_bind",
"(",
"$",
"queueName",
",",
"$",
"this",
"->",
"exchangeOptions",
"[",
"'name'",
"]",
",",
"$",
"this",
"->",
"routingKey",
")",
";",
"}",
"$",
"this",
"->",
"queueStats",
"=",
"array",
"(",
"'message_count'",
"=>",
"$",
"msgCount",
",",
"'consumer_count'",
"=>",
"$",
"consumerCount",
")",
";",
"$",
"this",
"->",
"queueDeclared",
"=",
"true",
";",
"}",
"}"
] |
Reimplement the code from BaseAmqp, to save queue stats when we can
|
[
"Reimplement",
"the",
"code",
"from",
"BaseAmqp",
"to",
"save",
"queue",
"stats",
"when",
"we",
"can"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Producer.php#L73-L95
|
233,788
|
yarcode/yii2-email-manager
|
src/transports/YiiMailer.php
|
YiiMailer.parseFrom
|
protected function parseFrom($from)
{
$parts = explode(' ', $from);
if (count($parts) == 1) {
return $from;
}
$email = array_pop($parts);
$email = trim($email, '<>');
$name = implode(' ', $parts);
return [$email => $name];
}
|
php
|
protected function parseFrom($from)
{
$parts = explode(' ', $from);
if (count($parts) == 1) {
return $from;
}
$email = array_pop($parts);
$email = trim($email, '<>');
$name = implode(' ', $parts);
return [$email => $name];
}
|
[
"protected",
"function",
"parseFrom",
"(",
"$",
"from",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"$",
"from",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"==",
"1",
")",
"{",
"return",
"$",
"from",
";",
"}",
"$",
"email",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"email",
"=",
"trim",
"(",
"$",
"email",
",",
"'<>'",
")",
";",
"$",
"name",
"=",
"implode",
"(",
"' '",
",",
"$",
"parts",
")",
";",
"return",
"[",
"$",
"email",
"=>",
"$",
"name",
"]",
";",
"}"
] |
Quick workaround for sender email
@param $from
@return string|array
|
[
"Quick",
"workaround",
"for",
"sender",
"email"
] |
4e83eae67199fc2b9eca9f08dcf59cc0440c385a
|
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/transports/YiiMailer.php#L51-L63
|
233,789
|
skrz/meta
|
src/Skrz/Meta/Fields/Fields.php
|
Fields.fromArray
|
public static function fromArray($input = [])
{
$fields = ScalarFields::getInstance();
foreach ($input as $k => $v) {
if (is_array($v)) {
$fields = $fields->appendFields($k, self::fromArray($v));
} elseif (!!$v) {
$fields = $fields->appendField($k);
}
}
return $fields;
}
|
php
|
public static function fromArray($input = [])
{
$fields = ScalarFields::getInstance();
foreach ($input as $k => $v) {
if (is_array($v)) {
$fields = $fields->appendFields($k, self::fromArray($v));
} elseif (!!$v) {
$fields = $fields->appendField($k);
}
}
return $fields;
}
|
[
"public",
"static",
"function",
"fromArray",
"(",
"$",
"input",
"=",
"[",
"]",
")",
"{",
"$",
"fields",
"=",
"ScalarFields",
"::",
"getInstance",
"(",
")",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"fields",
"=",
"$",
"fields",
"->",
"appendFields",
"(",
"$",
"k",
",",
"self",
"::",
"fromArray",
"(",
"$",
"v",
")",
")",
";",
"}",
"elseif",
"(",
"!",
"!",
"$",
"v",
")",
"{",
"$",
"fields",
"=",
"$",
"fields",
"->",
"appendField",
"(",
"$",
"k",
")",
";",
"}",
"}",
"return",
"$",
"fields",
";",
"}"
] |
Convert given array into fields.
@param array $input
@return FieldsBuilderInterface
|
[
"Convert",
"given",
"array",
"into",
"fields",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/src/Skrz/Meta/Fields/Fields.php#L28-L41
|
233,790
|
skrz/meta
|
src/Skrz/Meta/Fields/Fields.php
|
Fields.fromString
|
public static function fromString($input, $start = 0, $end = null)
{
return self::appendFromString(self::builder(), $input, $start, $end);
}
|
php
|
public static function fromString($input, $start = 0, $end = null)
{
return self::appendFromString(self::builder(), $input, $start, $end);
}
|
[
"public",
"static",
"function",
"fromString",
"(",
"$",
"input",
",",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"appendFromString",
"(",
"self",
"::",
"builder",
"(",
")",
",",
"$",
"input",
",",
"$",
"start",
",",
"$",
"end",
")",
";",
"}"
] |
Parse string into fields.
@param $input
@param int $start
@param null $end
@return FieldsBuilderInterface
|
[
"Parse",
"string",
"into",
"fields",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/src/Skrz/Meta/Fields/Fields.php#L51-L54
|
233,791
|
skrz/meta
|
src/Skrz/Meta/Fields/Fields.php
|
Fields.appendFromString
|
public static function appendFromString(FieldsBuilderInterface $builder, $input, $start = 0, $end = null)
{
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$start = self::ltrim($input, $start, $end);
if ($start >= $end) {
return $builder;
}
$p = self::pos($input, $start, $end, ".{,");
if ($p === $end) {
$p = self::rtrim($input, $start, $p);
$builder = $builder->appendField(substr($input, $start, $p - $start));
$start = $end;
} else {
$fieldName = substr($input, $start, self::rtrim($input, $start, $p) - $start);
switch ($input[$p]) {
case ".":
for ($q = self::pos($input, $p, $end, "{,"); $q < $end && $input[$q] === "{"; ++$q) {
$q = self::findBalancedRightBrace($input, $q, $end);
}
$builder = $builder->appendFields(
$fieldName,
self::appendFromString($builder->builder($fieldName), $input, $p + 1, $q)
);
$start = $q + 1;
break;
case "{":
$balancedRightBrace = self::findBalancedRightBrace($input, $p, $end);
if ($balancedRightBrace + 1 < $end && $input[$balancedRightBrace + 1] !== ",") {
throw new \InvalidArgumentException(
"Invalid fields string '{$input}' - expected ',' at position " . ($balancedRightBrace + 1) . "."
);
}
$builder = $builder->appendFields(
$fieldName,
self::appendFromString($builder->builder($fieldName), $input, $p + 1, $balancedRightBrace)
);
$start = $balancedRightBrace + 2;
break;
case ",":
$builder = $builder->appendField($fieldName);
$start = $p + 1;
break;
default:
throw new \LogicException("Unhandled char '{$input[$p]}'.");
}
}
}
return $builder;
}
|
php
|
public static function appendFromString(FieldsBuilderInterface $builder, $input, $start = 0, $end = null)
{
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$start = self::ltrim($input, $start, $end);
if ($start >= $end) {
return $builder;
}
$p = self::pos($input, $start, $end, ".{,");
if ($p === $end) {
$p = self::rtrim($input, $start, $p);
$builder = $builder->appendField(substr($input, $start, $p - $start));
$start = $end;
} else {
$fieldName = substr($input, $start, self::rtrim($input, $start, $p) - $start);
switch ($input[$p]) {
case ".":
for ($q = self::pos($input, $p, $end, "{,"); $q < $end && $input[$q] === "{"; ++$q) {
$q = self::findBalancedRightBrace($input, $q, $end);
}
$builder = $builder->appendFields(
$fieldName,
self::appendFromString($builder->builder($fieldName), $input, $p + 1, $q)
);
$start = $q + 1;
break;
case "{":
$balancedRightBrace = self::findBalancedRightBrace($input, $p, $end);
if ($balancedRightBrace + 1 < $end && $input[$balancedRightBrace + 1] !== ",") {
throw new \InvalidArgumentException(
"Invalid fields string '{$input}' - expected ',' at position " . ($balancedRightBrace + 1) . "."
);
}
$builder = $builder->appendFields(
$fieldName,
self::appendFromString($builder->builder($fieldName), $input, $p + 1, $balancedRightBrace)
);
$start = $balancedRightBrace + 2;
break;
case ",":
$builder = $builder->appendField($fieldName);
$start = $p + 1;
break;
default:
throw new \LogicException("Unhandled char '{$input[$p]}'.");
}
}
}
return $builder;
}
|
[
"public",
"static",
"function",
"appendFromString",
"(",
"FieldsBuilderInterface",
"$",
"builder",
",",
"$",
"input",
",",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"end",
"===",
"null",
")",
"{",
"$",
"end",
"=",
"strlen",
"(",
"$",
"input",
")",
";",
"}",
"while",
"(",
"$",
"start",
"<",
"$",
"end",
")",
"{",
"$",
"start",
"=",
"self",
"::",
"ltrim",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"end",
")",
";",
"if",
"(",
"$",
"start",
">=",
"$",
"end",
")",
"{",
"return",
"$",
"builder",
";",
"}",
"$",
"p",
"=",
"self",
"::",
"pos",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"end",
",",
"\".{,\"",
")",
";",
"if",
"(",
"$",
"p",
"===",
"$",
"end",
")",
"{",
"$",
"p",
"=",
"self",
"::",
"rtrim",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"p",
")",
";",
"$",
"builder",
"=",
"$",
"builder",
"->",
"appendField",
"(",
"substr",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"p",
"-",
"$",
"start",
")",
")",
";",
"$",
"start",
"=",
"$",
"end",
";",
"}",
"else",
"{",
"$",
"fieldName",
"=",
"substr",
"(",
"$",
"input",
",",
"$",
"start",
",",
"self",
"::",
"rtrim",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"p",
")",
"-",
"$",
"start",
")",
";",
"switch",
"(",
"$",
"input",
"[",
"$",
"p",
"]",
")",
"{",
"case",
"\".\"",
":",
"for",
"(",
"$",
"q",
"=",
"self",
"::",
"pos",
"(",
"$",
"input",
",",
"$",
"p",
",",
"$",
"end",
",",
"\"{,\"",
")",
";",
"$",
"q",
"<",
"$",
"end",
"&&",
"$",
"input",
"[",
"$",
"q",
"]",
"===",
"\"{\"",
";",
"++",
"$",
"q",
")",
"{",
"$",
"q",
"=",
"self",
"::",
"findBalancedRightBrace",
"(",
"$",
"input",
",",
"$",
"q",
",",
"$",
"end",
")",
";",
"}",
"$",
"builder",
"=",
"$",
"builder",
"->",
"appendFields",
"(",
"$",
"fieldName",
",",
"self",
"::",
"appendFromString",
"(",
"$",
"builder",
"->",
"builder",
"(",
"$",
"fieldName",
")",
",",
"$",
"input",
",",
"$",
"p",
"+",
"1",
",",
"$",
"q",
")",
")",
";",
"$",
"start",
"=",
"$",
"q",
"+",
"1",
";",
"break",
";",
"case",
"\"{\"",
":",
"$",
"balancedRightBrace",
"=",
"self",
"::",
"findBalancedRightBrace",
"(",
"$",
"input",
",",
"$",
"p",
",",
"$",
"end",
")",
";",
"if",
"(",
"$",
"balancedRightBrace",
"+",
"1",
"<",
"$",
"end",
"&&",
"$",
"input",
"[",
"$",
"balancedRightBrace",
"+",
"1",
"]",
"!==",
"\",\"",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid fields string '{$input}' - expected ',' at position \"",
".",
"(",
"$",
"balancedRightBrace",
"+",
"1",
")",
".",
"\".\"",
")",
";",
"}",
"$",
"builder",
"=",
"$",
"builder",
"->",
"appendFields",
"(",
"$",
"fieldName",
",",
"self",
"::",
"appendFromString",
"(",
"$",
"builder",
"->",
"builder",
"(",
"$",
"fieldName",
")",
",",
"$",
"input",
",",
"$",
"p",
"+",
"1",
",",
"$",
"balancedRightBrace",
")",
")",
";",
"$",
"start",
"=",
"$",
"balancedRightBrace",
"+",
"2",
";",
"break",
";",
"case",
"\",\"",
":",
"$",
"builder",
"=",
"$",
"builder",
"->",
"appendField",
"(",
"$",
"fieldName",
")",
";",
"$",
"start",
"=",
"$",
"p",
"+",
"1",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"Unhandled char '{$input[$p]}'.\"",
")",
";",
"}",
"}",
"}",
"return",
"$",
"builder",
";",
"}"
] |
Add fields from given string to existing field set.
@param FieldsBuilderInterface $builder
@param string $input
@param int $start
@param int $end
@return FieldsBuilderInterface
|
[
"Add",
"fields",
"from",
"given",
"string",
"to",
"existing",
"field",
"set",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/src/Skrz/Meta/Fields/Fields.php#L65-L128
|
233,792
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
|
MethodDescriptorProtoMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new MethodDescriptorProto();
case 1:
return new MethodDescriptorProto(func_get_arg(0));
case 2:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new MethodDescriptorProto(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 MethodDescriptorProto(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 MethodDescriptorProto(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 MethodDescriptorProto();
case 1:
return new MethodDescriptorProto(func_get_arg(0));
case 2:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new MethodDescriptorProto(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 MethodDescriptorProto(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 MethodDescriptorProto(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",
"MethodDescriptorProto",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"MethodDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"MethodDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"MethodDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"MethodDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"MethodDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"MethodDescriptorProto",
"(",
"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",
"MethodDescriptorProto",
"(",
"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",
"MethodDescriptorProto",
"(",
"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\MethodDescriptorProto
@throws \InvalidArgumentException
@return MethodDescriptorProto
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MethodDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L62-L86
|
233,793
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
|
MethodDescriptorProtoMeta.reset
|
public static function reset($object)
{
if (!($object instanceof MethodDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodDescriptorProto.');
}
$object->name = NULL;
$object->inputType = NULL;
$object->outputType = NULL;
$object->options = NULL;
$object->clientStreaming = NULL;
$object->serverStreaming = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof MethodDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodDescriptorProto.');
}
$object->name = NULL;
$object->inputType = NULL;
$object->outputType = NULL;
$object->options = NULL;
$object->clientStreaming = NULL;
$object->serverStreaming = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"MethodDescriptorProto",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\MethodDescriptorProto.'",
")",
";",
"}",
"$",
"object",
"->",
"name",
"=",
"NULL",
";",
"$",
"object",
"->",
"inputType",
"=",
"NULL",
";",
"$",
"object",
"->",
"outputType",
"=",
"NULL",
";",
"$",
"object",
"->",
"options",
"=",
"NULL",
";",
"$",
"object",
"->",
"clientStreaming",
"=",
"NULL",
";",
"$",
"object",
"->",
"serverStreaming",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\MethodDescriptorProto to default values
@param MethodDescriptorProto $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MethodDescriptorProto",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L99-L110
|
233,794
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
|
MethodDescriptorProtoMeta.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->inputType)) {
hash_update($ctx, 'inputType');
hash_update($ctx, (string)$object->inputType);
}
if (isset($object->outputType)) {
hash_update($ctx, 'outputType');
hash_update($ctx, (string)$object->outputType);
}
if (isset($object->options)) {
hash_update($ctx, 'options');
MethodOptionsMeta::hash($object->options, $ctx);
}
if (isset($object->clientStreaming)) {
hash_update($ctx, 'clientStreaming');
hash_update($ctx, (string)$object->clientStreaming);
}
if (isset($object->serverStreaming)) {
hash_update($ctx, 'serverStreaming');
hash_update($ctx, (string)$object->serverStreaming);
}
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->inputType)) {
hash_update($ctx, 'inputType');
hash_update($ctx, (string)$object->inputType);
}
if (isset($object->outputType)) {
hash_update($ctx, 'outputType');
hash_update($ctx, (string)$object->outputType);
}
if (isset($object->options)) {
hash_update($ctx, 'options');
MethodOptionsMeta::hash($object->options, $ctx);
}
if (isset($object->clientStreaming)) {
hash_update($ctx, 'clientStreaming');
hash_update($ctx, (string)$object->clientStreaming);
}
if (isset($object->serverStreaming)) {
hash_update($ctx, 'serverStreaming');
hash_update($ctx, (string)$object->serverStreaming);
}
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",
"->",
"inputType",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'inputType'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"inputType",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"outputType",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'outputType'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"outputType",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"options",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'options'",
")",
";",
"MethodOptionsMeta",
"::",
"hash",
"(",
"$",
"object",
"->",
"options",
",",
"$",
"ctx",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"clientStreaming",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'clientStreaming'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"clientStreaming",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"serverStreaming",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'serverStreaming'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"serverStreaming",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\MethodDescriptorProto
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MethodDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L122-L165
|
233,795
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
|
MethodDescriptorProtoMeta.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->inputType) && ($filter === null || isset($filter['inputType']))) {
$output .= "\x12";
$output .= Binary::encodeVarint(strlen($object->inputType));
$output .= $object->inputType;
}
if (isset($object->outputType) && ($filter === null || isset($filter['outputType']))) {
$output .= "\x1a";
$output .= Binary::encodeVarint(strlen($object->outputType));
$output .= $object->outputType;
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x22";
$buffer = MethodOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
if (isset($object->clientStreaming) && ($filter === null || isset($filter['clientStreaming']))) {
$output .= "\x28";
$output .= Binary::encodeVarint((int)$object->clientStreaming);
}
if (isset($object->serverStreaming) && ($filter === null || isset($filter['serverStreaming']))) {
$output .= "\x30";
$output .= Binary::encodeVarint((int)$object->serverStreaming);
}
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->inputType) && ($filter === null || isset($filter['inputType']))) {
$output .= "\x12";
$output .= Binary::encodeVarint(strlen($object->inputType));
$output .= $object->inputType;
}
if (isset($object->outputType) && ($filter === null || isset($filter['outputType']))) {
$output .= "\x1a";
$output .= Binary::encodeVarint(strlen($object->outputType));
$output .= $object->outputType;
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x22";
$buffer = MethodOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
if (isset($object->clientStreaming) && ($filter === null || isset($filter['clientStreaming']))) {
$output .= "\x28";
$output .= Binary::encodeVarint((int)$object->clientStreaming);
}
if (isset($object->serverStreaming) && ($filter === null || isset($filter['serverStreaming']))) {
$output .= "\x30";
$output .= Binary::encodeVarint((int)$object->serverStreaming);
}
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",
"->",
"inputType",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'inputType'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x12\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"inputType",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"inputType",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"outputType",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'outputType'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x1a\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"outputType",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"outputType",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"options",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'options'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x22\"",
";",
"$",
"buffer",
"=",
"MethodOptionsMeta",
"::",
"toProtobuf",
"(",
"$",
"object",
"->",
"options",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'options'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"clientStreaming",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'clientStreaming'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x28\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"(",
"int",
")",
"$",
"object",
"->",
"clientStreaming",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"serverStreaming",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'serverStreaming'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x30\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"(",
"int",
")",
"$",
"object",
"->",
"serverStreaming",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\MethodDescriptorProto to Protocol Buffers message.
@param MethodDescriptorProto $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MethodDescriptorProto",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L300-L340
|
233,796
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php
|
FileDescriptorSetMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new FileDescriptorSet();
case 1:
return new FileDescriptorSet(func_get_arg(0));
case 2:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1));
case 3:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new FileDescriptorSet(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 FileDescriptorSet(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 FileDescriptorSet(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 FileDescriptorSet();
case 1:
return new FileDescriptorSet(func_get_arg(0));
case 2:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1));
case 3:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new FileDescriptorSet(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 FileDescriptorSet(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 FileDescriptorSet(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",
"FileDescriptorSet",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"FileDescriptorSet",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"FileDescriptorSet",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"FileDescriptorSet",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"FileDescriptorSet",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"FileDescriptorSet",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"FileDescriptorSet",
"(",
"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",
"FileDescriptorSet",
"(",
"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",
"FileDescriptorSet",
"(",
"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\FileDescriptorSet
@throws \InvalidArgumentException
@return FileDescriptorSet
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"FileDescriptorSet"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php#L57-L81
|
233,797
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php
|
FileDescriptorSetMeta.fromProtobuf
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new FileDescriptorSet();
}
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);
}
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[] = FileDescriptorProtoMeta::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 FileDescriptorSet();
}
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);
}
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[] = FileDescriptorProtoMeta::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",
"FileDescriptorSet",
"(",
")",
";",
"}",
"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",
")",
";",
"}",
"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",
"[",
"]",
"=",
"FileDescriptorProtoMeta",
"::",
"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\FileDescriptorSet object from serialized Protocol Buffers message.
@param string $input
@param FileDescriptorSet $object
@param int $start
@param int $end
@throws \Exception
@return FileDescriptorSet
|
[
"Creates",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"FileDescriptorSet",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php#L147-L200
|
233,798
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php
|
FileDescriptorSetMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->file) && ($filter === null || isset($filter['file']))) {
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) {
$output .= "\x0a";
$buffer = FileDescriptorProtoMeta::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->file) && ($filter === null || isset($filter['file']))) {
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) {
$output .= "\x0a";
$buffer = FileDescriptorProtoMeta::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",
"->",
"file",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'file'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"file",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"file",
":",
"(",
"array",
")",
"$",
"object",
"->",
"file",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\x0a\"",
";",
"$",
"buffer",
"=",
"FileDescriptorProtoMeta",
"::",
"toProtobuf",
"(",
"$",
"v",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'file'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\FileDescriptorSet to Protocol Buffers message.
@param FileDescriptorSet $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"FileDescriptorSet",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php#L213-L227
|
233,799
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php
|
ServiceOptionsMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ServiceOptions();
case 1:
return new ServiceOptions(func_get_arg(0));
case 2:
return new ServiceOptions(func_get_arg(0), func_get_arg(1));
case 3:
return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ServiceOptions(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 ServiceOptions(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 ServiceOptions(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 ServiceOptions();
case 1:
return new ServiceOptions(func_get_arg(0));
case 2:
return new ServiceOptions(func_get_arg(0), func_get_arg(1));
case 3:
return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ServiceOptions(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 ServiceOptions(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 ServiceOptions(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",
"ServiceOptions",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ServiceOptions",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ServiceOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ServiceOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ServiceOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ServiceOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ServiceOptions",
"(",
"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",
"ServiceOptions",
"(",
"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",
"ServiceOptions",
"(",
"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\ServiceOptions
@throws \InvalidArgumentException
@return ServiceOptions
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceOptions"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php#L58-L82
|
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.