repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
phpguard/plugin-behat | src/Session.php | Session.unserialize | public function unserialize($serialized)
{
$data = unserialize($serialized);
$this->features = $data['features'];
$this->scenarios = $data['scenarios'];
$this->steps = $data['steps'];
$this->results = $data['results'];
$this->path = $data['path'];
$this->fs = $data['fs'];
} | php | public function unserialize($serialized)
{
$data = unserialize($serialized);
$this->features = $data['features'];
$this->scenarios = $data['scenarios'];
$this->steps = $data['steps'];
$this->results = $data['results'];
$this->path = $data['path'];
$this->fs = $data['fs'];
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
")",
"{",
"$",
"data",
"=",
"unserialize",
"(",
"$",
"serialized",
")",
";",
"$",
"this",
"->",
"features",
"=",
"$",
"data",
"[",
"'features'",
"]",
";",
"$",
"this",
"->",
"scenarios",
"=",
"$",
"data",
"[",
"'scenarios'",
"]",
";",
"$",
"this",
"->",
"steps",
"=",
"$",
"data",
"[",
"'steps'",
"]",
";",
"$",
"this",
"->",
"results",
"=",
"$",
"data",
"[",
"'results'",
"]",
";",
"$",
"this",
"->",
"path",
"=",
"$",
"data",
"[",
"'path'",
"]",
";",
"$",
"this",
"->",
"fs",
"=",
"$",
"data",
"[",
"'fs'",
"]",
";",
"}"
] | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/phpguard/plugin-behat/blob/9fa140c4355935196943d2bd8f84232cde1d7d15/src/Session.php#L101-L110 |
agentmedia/phine-core | src/Core/Modules/Backend/UserList.php | UserList.FormUrl | protected function FormUrl(User $user = null)
{
$args = array();
if ($user)
{
$args['user'] = $user->GetID();
}
return BackendRouter::ModuleUrl(new UserForm(), $args);
} | php | protected function FormUrl(User $user = null)
{
$args = array();
if ($user)
{
$args['user'] = $user->GetID();
}
return BackendRouter::ModuleUrl(new UserForm(), $args);
} | [
"protected",
"function",
"FormUrl",
"(",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"user",
")",
"{",
"$",
"args",
"[",
"'user'",
"]",
"=",
"$",
"user",
"->",
"GetID",
"(",
")",
";",
"}",
"return",
"BackendRouter",
"::",
"ModuleUrl",
"(",
"new",
"UserForm",
"(",
")",
",",
"$",
"args",
")",
";",
"}"
] | The url to the page with the user edit/create form
@param User $user If user is given, form page will be in edit mode, otherwise in create mode
@return string Returns the form page url | [
"The",
"url",
"to",
"the",
"page",
"with",
"the",
"user",
"edit",
"/",
"create",
"form"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UserList.php#L50-L58 |
agentmedia/phine-core | src/Core/Modules/Backend/UserList.php | UserList.GroupsFormUrl | protected function GroupsFormUrl(User $user)
{
$args = array('user'=>$user->GetID());
return BackendRouter::ModuleUrl(new UsergroupAssignmentForm(), $args);
} | php | protected function GroupsFormUrl(User $user)
{
$args = array('user'=>$user->GetID());
return BackendRouter::ModuleUrl(new UsergroupAssignmentForm(), $args);
} | [
"protected",
"function",
"GroupsFormUrl",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"'user'",
"=>",
"$",
"user",
"->",
"GetID",
"(",
")",
")",
";",
"return",
"BackendRouter",
"::",
"ModuleUrl",
"(",
"new",
"UsergroupAssignmentForm",
"(",
")",
",",
"$",
"args",
")",
";",
"}"
] | The url to the form for the user groups
@param User $user
@return string | [
"The",
"url",
"to",
"the",
"form",
"for",
"the",
"user",
"groups"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UserList.php#L65-L69 |
agentmedia/phine-core | src/Core/Modules/Backend/UserList.php | UserList.RemovalObject | protected function RemovalObject()
{
$id = Request::PostData('delete');
return $id ? User::Schema()->ByID($id) : null;
} | php | protected function RemovalObject()
{
$id = Request::PostData('delete');
return $id ? User::Schema()->ByID($id) : null;
} | [
"protected",
"function",
"RemovalObject",
"(",
")",
"{",
"$",
"id",
"=",
"Request",
"::",
"PostData",
"(",
"'delete'",
")",
";",
"return",
"$",
"id",
"?",
"User",
"::",
"Schema",
"(",
")",
"->",
"ByID",
"(",
"$",
"id",
")",
":",
"null",
";",
"}"
] | Gets the site for removal if delete id is posted
@return User | [
"Gets",
"the",
"site",
"for",
"removal",
"if",
"delete",
"id",
"is",
"posted"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UserList.php#L104-L108 |
agentmedia/phine-core | src/Core/Modules/Backend/UserList.php | UserList.CanEdit | protected function CanEdit(User $user)
{
return self::Guard()->Allow(BackendAction::Edit(), $user)&&
self::Guard()->Allow(BackendAction::UseIt(), new UserForm());
} | php | protected function CanEdit(User $user)
{
return self::Guard()->Allow(BackendAction::Edit(), $user)&&
self::Guard()->Allow(BackendAction::UseIt(), new UserForm());
} | [
"protected",
"function",
"CanEdit",
"(",
"User",
"$",
"user",
")",
"{",
"return",
"self",
"::",
"Guard",
"(",
")",
"->",
"Allow",
"(",
"BackendAction",
"::",
"Edit",
"(",
")",
",",
"$",
"user",
")",
"&&",
"self",
"::",
"Guard",
"(",
")",
"->",
"Allow",
"(",
"BackendAction",
"::",
"UseIt",
"(",
")",
",",
"new",
"UserForm",
"(",
")",
")",
";",
"}"
] | True if user can be edited
@param User $user
@return string | [
"True",
"if",
"user",
"can",
"be",
"edited"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UserList.php#L121-L125 |
rickard2/luhnar | Validator.php | Validator.validate | public function validate($input, $country)
{
$country = trim(strtolower($country));
if (!$this->supportsCountry($country)) {
throw new Exception('Unsupported country: ' . $country);
}
if (!$input) {
return true;
}
/** @var \Rickard2\Luhnar\Validator\Validator $validator */
$validator = new $this->countryClassMap[$country];
return $validator->validate($input);
} | php | public function validate($input, $country)
{
$country = trim(strtolower($country));
if (!$this->supportsCountry($country)) {
throw new Exception('Unsupported country: ' . $country);
}
if (!$input) {
return true;
}
/** @var \Rickard2\Luhnar\Validator\Validator $validator */
$validator = new $this->countryClassMap[$country];
return $validator->validate($input);
} | [
"public",
"function",
"validate",
"(",
"$",
"input",
",",
"$",
"country",
")",
"{",
"$",
"country",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"country",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"supportsCountry",
"(",
"$",
"country",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unsupported country: '",
".",
"$",
"country",
")",
";",
"}",
"if",
"(",
"!",
"$",
"input",
")",
"{",
"return",
"true",
";",
"}",
"/** @var \\Rickard2\\Luhnar\\Validator\\Validator $validator */",
"$",
"validator",
"=",
"new",
"$",
"this",
"->",
"countryClassMap",
"[",
"$",
"country",
"]",
";",
"return",
"$",
"validator",
"->",
"validate",
"(",
"$",
"input",
")",
";",
"}"
] | @param string $input
@param string $country
@return bool
@throws \Exception | [
"@param",
"string",
"$input",
"@param",
"string",
"$country"
] | train | https://github.com/rickard2/luhnar/blob/e2475a0648396ec51c332e31c673ac97097e48e1/Validator.php#L30-L46 |
tamagokun/rackem | lib/Rackem/Server.php | Server.init | protected function init()
{
set_time_limit(0);
$this->master = @stream_socket_server("tcp://{$this->host}:{$this->port}", $errno, $errstr);
if($this->master === false) {
echo ">> Failed to bind socket.\n", $errno, " - ", $errstr, "\n";
exit(2);
}
stream_set_blocking($this->master, 0);
echo "== Rack'em on http://{$this->host}:{$this->port}\n";
echo ">> Rack'em web server\n";
echo ">> Listening on {$this->host}:{$this->port}, CTRL+C to stop\n";
if(function_exists('pcntl_signal')) {
pcntl_signal(SIGINT, array($this, "stop"));
pcntl_signal(SIGTERM, array($this, "stop"));
}
} | php | protected function init()
{
set_time_limit(0);
$this->master = @stream_socket_server("tcp://{$this->host}:{$this->port}", $errno, $errstr);
if($this->master === false) {
echo ">> Failed to bind socket.\n", $errno, " - ", $errstr, "\n";
exit(2);
}
stream_set_blocking($this->master, 0);
echo "== Rack'em on http://{$this->host}:{$this->port}\n";
echo ">> Rack'em web server\n";
echo ">> Listening on {$this->host}:{$this->port}, CTRL+C to stop\n";
if(function_exists('pcntl_signal')) {
pcntl_signal(SIGINT, array($this, "stop"));
pcntl_signal(SIGTERM, array($this, "stop"));
}
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"set_time_limit",
"(",
"0",
")",
";",
"$",
"this",
"->",
"master",
"=",
"@",
"stream_socket_server",
"(",
"\"tcp://{$this->host}:{$this->port}\"",
",",
"$",
"errno",
",",
"$",
"errstr",
")",
";",
"if",
"(",
"$",
"this",
"->",
"master",
"===",
"false",
")",
"{",
"echo",
"\">> Failed to bind socket.\\n\"",
",",
"$",
"errno",
",",
"\" - \"",
",",
"$",
"errstr",
",",
"\"\\n\"",
";",
"exit",
"(",
"2",
")",
";",
"}",
"stream_set_blocking",
"(",
"$",
"this",
"->",
"master",
",",
"0",
")",
";",
"echo",
"\"== Rack'em on http://{$this->host}:{$this->port}\\n\"",
";",
"echo",
"\">> Rack'em web server\\n\"",
";",
"echo",
"\">> Listening on {$this->host}:{$this->port}, CTRL+C to stop\\n\"",
";",
"if",
"(",
"function_exists",
"(",
"'pcntl_signal'",
")",
")",
"{",
"pcntl_signal",
"(",
"SIGINT",
",",
"array",
"(",
"$",
"this",
",",
"\"stop\"",
")",
")",
";",
"pcntl_signal",
"(",
"SIGTERM",
",",
"array",
"(",
"$",
"this",
",",
"\"stop\"",
")",
")",
";",
"}",
"}"
] | /* private | [
"/",
"*",
"private"
] | train | https://github.com/tamagokun/rackem/blob/8f6df86f717f9e88a31a44c0bd152f22562daea9/lib/Rackem/Server.php#L153-L170 |
spiffyjr/spiffy-inject | src/Generator/ArrayGenerator.php | ArrayGenerator.generate | public function generate(Metadata $metadata)
{
return [
$metadata->getClassName(),
$this->buildConstructor($metadata),
$this->buildMethods($metadata)
];
} | php | public function generate(Metadata $metadata)
{
return [
$metadata->getClassName(),
$this->buildConstructor($metadata),
$this->buildMethods($metadata)
];
} | [
"public",
"function",
"generate",
"(",
"Metadata",
"$",
"metadata",
")",
"{",
"return",
"[",
"$",
"metadata",
"->",
"getClassName",
"(",
")",
",",
"$",
"this",
"->",
"buildConstructor",
"(",
"$",
"metadata",
")",
",",
"$",
"this",
"->",
"buildMethods",
"(",
"$",
"metadata",
")",
"]",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/spiffyjr/spiffy-inject/blob/846e365502080e1610d930329f4286489b29a25d/src/Generator/ArrayGenerator.php#L14-L21 |
rutger-speksnijder/restphp | src/RestPHP/Response/Types/Text.php | Text.transformToText | private function transformToText($data, $hypertextRoutes = [], $depth = 0)
{
// Return the data as string if it's not an array
if (!is_array($data)) {
return "{$data}\n{$this->getHypertextString($hypertextRoutes)}";
}
// Loop through the data and add to the string
$str = '';
foreach ($data as $k => $v) {
// Add tabs
for ($i = 0; $i < $depth; $i++) {
$str .= "\t";
}
if (is_array($v)) {
// Recursively transform underlying data
$str .= "{$k}: {$this->transformToText($v, [], $depth+1)}\n";
} else {
$str .= "{$k}: {$v}\n";
}
}
// Add the hypertext routes
$str .= $this->getHypertextString($hypertextRoutes);
return $str;
} | php | private function transformToText($data, $hypertextRoutes = [], $depth = 0)
{
// Return the data as string if it's not an array
if (!is_array($data)) {
return "{$data}\n{$this->getHypertextString($hypertextRoutes)}";
}
// Loop through the data and add to the string
$str = '';
foreach ($data as $k => $v) {
// Add tabs
for ($i = 0; $i < $depth; $i++) {
$str .= "\t";
}
if (is_array($v)) {
// Recursively transform underlying data
$str .= "{$k}: {$this->transformToText($v, [], $depth+1)}\n";
} else {
$str .= "{$k}: {$v}\n";
}
}
// Add the hypertext routes
$str .= $this->getHypertextString($hypertextRoutes);
return $str;
} | [
"private",
"function",
"transformToText",
"(",
"$",
"data",
",",
"$",
"hypertextRoutes",
"=",
"[",
"]",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"// Return the data as string if it's not an array",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"\"{$data}\\n{$this->getHypertextString($hypertextRoutes)}\"",
";",
"}",
"// Loop through the data and add to the string",
"$",
"str",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// Add tabs",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"depth",
";",
"$",
"i",
"++",
")",
"{",
"$",
"str",
".=",
"\"\\t\"",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"// Recursively transform underlying data",
"$",
"str",
".=",
"\"{$k}: {$this->transformToText($v, [], $depth+1)}\\n\"",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"\"{$k}: {$v}\\n\"",
";",
"}",
"}",
"// Add the hypertext routes",
"$",
"str",
".=",
"$",
"this",
"->",
"getHypertextString",
"(",
"$",
"hypertextRoutes",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Recursively converts the response into a text string.
@param mixed $data The data to transform.
@param optional array $hypertextRoutes An array with hypertext routes.
@return string The response as a text string. | [
"Recursively",
"converts",
"the",
"response",
"into",
"a",
"text",
"string",
"."
] | train | https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/Text.php#L48-L74 |
rutger-speksnijder/restphp | src/RestPHP/Response/Types/Text.php | Text.getHypertextString | private function getHypertextString($routes = [])
{
// Check if we have routes
if (!$routes) {
return '';
}
// Loop through the routes and add them to the string
$str = "links: \n";
foreach ($routes as $name => $route) {
$str .= "\trel: {$name}. href: {$route}.\n";
}
return $str;
} | php | private function getHypertextString($routes = [])
{
// Check if we have routes
if (!$routes) {
return '';
}
// Loop through the routes and add them to the string
$str = "links: \n";
foreach ($routes as $name => $route) {
$str .= "\trel: {$name}. href: {$route}.\n";
}
return $str;
} | [
"private",
"function",
"getHypertextString",
"(",
"$",
"routes",
"=",
"[",
"]",
")",
"{",
"// Check if we have routes",
"if",
"(",
"!",
"$",
"routes",
")",
"{",
"return",
"''",
";",
"}",
"// Loop through the routes and add them to the string",
"$",
"str",
"=",
"\"links: \\n\"",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"name",
"=>",
"$",
"route",
")",
"{",
"$",
"str",
".=",
"\"\\trel: {$name}. href: {$route}.\\n\"",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Transforms the hypertext routes into a string.
@param array $routes The hypertext routes.
@return string The hypertext routes transformed into a string. | [
"Transforms",
"the",
"hypertext",
"routes",
"into",
"a",
"string",
"."
] | train | https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/Text.php#L83-L96 |
locomotivemtl/charcoal-queue | src/Charcoal/Queue/AbstractQueueManager.php | AbstractQueueManager.processQueue | public function processQueue(callable $callback = null)
{
$queued = $this->loadQueueItems();
if (!is_callable($callback)) {
$callback = $this->processedCallback;
}
$success = [];
$failures = [];
$skipped = [];
foreach ($queued as $q) {
try {
$res = $q->process($this->itemCallback, $this->itemSuccessCallback, $this->itemFailureCallback);
if ($res === true) {
$success[] = $q;
} elseif ($res === false) {
$failures[] = $q;
} else {
$skipped[] = $q;
}
} catch (Exception $e) {
$this->logger->error(
sprintf('Could not process a queue item: %s', $e->getMessage())
);
$failures[] = $q;
continue;
}
// Throttle according to processing rate.
if ($this->rate > 0) {
usleep(1000000/$this->rate);
}
}
if (is_callable($callback)) {
$callback($success, $failures, $skipped);
}
return true;
} | php | public function processQueue(callable $callback = null)
{
$queued = $this->loadQueueItems();
if (!is_callable($callback)) {
$callback = $this->processedCallback;
}
$success = [];
$failures = [];
$skipped = [];
foreach ($queued as $q) {
try {
$res = $q->process($this->itemCallback, $this->itemSuccessCallback, $this->itemFailureCallback);
if ($res === true) {
$success[] = $q;
} elseif ($res === false) {
$failures[] = $q;
} else {
$skipped[] = $q;
}
} catch (Exception $e) {
$this->logger->error(
sprintf('Could not process a queue item: %s', $e->getMessage())
);
$failures[] = $q;
continue;
}
// Throttle according to processing rate.
if ($this->rate > 0) {
usleep(1000000/$this->rate);
}
}
if (is_callable($callback)) {
$callback($success, $failures, $skipped);
}
return true;
} | [
"public",
"function",
"processQueue",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"queued",
"=",
"$",
"this",
"->",
"loadQueueItems",
"(",
")",
";",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"processedCallback",
";",
"}",
"$",
"success",
"=",
"[",
"]",
";",
"$",
"failures",
"=",
"[",
"]",
";",
"$",
"skipped",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"queued",
"as",
"$",
"q",
")",
"{",
"try",
"{",
"$",
"res",
"=",
"$",
"q",
"->",
"process",
"(",
"$",
"this",
"->",
"itemCallback",
",",
"$",
"this",
"->",
"itemSuccessCallback",
",",
"$",
"this",
"->",
"itemFailureCallback",
")",
";",
"if",
"(",
"$",
"res",
"===",
"true",
")",
"{",
"$",
"success",
"[",
"]",
"=",
"$",
"q",
";",
"}",
"elseif",
"(",
"$",
"res",
"===",
"false",
")",
"{",
"$",
"failures",
"[",
"]",
"=",
"$",
"q",
";",
"}",
"else",
"{",
"$",
"skipped",
"[",
"]",
"=",
"$",
"q",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"'Could not process a queue item: %s'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"$",
"failures",
"[",
"]",
"=",
"$",
"q",
";",
"continue",
";",
"}",
"// Throttle according to processing rate.",
"if",
"(",
"$",
"this",
"->",
"rate",
">",
"0",
")",
"{",
"usleep",
"(",
"1000000",
"/",
"$",
"this",
"->",
"rate",
")",
";",
"}",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback",
"(",
"$",
"success",
",",
"$",
"failures",
",",
"$",
"skipped",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Process the items of the queue.
If no callback is passed and a self::$processedCallback is set, the latter is used.
@param callable $callback An optional alternative callback routine executed
after all queue items are processed.
@return boolean Success / Failure | [
"Process",
"the",
"items",
"of",
"the",
"queue",
"."
] | train | https://github.com/locomotivemtl/charcoal-queue/blob/90c47581cd35fbb554eca513f909171a70325b44/src/Charcoal/Queue/AbstractQueueManager.php#L257-L297 |
locomotivemtl/charcoal-queue | src/Charcoal/Queue/AbstractQueueManager.php | AbstractQueueManager.loadQueueItems | public function loadQueueItems()
{
$loader = new CollectionLoader([
'logger' => $this->logger,
'factory' => $this->queueItemFactory(),
]);
$loader->setModel($this->queueItemProto());
$loader->addFilter([
'property' => 'processed',
'value' => 0,
]);
$loader->addFilter([
'property' => 'processing_date',
'operator' => '<',
'value' => date('Y-m-d H:i:s'),
]);
$queueId = $this->queueId();
if ($queueId) {
$loader->addFilter([
'property' => 'queue_id',
'value' => $queueId,
]);
}
$loader->addOrder([
'property' => 'queued_date',
'mode' => 'asc',
]);
if ($this->limit > 0) {
$loader->setNumPerPage($this->limit);
$loader->setPage(0);
}
$queued = $loader->load();
return $queued;
} | php | public function loadQueueItems()
{
$loader = new CollectionLoader([
'logger' => $this->logger,
'factory' => $this->queueItemFactory(),
]);
$loader->setModel($this->queueItemProto());
$loader->addFilter([
'property' => 'processed',
'value' => 0,
]);
$loader->addFilter([
'property' => 'processing_date',
'operator' => '<',
'value' => date('Y-m-d H:i:s'),
]);
$queueId = $this->queueId();
if ($queueId) {
$loader->addFilter([
'property' => 'queue_id',
'value' => $queueId,
]);
}
$loader->addOrder([
'property' => 'queued_date',
'mode' => 'asc',
]);
if ($this->limit > 0) {
$loader->setNumPerPage($this->limit);
$loader->setPage(0);
}
$queued = $loader->load();
return $queued;
} | [
"public",
"function",
"loadQueueItems",
"(",
")",
"{",
"$",
"loader",
"=",
"new",
"CollectionLoader",
"(",
"[",
"'logger'",
"=>",
"$",
"this",
"->",
"logger",
",",
"'factory'",
"=>",
"$",
"this",
"->",
"queueItemFactory",
"(",
")",
",",
"]",
")",
";",
"$",
"loader",
"->",
"setModel",
"(",
"$",
"this",
"->",
"queueItemProto",
"(",
")",
")",
";",
"$",
"loader",
"->",
"addFilter",
"(",
"[",
"'property'",
"=>",
"'processed'",
",",
"'value'",
"=>",
"0",
",",
"]",
")",
";",
"$",
"loader",
"->",
"addFilter",
"(",
"[",
"'property'",
"=>",
"'processing_date'",
",",
"'operator'",
"=>",
"'<'",
",",
"'value'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"]",
")",
";",
"$",
"queueId",
"=",
"$",
"this",
"->",
"queueId",
"(",
")",
";",
"if",
"(",
"$",
"queueId",
")",
"{",
"$",
"loader",
"->",
"addFilter",
"(",
"[",
"'property'",
"=>",
"'queue_id'",
",",
"'value'",
"=>",
"$",
"queueId",
",",
"]",
")",
";",
"}",
"$",
"loader",
"->",
"addOrder",
"(",
"[",
"'property'",
"=>",
"'queued_date'",
",",
"'mode'",
"=>",
"'asc'",
",",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"limit",
">",
"0",
")",
"{",
"$",
"loader",
"->",
"setNumPerPage",
"(",
"$",
"this",
"->",
"limit",
")",
";",
"$",
"loader",
"->",
"setPage",
"(",
"0",
")",
";",
"}",
"$",
"queued",
"=",
"$",
"loader",
"->",
"load",
"(",
")",
";",
"return",
"$",
"queued",
";",
"}"
] | Retrieve the items of the current queue.
@return \Charcoal\Model\Collection|array | [
"Retrieve",
"the",
"items",
"of",
"the",
"current",
"queue",
"."
] | train | https://github.com/locomotivemtl/charcoal-queue/blob/90c47581cd35fbb554eca513f909171a70325b44/src/Charcoal/Queue/AbstractQueueManager.php#L304-L342 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setEmail | public function setEmail($email)
{
if (!is_string($email)) {
$email = strval($email);
}
$this->email = $email;
} | php | public function setEmail($email)
{
if (!is_string($email)) {
$email = strval($email);
}
$this->email = $email;
} | [
"public",
"function",
"setEmail",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"email",
")",
")",
"{",
"$",
"email",
"=",
"strval",
"(",
"$",
"email",
")",
";",
"}",
"$",
"this",
"->",
"email",
"=",
"$",
"email",
";",
"}"
] | Sets the email address.
@param string $email email address
@return void | [
"Sets",
"the",
"email",
"address",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L231-L238 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setTelno | public function setTelno($telno)
{
if (!is_string($telno)) {
$telno = strval($telno);
}
$this->telno = $telno;
} | php | public function setTelno($telno)
{
if (!is_string($telno)) {
$telno = strval($telno);
}
$this->telno = $telno;
} | [
"public",
"function",
"setTelno",
"(",
"$",
"telno",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"telno",
")",
")",
"{",
"$",
"telno",
"=",
"strval",
"(",
"$",
"telno",
")",
";",
"}",
"$",
"this",
"->",
"telno",
"=",
"$",
"telno",
";",
"}"
] | Sets the phone number.
@param string $telno telno
@return void | [
"Sets",
"the",
"phone",
"number",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L257-L263 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setCellno | public function setCellno($cellno)
{
if (!is_string($cellno)) {
$cellno = strval($cellno);
}
$this->cellno = $cellno;
} | php | public function setCellno($cellno)
{
if (!is_string($cellno)) {
$cellno = strval($cellno);
}
$this->cellno = $cellno;
} | [
"public",
"function",
"setCellno",
"(",
"$",
"cellno",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"cellno",
")",
")",
"{",
"$",
"cellno",
"=",
"strval",
"(",
"$",
"cellno",
")",
";",
"}",
"$",
"this",
"->",
"cellno",
"=",
"$",
"cellno",
";",
"}"
] | Sets the cellphone number.
@param string $cellno mobile number
@return void | [
"Sets",
"the",
"cellphone",
"number",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L282-L289 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setFirstName | public function setFirstName($fname)
{
if (!is_string($fname)) {
$fname = strval($fname);
}
$this->fname = $fname;
} | php | public function setFirstName($fname)
{
if (!is_string($fname)) {
$fname = strval($fname);
}
$this->fname = $fname;
} | [
"public",
"function",
"setFirstName",
"(",
"$",
"fname",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"fname",
")",
")",
"{",
"$",
"fname",
"=",
"strval",
"(",
"$",
"fname",
")",
";",
"}",
"$",
"this",
"->",
"fname",
"=",
"$",
"fname",
";",
"}"
] | Sets the first name.
@param string $fname firstname
@return void | [
"Sets",
"the",
"first",
"name",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L308-L315 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setLastName | public function setLastName($lname)
{
if (!is_string($lname)) {
$lname = strval($lname);
}
$this->lname = $lname;
} | php | public function setLastName($lname)
{
if (!is_string($lname)) {
$lname = strval($lname);
}
$this->lname = $lname;
} | [
"public",
"function",
"setLastName",
"(",
"$",
"lname",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"lname",
")",
")",
"{",
"$",
"lname",
"=",
"strval",
"(",
"$",
"lname",
")",
";",
"}",
"$",
"this",
"->",
"lname",
"=",
"$",
"lname",
";",
"}"
] | Sets the last name.
@param string $lname lastname
@return void | [
"Sets",
"the",
"last",
"name",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L334-L341 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setCompanyName | public function setCompanyName($company)
{
if (!is_string($company)) {
$company = strval($company);
}
$this->company = $company;
} | php | public function setCompanyName($company)
{
if (!is_string($company)) {
$company = strval($company);
}
$this->company = $company;
} | [
"public",
"function",
"setCompanyName",
"(",
"$",
"company",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"company",
")",
")",
"{",
"$",
"company",
"=",
"strval",
"(",
"$",
"company",
")",
";",
"}",
"$",
"this",
"->",
"company",
"=",
"$",
"company",
";",
"}"
] | Sets the company name.
If the purchase results in a company purchase,
reference person will be used from first and last name,
or the value set with {@link Klarna::setReference()}.
@param string $company company name
@see Klarna::setReference
@return void | [
"Sets",
"the",
"company",
"name",
".",
"If",
"the",
"purchase",
"results",
"in",
"a",
"company",
"purchase",
"reference",
"person",
"will",
"be",
"used",
"from",
"first",
"and",
"last",
"name",
"or",
"the",
"value",
"set",
"with",
"{",
"@link",
"Klarna",
"::",
"setReference",
"()",
"}",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L364-L371 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setCareof | public function setCareof($careof)
{
if (!is_string($careof)) {
$careof = strval($careof);
}
$this->careof = $careof;
} | php | public function setCareof($careof)
{
if (!is_string($careof)) {
$careof = strval($careof);
}
$this->careof = $careof;
} | [
"public",
"function",
"setCareof",
"(",
"$",
"careof",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"careof",
")",
")",
"{",
"$",
"careof",
"=",
"strval",
"(",
"$",
"careof",
")",
";",
"}",
"$",
"this",
"->",
"careof",
"=",
"$",
"careof",
";",
"}"
] | Sets the care of, C/O.
@param string $careof care of address
@return void | [
"Sets",
"the",
"care",
"of",
"C",
"/",
"O",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L390-L397 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setStreet | public function setStreet($street)
{
if (!is_string($street)) {
$street = strval($street);
}
$this->street = $street;
} | php | public function setStreet($street)
{
if (!is_string($street)) {
$street = strval($street);
}
$this->street = $street;
} | [
"public",
"function",
"setStreet",
"(",
"$",
"street",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"street",
")",
")",
"{",
"$",
"street",
"=",
"strval",
"(",
"$",
"street",
")",
";",
"}",
"$",
"this",
"->",
"street",
"=",
"$",
"street",
";",
"}"
] | Sets the street address.
@param string $street street address
@return void | [
"Sets",
"the",
"street",
"address",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L416-L423 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setZipCode | public function setZipCode($zip)
{
if (!is_string($zip)) {
$zip = strval($zip);
}
$zip = str_replace(' ', '', $zip); //remove spaces
$this->zip = $zip;
} | php | public function setZipCode($zip)
{
if (!is_string($zip)) {
$zip = strval($zip);
}
$zip = str_replace(' ', '', $zip); //remove spaces
$this->zip = $zip;
} | [
"public",
"function",
"setZipCode",
"(",
"$",
"zip",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"zip",
")",
")",
"{",
"$",
"zip",
"=",
"strval",
"(",
"$",
"zip",
")",
";",
"}",
"$",
"zip",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"zip",
")",
";",
"//remove spaces",
"$",
"this",
"->",
"zip",
"=",
"$",
"zip",
";",
"}"
] | Sets the zip code.
@param string $zip zip code
@return void | [
"Sets",
"the",
"zip",
"code",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L442-L452 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setCity | public function setCity($city)
{
if (!is_string($city)) {
$city = strval($city);
}
$this->city = $city;
} | php | public function setCity($city)
{
if (!is_string($city)) {
$city = strval($city);
}
$this->city = $city;
} | [
"public",
"function",
"setCity",
"(",
"$",
"city",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"city",
")",
")",
"{",
"$",
"city",
"=",
"strval",
"(",
"$",
"city",
")",
";",
"}",
"$",
"this",
"->",
"city",
"=",
"$",
"city",
";",
"}"
] | Sets the city.
@param string $city city
@return void | [
"Sets",
"the",
"city",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L471-L478 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setCountry | public function setCountry($country)
{
if ($country === null) {
throw new Klarna_ArgumentNotSetException('Country');
}
if (is_numeric($country)) {
if (!is_int($country)) {
$country = intval($country);
}
$this->country = $country;
return;
}
if (strlen($country) == 2 || strlen($country) == 3) {
$this->setCountry(KlarnaCountry::fromCode($country));
return;
}
throw new KlarnaException("Failed to set country! ($country)");
} | php | public function setCountry($country)
{
if ($country === null) {
throw new Klarna_ArgumentNotSetException('Country');
}
if (is_numeric($country)) {
if (!is_int($country)) {
$country = intval($country);
}
$this->country = $country;
return;
}
if (strlen($country) == 2 || strlen($country) == 3) {
$this->setCountry(KlarnaCountry::fromCode($country));
return;
}
throw new KlarnaException("Failed to set country! ($country)");
} | [
"public",
"function",
"setCountry",
"(",
"$",
"country",
")",
"{",
"if",
"(",
"$",
"country",
"===",
"null",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"'Country'",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"country",
")",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"country",
")",
")",
"{",
"$",
"country",
"=",
"intval",
"(",
"$",
"country",
")",
";",
"}",
"$",
"this",
"->",
"country",
"=",
"$",
"country",
";",
"return",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"country",
")",
"==",
"2",
"||",
"strlen",
"(",
"$",
"country",
")",
"==",
"3",
")",
"{",
"$",
"this",
"->",
"setCountry",
"(",
"KlarnaCountry",
"::",
"fromCode",
"(",
"$",
"country",
")",
")",
";",
"return",
";",
"}",
"throw",
"new",
"KlarnaException",
"(",
"\"Failed to set country! ($country)\"",
")",
";",
"}"
] | Sets the country, use either a two letter representation or the integer
constant.
@param int $country {@link KlarnaCountry}
@throws KlarnaException
@return void | [
"Sets",
"the",
"country",
"use",
"either",
"a",
"two",
"letter",
"representation",
"or",
"the",
"integer",
"constant",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L510-L527 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setHouseNumber | public function setHouseNumber($houseNo)
{
if (!is_string($houseNo)) {
$houseNo = strval($houseNo);
}
$this->houseNo = $houseNo;
} | php | public function setHouseNumber($houseNo)
{
if (!is_string($houseNo)) {
$houseNo = strval($houseNo);
}
$this->houseNo = $houseNo;
} | [
"public",
"function",
"setHouseNumber",
"(",
"$",
"houseNo",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"houseNo",
")",
")",
"{",
"$",
"houseNo",
"=",
"strval",
"(",
"$",
"houseNo",
")",
";",
"}",
"$",
"this",
"->",
"houseNo",
"=",
"$",
"houseNo",
";",
"}"
] | Sets the house number.<br>
Only used in Germany and Netherlands.<br>
@param string $houseNo house number
@return void | [
"Sets",
"the",
"house",
"number",
".",
"<br",
">",
"Only",
"used",
"in",
"Germany",
"and",
"Netherlands",
".",
"<br",
">"
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L548-L555 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.setHouseExt | public function setHouseExt($houseExt)
{
if (!is_string($houseExt)) {
$houseExt = strval($houseExt);
}
$this->houseExt = $houseExt;
} | php | public function setHouseExt($houseExt)
{
if (!is_string($houseExt)) {
$houseExt = strval($houseExt);
}
$this->houseExt = $houseExt;
} | [
"public",
"function",
"setHouseExt",
"(",
"$",
"houseExt",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"houseExt",
")",
")",
"{",
"$",
"houseExt",
"=",
"strval",
"(",
"$",
"houseExt",
")",
";",
"}",
"$",
"this",
"->",
"houseExt",
"=",
"$",
"houseExt",
";",
"}"
] | Sets the house extension.<br>
Only used in Netherlands.<br>
@param string $houseExt house extension
@return void | [
"Sets",
"the",
"house",
"extension",
".",
"<br",
">",
"Only",
"used",
"in",
"Netherlands",
".",
"<br",
">"
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L576-L583 |
Subscribo/klarna-invoice-sdk-wrapped | src/klarnaaddr.php | KlarnaAddr.toArray | public function toArray()
{
return array(
'email' => $this->getEmail(),
'telno' => $this->getTelno(),
'cellno' => $this->getCellno(),
'fname' => $this->getFirstName(),
'lname' => $this->getLastName(),
'company' => $this->getCompanyName(),
'careof' => $this->getCareof(),
'street' => $this->getStreet(),
'house_number' => $this->getHouseNumber(),
'house_extension' => $this->getHouseExt(),
'zip' => $this->getZipCode(),
'city' => $this->getCity(),
'country' => $this->getCountry(),
);
} | php | public function toArray()
{
return array(
'email' => $this->getEmail(),
'telno' => $this->getTelno(),
'cellno' => $this->getCellno(),
'fname' => $this->getFirstName(),
'lname' => $this->getLastName(),
'company' => $this->getCompanyName(),
'careof' => $this->getCareof(),
'street' => $this->getStreet(),
'house_number' => $this->getHouseNumber(),
'house_extension' => $this->getHouseExt(),
'zip' => $this->getZipCode(),
'city' => $this->getCity(),
'country' => $this->getCountry(),
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'email'",
"=>",
"$",
"this",
"->",
"getEmail",
"(",
")",
",",
"'telno'",
"=>",
"$",
"this",
"->",
"getTelno",
"(",
")",
",",
"'cellno'",
"=>",
"$",
"this",
"->",
"getCellno",
"(",
")",
",",
"'fname'",
"=>",
"$",
"this",
"->",
"getFirstName",
"(",
")",
",",
"'lname'",
"=>",
"$",
"this",
"->",
"getLastName",
"(",
")",
",",
"'company'",
"=>",
"$",
"this",
"->",
"getCompanyName",
"(",
")",
",",
"'careof'",
"=>",
"$",
"this",
"->",
"getCareof",
"(",
")",
",",
"'street'",
"=>",
"$",
"this",
"->",
"getStreet",
"(",
")",
",",
"'house_number'",
"=>",
"$",
"this",
"->",
"getHouseNumber",
"(",
")",
",",
"'house_extension'",
"=>",
"$",
"this",
"->",
"getHouseExt",
"(",
")",
",",
"'zip'",
"=>",
"$",
"this",
"->",
"getZipCode",
"(",
")",
",",
"'city'",
"=>",
"$",
"this",
"->",
"getCity",
"(",
")",
",",
"'country'",
"=>",
"$",
"this",
"->",
"getCountry",
"(",
")",
",",
")",
";",
"}"
] | Returns an associative array representing this object.
@return array | [
"Returns",
"an",
"associative",
"array",
"representing",
"this",
"object",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L590-L607 |
Talis90/HtmlMediaFinder | library/HtmlMediaFinder/RemoteXpathAdapter.php | RemoteXpathAdapter.remoteXpathQuery | static function remoteXpathQuery($url, $xpath, array $post = []) {
if (count($post) > 0) {
$cont = self::postRequest($url, $post);
} else {
$cont = file_get_contents($url);
}
return self::xpathQuery($cont, $xpath);
} | php | static function remoteXpathQuery($url, $xpath, array $post = []) {
if (count($post) > 0) {
$cont = self::postRequest($url, $post);
} else {
$cont = file_get_contents($url);
}
return self::xpathQuery($cont, $xpath);
} | [
"static",
"function",
"remoteXpathQuery",
"(",
"$",
"url",
",",
"$",
"xpath",
",",
"array",
"$",
"post",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"post",
")",
">",
"0",
")",
"{",
"$",
"cont",
"=",
"self",
"::",
"postRequest",
"(",
"$",
"url",
",",
"$",
"post",
")",
";",
"}",
"else",
"{",
"$",
"cont",
"=",
"file_get_contents",
"(",
"$",
"url",
")",
";",
"}",
"return",
"self",
"::",
"xpathQuery",
"(",
"$",
"cont",
",",
"$",
"xpath",
")",
";",
"}"
] | Curl the $url and get the elements matching the given $xpath
@param string $url
@param string $xpath
@return DOMNodeList | [
"Curl",
"the",
"$url",
"and",
"get",
"the",
"elements",
"matching",
"the",
"given",
"$xpath"
] | train | https://github.com/Talis90/HtmlMediaFinder/blob/fd19212a88d5d3f78d20aeea1accf7be427643b0/library/HtmlMediaFinder/RemoteXpathAdapter.php#L13-L20 |
Talis90/HtmlMediaFinder | library/HtmlMediaFinder/RemoteXpathAdapter.php | RemoteXpathAdapter.xpathQuery | static function xpathQuery($html, $xpath) {
$ddoc = new \DOMDocument();
@$ddoc->loadHTML($html);
$dxpath = new \DOMXPath($ddoc);
return $dxpath->query($xpath);
} | php | static function xpathQuery($html, $xpath) {
$ddoc = new \DOMDocument();
@$ddoc->loadHTML($html);
$dxpath = new \DOMXPath($ddoc);
return $dxpath->query($xpath);
} | [
"static",
"function",
"xpathQuery",
"(",
"$",
"html",
",",
"$",
"xpath",
")",
"{",
"$",
"ddoc",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"@",
"$",
"ddoc",
"->",
"loadHTML",
"(",
"$",
"html",
")",
";",
"$",
"dxpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"ddoc",
")",
";",
"return",
"$",
"dxpath",
"->",
"query",
"(",
"$",
"xpath",
")",
";",
"}"
] | Get the elements matching the given $xpath
@param string $html
@param string $xpath
@return DOMNodeList | [
"Get",
"the",
"elements",
"matching",
"the",
"given",
"$xpath"
] | train | https://github.com/Talis90/HtmlMediaFinder/blob/fd19212a88d5d3f78d20aeea1accf7be427643b0/library/HtmlMediaFinder/RemoteXpathAdapter.php#L28-L34 |
Talis90/HtmlMediaFinder | library/HtmlMediaFinder/RemoteXpathAdapter.php | RemoteXpathAdapter.postRequest | static function postRequest($url, array $post) {
$handle = curl_init($url);
curl_setopt_array($handle, [
CURLOPT_POST => count($post),
CURLOPT_POSTFIELDS => http_build_query($post),
CURLOPT_RETURNTRANSFER => 1
]);
$result = curl_exec($handle);
curl_close($handle);
return $result;
} | php | static function postRequest($url, array $post) {
$handle = curl_init($url);
curl_setopt_array($handle, [
CURLOPT_POST => count($post),
CURLOPT_POSTFIELDS => http_build_query($post),
CURLOPT_RETURNTRANSFER => 1
]);
$result = curl_exec($handle);
curl_close($handle);
return $result;
} | [
"static",
"function",
"postRequest",
"(",
"$",
"url",
",",
"array",
"$",
"post",
")",
"{",
"$",
"handle",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt_array",
"(",
"$",
"handle",
",",
"[",
"CURLOPT_POST",
"=>",
"count",
"(",
"$",
"post",
")",
",",
"CURLOPT_POSTFIELDS",
"=>",
"http_build_query",
"(",
"$",
"post",
")",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"1",
"]",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"handle",
")",
";",
"curl_close",
"(",
"$",
"handle",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Get result string of post request
@param string $url
@param array $post
@return string | [
"Get",
"result",
"string",
"of",
"post",
"request"
] | train | https://github.com/Talis90/HtmlMediaFinder/blob/fd19212a88d5d3f78d20aeea1accf7be427643b0/library/HtmlMediaFinder/RemoteXpathAdapter.php#L42-L55 |
romm/configuration_object | Classes/Validation/Validator/Internal/MixedTypeValidator.php | MixedTypeValidator.isValid | public function isValid($object)
{
if (is_object($object)) {
$validator = Core::get()->getValidatorResolver()
->getBaseValidatorConjunction(get_class($object));
$this->result->merge($validator->validate($object));
}
} | php | public function isValid($object)
{
if (is_object($object)) {
$validator = Core::get()->getValidatorResolver()
->getBaseValidatorConjunction(get_class($object));
$this->result->merge($validator->validate($object));
}
} | [
"public",
"function",
"isValid",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"$",
"validator",
"=",
"Core",
"::",
"get",
"(",
")",
"->",
"getValidatorResolver",
"(",
")",
"->",
"getBaseValidatorConjunction",
"(",
"get_class",
"(",
"$",
"object",
")",
")",
";",
"$",
"this",
"->",
"result",
"->",
"merge",
"(",
"$",
"validator",
"->",
"validate",
"(",
"$",
"object",
")",
")",
";",
"}",
"}"
] | The property of the object is a mixed type: the validator could not be
guessed in the validator resolver, because the property was not filled
yet.
We have to build the resolver now for the given object and merge its
result with the result of this validator.
@inheritdoc | [
"The",
"property",
"of",
"the",
"object",
"is",
"a",
"mixed",
"type",
":",
"the",
"validator",
"could",
"not",
"be",
"guessed",
"in",
"the",
"validator",
"resolver",
"because",
"the",
"property",
"was",
"not",
"filled",
"yet",
"."
] | train | https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Validation/Validator/Internal/MixedTypeValidator.php#L35-L43 |
koolkode/meta | src/Source/SourceParser.php | SourceParser.parse | public function parse(SourceStream $code, SourceStorageInterface $storage = NULL)
{
$buffer = new SourceBuffer();
$this->doParse($code, $buffer, $storage);
return $buffer;
} | php | public function parse(SourceStream $code, SourceStorageInterface $storage = NULL)
{
$buffer = new SourceBuffer();
$this->doParse($code, $buffer, $storage);
return $buffer;
} | [
"public",
"function",
"parse",
"(",
"SourceStream",
"$",
"code",
",",
"SourceStorageInterface",
"$",
"storage",
"=",
"NULL",
")",
"{",
"$",
"buffer",
"=",
"new",
"SourceBuffer",
"(",
")",
";",
"$",
"this",
"->",
"doParse",
"(",
"$",
"code",
",",
"$",
"buffer",
",",
"$",
"storage",
")",
";",
"return",
"$",
"buffer",
";",
"}"
] | Parse the given code and create a SourceGenerator from it, extracted data for static
analysis is stored in the given storage implementation.
@param SourceStream $code The source code to be parsed.
@param SourceStorageInterface $storage The stoage implementation for extracted data.
@return SourceGenerator | [
"Parse",
"the",
"given",
"code",
"and",
"create",
"a",
"SourceGenerator",
"from",
"it",
"extracted",
"data",
"for",
"static",
"analysis",
"is",
"stored",
"in",
"the",
"given",
"storage",
"implementation",
"."
] | train | https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L40-L46 |
koolkode/meta | src/Source/SourceParser.php | SourceParser.lookup | protected function lookup($localName, $namespace = '', array $import = [])
{
if($localName == '')
{
return $localName;
}
switch(strtolower($localName))
{
case 'bool':
case 'int':
case 'float':
case 'string':
case 'array':
case 'callable':
return strtolower($localName);
break;
}
if($localName[0] == '\\')
{
return ltrim($localName, '\\');
}
if(false === (strpos($localName, '\\')))
{
$n = strtolower($localName);
return isset($import[$n]) ? $import[$n] : ltrim($namespace . '\\' . $localName, '\\');
}
$parts = explode('\\', $localName, 2);
$alias = strtolower($parts[0]);
if(isset($import[$alias]))
{
return ltrim($import[$alias] . '\\' . $parts[1], '\\');
}
return ltrim($namespace . '\\' . $localName, '\\');
} | php | protected function lookup($localName, $namespace = '', array $import = [])
{
if($localName == '')
{
return $localName;
}
switch(strtolower($localName))
{
case 'bool':
case 'int':
case 'float':
case 'string':
case 'array':
case 'callable':
return strtolower($localName);
break;
}
if($localName[0] == '\\')
{
return ltrim($localName, '\\');
}
if(false === (strpos($localName, '\\')))
{
$n = strtolower($localName);
return isset($import[$n]) ? $import[$n] : ltrim($namespace . '\\' . $localName, '\\');
}
$parts = explode('\\', $localName, 2);
$alias = strtolower($parts[0]);
if(isset($import[$alias]))
{
return ltrim($import[$alias] . '\\' . $parts[1], '\\');
}
return ltrim($namespace . '\\' . $localName, '\\');
} | [
"protected",
"function",
"lookup",
"(",
"$",
"localName",
",",
"$",
"namespace",
"=",
"''",
",",
"array",
"$",
"import",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"localName",
"==",
"''",
")",
"{",
"return",
"$",
"localName",
";",
"}",
"switch",
"(",
"strtolower",
"(",
"$",
"localName",
")",
")",
"{",
"case",
"'bool'",
":",
"case",
"'int'",
":",
"case",
"'float'",
":",
"case",
"'string'",
":",
"case",
"'array'",
":",
"case",
"'callable'",
":",
"return",
"strtolower",
"(",
"$",
"localName",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"localName",
"[",
"0",
"]",
"==",
"'\\\\'",
")",
"{",
"return",
"ltrim",
"(",
"$",
"localName",
",",
"'\\\\'",
")",
";",
"}",
"if",
"(",
"false",
"===",
"(",
"strpos",
"(",
"$",
"localName",
",",
"'\\\\'",
")",
")",
")",
"{",
"$",
"n",
"=",
"strtolower",
"(",
"$",
"localName",
")",
";",
"return",
"isset",
"(",
"$",
"import",
"[",
"$",
"n",
"]",
")",
"?",
"$",
"import",
"[",
"$",
"n",
"]",
":",
"ltrim",
"(",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"localName",
",",
"'\\\\'",
")",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"localName",
",",
"2",
")",
";",
"$",
"alias",
"=",
"strtolower",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"import",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"return",
"ltrim",
"(",
"$",
"import",
"[",
"$",
"alias",
"]",
".",
"'\\\\'",
".",
"$",
"parts",
"[",
"1",
"]",
",",
"'\\\\'",
")",
";",
"}",
"return",
"ltrim",
"(",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"localName",
",",
"'\\\\'",
")",
";",
"}"
] | Lookup a fully qualified name in the given namespace considering imports.
@param string $localName
@param string $namespace
@param array<string, string> $import
@return string | [
"Lookup",
"a",
"fully",
"qualified",
"name",
"in",
"the",
"given",
"namespace",
"considering",
"imports",
"."
] | train | https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L638-L678 |
koolkode/meta | src/Source/SourceParser.php | SourceParser.parseTypeModifiers | protected function parseTypeModifiers(array $tokens)
{
$modifiers = 0;
foreach($tokens as $tok)
{
if(is_array($tok))
{
switch($tok[0])
{
case T_ABSTRACT:
$modifiers |= MetaInfo::IS_ABSTRACT;
break;
case T_FINAL:
$modifiers |= MetaInfo::IS_FINAL;
break;
}
}
}
return $modifiers;
} | php | protected function parseTypeModifiers(array $tokens)
{
$modifiers = 0;
foreach($tokens as $tok)
{
if(is_array($tok))
{
switch($tok[0])
{
case T_ABSTRACT:
$modifiers |= MetaInfo::IS_ABSTRACT;
break;
case T_FINAL:
$modifiers |= MetaInfo::IS_FINAL;
break;
}
}
}
return $modifiers;
} | [
"protected",
"function",
"parseTypeModifiers",
"(",
"array",
"$",
"tokens",
")",
"{",
"$",
"modifiers",
"=",
"0",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"tok",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tok",
")",
")",
"{",
"switch",
"(",
"$",
"tok",
"[",
"0",
"]",
")",
"{",
"case",
"T_ABSTRACT",
":",
"$",
"modifiers",
"|=",
"MetaInfo",
"::",
"IS_ABSTRACT",
";",
"break",
";",
"case",
"T_FINAL",
":",
"$",
"modifiers",
"|=",
"MetaInfo",
"::",
"IS_FINAL",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"modifiers",
";",
"}"
] | Extract all type modifiers from the given tokens and combine them into a bit mask.
@param array $tokens
@return integer | [
"Extract",
"all",
"type",
"modifiers",
"from",
"the",
"given",
"tokens",
"and",
"combine",
"them",
"into",
"a",
"bit",
"mask",
"."
] | train | https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L686-L707 |
koolkode/meta | src/Source/SourceParser.php | SourceParser.parseFieldModifiers | protected function parseFieldModifiers(array $tokens)
{
$modifiers = MetaInfo::IS_PUBLIC;
foreach($tokens as $tok)
{
if(is_array($tok))
{
switch($tok[0])
{
case T_VAR:
case T_PUBLIC:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC;
break;
case T_PRIVATE:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE;
break;
case T_PROTECTED:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED;
break;
case T_STATIC:
$modifiers |= MetaInfo::IS_STATIC;
break;
}
}
}
return $modifiers;
} | php | protected function parseFieldModifiers(array $tokens)
{
$modifiers = MetaInfo::IS_PUBLIC;
foreach($tokens as $tok)
{
if(is_array($tok))
{
switch($tok[0])
{
case T_VAR:
case T_PUBLIC:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC;
break;
case T_PRIVATE:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE;
break;
case T_PROTECTED:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED;
break;
case T_STATIC:
$modifiers |= MetaInfo::IS_STATIC;
break;
}
}
}
return $modifiers;
} | [
"protected",
"function",
"parseFieldModifiers",
"(",
"array",
"$",
"tokens",
")",
"{",
"$",
"modifiers",
"=",
"MetaInfo",
"::",
"IS_PUBLIC",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"tok",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tok",
")",
")",
"{",
"switch",
"(",
"$",
"tok",
"[",
"0",
"]",
")",
"{",
"case",
"T_VAR",
":",
"case",
"T_PUBLIC",
":",
"$",
"modifiers",
"=",
"(",
"$",
"modifiers",
"|",
"MetaInfo",
"::",
"MASK_VISIBILITY",
")",
"^",
"MetaInfo",
"::",
"IS_NOT_PUBLIC",
";",
"break",
";",
"case",
"T_PRIVATE",
":",
"$",
"modifiers",
"=",
"(",
"$",
"modifiers",
"|",
"MetaInfo",
"::",
"MASK_VISIBILITY",
")",
"^",
"MetaInfo",
"::",
"IS_NOT_PRIVATE",
";",
"break",
";",
"case",
"T_PROTECTED",
":",
"$",
"modifiers",
"=",
"(",
"$",
"modifiers",
"|",
"MetaInfo",
"::",
"MASK_VISIBILITY",
")",
"^",
"MetaInfo",
"::",
"IS_NOT_PROTECTED",
";",
"break",
";",
"case",
"T_STATIC",
":",
"$",
"modifiers",
"|=",
"MetaInfo",
"::",
"IS_STATIC",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"modifiers",
";",
"}"
] | Parse all field modifiers from the given tokens and combine them into a bit mask.
@param array $tokens
@return integer | [
"Parse",
"all",
"field",
"modifiers",
"from",
"the",
"given",
"tokens",
"and",
"combine",
"them",
"into",
"a",
"bit",
"mask",
"."
] | train | https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L715-L743 |
koolkode/meta | src/Source/SourceParser.php | SourceParser.parseMethodModifiers | protected function parseMethodModifiers(array $tokens)
{
$modifiers = MetaInfo::IS_PUBLIC;
foreach($tokens as $tok)
{
if(is_array($tok))
{
switch($tok[0])
{
case T_PUBLIC:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC;
break;
case T_PRIVATE:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE;
break;
case T_PROTECTED:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED;
break;
case T_STATIC:
$modifiers |= MetaInfo::IS_STATIC;
break;
case T_ABSTRACT:
$modifiers |= MetaInfo::IS_ABSTRACT;
break;
case T_FINAL:
$modifiers |= MetaInfo::IS_FINAL;
break;
}
}
}
return $modifiers;
} | php | protected function parseMethodModifiers(array $tokens)
{
$modifiers = MetaInfo::IS_PUBLIC;
foreach($tokens as $tok)
{
if(is_array($tok))
{
switch($tok[0])
{
case T_PUBLIC:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC;
break;
case T_PRIVATE:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE;
break;
case T_PROTECTED:
$modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED;
break;
case T_STATIC:
$modifiers |= MetaInfo::IS_STATIC;
break;
case T_ABSTRACT:
$modifiers |= MetaInfo::IS_ABSTRACT;
break;
case T_FINAL:
$modifiers |= MetaInfo::IS_FINAL;
break;
}
}
}
return $modifiers;
} | [
"protected",
"function",
"parseMethodModifiers",
"(",
"array",
"$",
"tokens",
")",
"{",
"$",
"modifiers",
"=",
"MetaInfo",
"::",
"IS_PUBLIC",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"tok",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tok",
")",
")",
"{",
"switch",
"(",
"$",
"tok",
"[",
"0",
"]",
")",
"{",
"case",
"T_PUBLIC",
":",
"$",
"modifiers",
"=",
"(",
"$",
"modifiers",
"|",
"MetaInfo",
"::",
"MASK_VISIBILITY",
")",
"^",
"MetaInfo",
"::",
"IS_NOT_PUBLIC",
";",
"break",
";",
"case",
"T_PRIVATE",
":",
"$",
"modifiers",
"=",
"(",
"$",
"modifiers",
"|",
"MetaInfo",
"::",
"MASK_VISIBILITY",
")",
"^",
"MetaInfo",
"::",
"IS_NOT_PRIVATE",
";",
"break",
";",
"case",
"T_PROTECTED",
":",
"$",
"modifiers",
"=",
"(",
"$",
"modifiers",
"|",
"MetaInfo",
"::",
"MASK_VISIBILITY",
")",
"^",
"MetaInfo",
"::",
"IS_NOT_PROTECTED",
";",
"break",
";",
"case",
"T_STATIC",
":",
"$",
"modifiers",
"|=",
"MetaInfo",
"::",
"IS_STATIC",
";",
"break",
";",
"case",
"T_ABSTRACT",
":",
"$",
"modifiers",
"|=",
"MetaInfo",
"::",
"IS_ABSTRACT",
";",
"break",
";",
"case",
"T_FINAL",
":",
"$",
"modifiers",
"|=",
"MetaInfo",
"::",
"IS_FINAL",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"modifiers",
";",
"}"
] | Parse all method modifiers from the given tokens and combine them into a bit mask.
@param array $tokens
@return integer | [
"Parse",
"all",
"method",
"modifiers",
"from",
"the",
"given",
"tokens",
"and",
"combine",
"them",
"into",
"a",
"bit",
"mask",
"."
] | train | https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L751-L784 |
koolkode/meta | src/Source/SourceParser.php | SourceParser.expandNamesInternal | protected function expandNamesInternal(array & $tokens, $typeName, NamespaceContext $context)
{
$buffer = '';
for($size = count($tokens), $i = 0; $i < $size; $i ++)
{
if(is_array($tokens[$i]) && ($tokens[$i][0] == T_STRING || $tokens[$i][0] == T_NS_SEPARATOR || $tokens[$i][0] == T_NEW))
{
$isNew = ($tokens[$i][0] == T_NEW);
if($isNew)
{
$buffer .= 'new ';
$name = '';
}
else
{
$name = $tokens[$i][1];
}
$i ++;
for(; $i < $size; $i ++)
{
if(is_array($tokens[$i]))
{
switch($tokens[$i][0])
{
case T_WHITESPACE:
case T_COMMENT:
case T_DOC_COMMENT:
continue 2;
case T_NS_SEPARATOR:
case T_STRING:
$name .= $tokens[$i][1];
continue 2;
}
}
break;
}
if($isNew)
{
if($name != '')
{
$buffer .= '\\' . ltrim($context->lookup($name), '\\');
}
}
else
{
if($i < $size && is_array($tokens[$i]) && $tokens[$i][0] == T_DOUBLE_COLON)
{
if(trim(strtolower($name)) == 'self')
{
$buffer .= '\\' . $typeName;
}
else
{
$buffer .= '\\' . ltrim($context->lookup($name), '\\');
}
}
else
{
$buffer .= $name;
}
}
}
if($i < $size)
{
if(is_array($tokens[$i]))
{
$buffer .= $tokens[$i][1];
}
else
{
$buffer .= $tokens[$i];
}
}
}
return $buffer;
} | php | protected function expandNamesInternal(array & $tokens, $typeName, NamespaceContext $context)
{
$buffer = '';
for($size = count($tokens), $i = 0; $i < $size; $i ++)
{
if(is_array($tokens[$i]) && ($tokens[$i][0] == T_STRING || $tokens[$i][0] == T_NS_SEPARATOR || $tokens[$i][0] == T_NEW))
{
$isNew = ($tokens[$i][0] == T_NEW);
if($isNew)
{
$buffer .= 'new ';
$name = '';
}
else
{
$name = $tokens[$i][1];
}
$i ++;
for(; $i < $size; $i ++)
{
if(is_array($tokens[$i]))
{
switch($tokens[$i][0])
{
case T_WHITESPACE:
case T_COMMENT:
case T_DOC_COMMENT:
continue 2;
case T_NS_SEPARATOR:
case T_STRING:
$name .= $tokens[$i][1];
continue 2;
}
}
break;
}
if($isNew)
{
if($name != '')
{
$buffer .= '\\' . ltrim($context->lookup($name), '\\');
}
}
else
{
if($i < $size && is_array($tokens[$i]) && $tokens[$i][0] == T_DOUBLE_COLON)
{
if(trim(strtolower($name)) == 'self')
{
$buffer .= '\\' . $typeName;
}
else
{
$buffer .= '\\' . ltrim($context->lookup($name), '\\');
}
}
else
{
$buffer .= $name;
}
}
}
if($i < $size)
{
if(is_array($tokens[$i]))
{
$buffer .= $tokens[$i][1];
}
else
{
$buffer .= $tokens[$i];
}
}
}
return $buffer;
} | [
"protected",
"function",
"expandNamesInternal",
"(",
"array",
"&",
"$",
"tokens",
",",
"$",
"typeName",
",",
"NamespaceContext",
"$",
"context",
")",
"{",
"$",
"buffer",
"=",
"''",
";",
"for",
"(",
"$",
"size",
"=",
"count",
"(",
"$",
"tokens",
")",
",",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
")",
"&&",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"==",
"T_STRING",
"||",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"==",
"T_NS_SEPARATOR",
"||",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"==",
"T_NEW",
")",
")",
"{",
"$",
"isNew",
"=",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"==",
"T_NEW",
")",
";",
"if",
"(",
"$",
"isNew",
")",
"{",
"$",
"buffer",
".=",
"'new '",
";",
"$",
"name",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
";",
"}",
"$",
"i",
"++",
";",
"for",
"(",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
")",
")",
"{",
"switch",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
")",
"{",
"case",
"T_WHITESPACE",
":",
"case",
"T_COMMENT",
":",
"case",
"T_DOC_COMMENT",
":",
"continue",
"2",
";",
"case",
"T_NS_SEPARATOR",
":",
"case",
"T_STRING",
":",
"$",
"name",
".=",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
";",
"continue",
"2",
";",
"}",
"}",
"break",
";",
"}",
"if",
"(",
"$",
"isNew",
")",
"{",
"if",
"(",
"$",
"name",
"!=",
"''",
")",
"{",
"$",
"buffer",
".=",
"'\\\\'",
".",
"ltrim",
"(",
"$",
"context",
"->",
"lookup",
"(",
"$",
"name",
")",
",",
"'\\\\'",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"i",
"<",
"$",
"size",
"&&",
"is_array",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
")",
"&&",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"==",
"T_DOUBLE_COLON",
")",
"{",
"if",
"(",
"trim",
"(",
"strtolower",
"(",
"$",
"name",
")",
")",
"==",
"'self'",
")",
"{",
"$",
"buffer",
".=",
"'\\\\'",
".",
"$",
"typeName",
";",
"}",
"else",
"{",
"$",
"buffer",
".=",
"'\\\\'",
".",
"ltrim",
"(",
"$",
"context",
"->",
"lookup",
"(",
"$",
"name",
")",
",",
"'\\\\'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"buffer",
".=",
"$",
"name",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"i",
"<",
"$",
"size",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"buffer",
".=",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"buffer",
".=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"buffer",
";",
"}"
] | Expand all unqualified names using the given namespace context in the given source code tokens.
@param array $tokens
@param NamespaceContext $context
@return string | [
"Expand",
"all",
"unqualified",
"names",
"using",
"the",
"given",
"namespace",
"context",
"in",
"the",
"given",
"source",
"code",
"tokens",
"."
] | train | https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L798-L881 |
PenoaksDev/Milky-Framework | src/Milky/Annotations/AnnotationException.php | AnnotationException.enumeratorError | public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
{
return new self(sprintf(
'[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.',
$attributeName,
$annotationName,
$context,
implode(', ', $available),
is_object($given) ? get_class($given) : $given
));
} | php | public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
{
return new self(sprintf(
'[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.',
$attributeName,
$annotationName,
$context,
implode(', ', $available),
is_object($given) ? get_class($given) : $given
));
} | [
"public",
"static",
"function",
"enumeratorError",
"(",
"$",
"attributeName",
",",
"$",
"annotationName",
",",
"$",
"context",
",",
"$",
"available",
",",
"$",
"given",
")",
"{",
"return",
"new",
"self",
"(",
"sprintf",
"(",
"'[Enum Error] Attribute \"%s\" of @%s declared on %s accept only [%s], but got %s.'",
",",
"$",
"attributeName",
",",
"$",
"annotationName",
",",
"$",
"context",
",",
"implode",
"(",
"', '",
",",
"$",
"available",
")",
",",
"is_object",
"(",
"$",
"given",
")",
"?",
"get_class",
"(",
"$",
"given",
")",
":",
"$",
"given",
")",
")",
";",
"}"
] | Creates a new AnnotationException describing a invalid enummerator.
@since 2.4
@param string $attributeName
@param string $annotationName
@param string $context
@param array $available
@param mixed $given
@return AnnotationException | [
"Creates",
"a",
"new",
"AnnotationException",
"describing",
"a",
"invalid",
"enummerator",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Annotations/AnnotationException.php#L147-L157 |
phossa/phossa-shared | src/Phossa/Shared/Message/MessageAbstract.php | MessageAbstract.get | public static function get()/*# : string */
{
// process arguments
$args = func_get_args();
if (sizeof($args) < 1) {
// return empty string
return '';
} else {
$code = array_shift($args);
// first argument is not numeric
if (!is_numeric($code)) {
return is_scalar($code) ? (string) $code : print_r($code, true);
// first argument is numeric
} else {
$code = (int) $code;
}
}
// search message class hierachy upwards to find message template
$class = get_called_class();
do {
$template = 'message: %s';
if ($class::hasMessage($code)) {
// load message mapping
static::loadMappings($class);
// get the message template
$template = $class::getMessage($code);
break;
}
// last resort
if ($class === __CLASS__) {
break;
}
$class = get_parent_class($class);
} while ($class);
// built the message with remaining arguments
return static::buildMessage($template, $args);
} | php | public static function get()/*# : string */
{
// process arguments
$args = func_get_args();
if (sizeof($args) < 1) {
// return empty string
return '';
} else {
$code = array_shift($args);
// first argument is not numeric
if (!is_numeric($code)) {
return is_scalar($code) ? (string) $code : print_r($code, true);
// first argument is numeric
} else {
$code = (int) $code;
}
}
// search message class hierachy upwards to find message template
$class = get_called_class();
do {
$template = 'message: %s';
if ($class::hasMessage($code)) {
// load message mapping
static::loadMappings($class);
// get the message template
$template = $class::getMessage($code);
break;
}
// last resort
if ($class === __CLASS__) {
break;
}
$class = get_parent_class($class);
} while ($class);
// built the message with remaining arguments
return static::buildMessage($template, $args);
} | [
"public",
"static",
"function",
"get",
"(",
")",
"/*# : string */",
"{",
"// process arguments",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"args",
")",
"<",
"1",
")",
"{",
"// return empty string",
"return",
"''",
";",
"}",
"else",
"{",
"$",
"code",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"// first argument is not numeric",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"code",
")",
")",
"{",
"return",
"is_scalar",
"(",
"$",
"code",
")",
"?",
"(",
"string",
")",
"$",
"code",
":",
"print_r",
"(",
"$",
"code",
",",
"true",
")",
";",
"// first argument is numeric",
"}",
"else",
"{",
"$",
"code",
"=",
"(",
"int",
")",
"$",
"code",
";",
"}",
"}",
"// search message class hierachy upwards to find message template",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"do",
"{",
"$",
"template",
"=",
"'message: %s'",
";",
"if",
"(",
"$",
"class",
"::",
"hasMessage",
"(",
"$",
"code",
")",
")",
"{",
"// load message mapping",
"static",
"::",
"loadMappings",
"(",
"$",
"class",
")",
";",
"// get the message template",
"$",
"template",
"=",
"$",
"class",
"::",
"getMessage",
"(",
"$",
"code",
")",
";",
"break",
";",
"}",
"// last resort",
"if",
"(",
"$",
"class",
"===",
"__CLASS__",
")",
"{",
"break",
";",
"}",
"$",
"class",
"=",
"get_parent_class",
"(",
"$",
"class",
")",
";",
"}",
"while",
"(",
"$",
"class",
")",
";",
"// built the message with remaining arguments",
"return",
"static",
"::",
"buildMessage",
"(",
"$",
"template",
",",
"$",
"args",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/phossa/phossa-shared/blob/fcf140c09e94c3a441ee4e285de0b4c18cb6504b/src/Phossa/Shared/Message/MessageAbstract.php#L85-L127 |
phossa/phossa-shared | src/Phossa/Shared/Message/MessageAbstract.php | MessageAbstract.loadMappings | protected static function loadMappings(/*# string */ $class)
{
// mapping status changed ?
if (self::isStatusUpdated()) {
self::resetMappings();
self::setStatus(false);
}
// $class' mapping loaded already
if ($class::hasMappings()) {
return;
}
// load $class mapping
$loadedClass = $class::hasLoader();
if ($loadedClass) {
// loader found
$class::setMappings(
$loadedClass::getLoader()->loadMessages($class)
);
} else {
// no loader found
$class::setMappings([]);
}
} | php | protected static function loadMappings(/*# string */ $class)
{
// mapping status changed ?
if (self::isStatusUpdated()) {
self::resetMappings();
self::setStatus(false);
}
// $class' mapping loaded already
if ($class::hasMappings()) {
return;
}
// load $class mapping
$loadedClass = $class::hasLoader();
if ($loadedClass) {
// loader found
$class::setMappings(
$loadedClass::getLoader()->loadMessages($class)
);
} else {
// no loader found
$class::setMappings([]);
}
} | [
"protected",
"static",
"function",
"loadMappings",
"(",
"/*# string */",
"$",
"class",
")",
"{",
"// mapping status changed ?",
"if",
"(",
"self",
"::",
"isStatusUpdated",
"(",
")",
")",
"{",
"self",
"::",
"resetMappings",
"(",
")",
";",
"self",
"::",
"setStatus",
"(",
"false",
")",
";",
"}",
"// $class' mapping loaded already",
"if",
"(",
"$",
"class",
"::",
"hasMappings",
"(",
")",
")",
"{",
"return",
";",
"}",
"// load $class mapping",
"$",
"loadedClass",
"=",
"$",
"class",
"::",
"hasLoader",
"(",
")",
";",
"if",
"(",
"$",
"loadedClass",
")",
"{",
"// loader found",
"$",
"class",
"::",
"setMappings",
"(",
"$",
"loadedClass",
"::",
"getLoader",
"(",
")",
"->",
"loadMessages",
"(",
"$",
"class",
")",
")",
";",
"}",
"else",
"{",
"// no loader found",
"$",
"class",
"::",
"setMappings",
"(",
"[",
"]",
")",
";",
"}",
"}"
] | Load message mappings for $class
@param string $class fully qualified class name
@return void
@access protected
@static | [
"Load",
"message",
"mappings",
"for",
"$class"
] | train | https://github.com/phossa/phossa-shared/blob/fcf140c09e94c3a441ee4e285de0b4c18cb6504b/src/Phossa/Shared/Message/MessageAbstract.php#L137-L161 |
phossa/phossa-shared | src/Phossa/Shared/Message/MessageAbstract.php | MessageAbstract.buildMessage | protected static function buildMessage(
/*# string */ $template,
array $arguments
)/*# : string */ {
// use formatter
if (self::hasFormatter()) {
return self::getFormatter()
->formatMessage($template, $arguments);
// default is vsprintf()
} else {
// make sure arguments are all strings
array_walk($arguments, function (&$value) {
$value = is_scalar($value) ? (string) $value :
substr(print_r($value, true), 0, 50);
});
// make sure '%s' count in $template is same as size of $arguments
$count = substr_count($template, '%s');
$size = sizeof($arguments);
if ($count > $size) {
$arguments = $arguments + array_fill($size, $count - $size, '');
} else {
$template .= str_repeat(' %s', $size - $count);
}
return vsprintf($template, $arguments);
}
} | php | protected static function buildMessage(
/*# string */ $template,
array $arguments
)/*# : string */ {
// use formatter
if (self::hasFormatter()) {
return self::getFormatter()
->formatMessage($template, $arguments);
// default is vsprintf()
} else {
// make sure arguments are all strings
array_walk($arguments, function (&$value) {
$value = is_scalar($value) ? (string) $value :
substr(print_r($value, true), 0, 50);
});
// make sure '%s' count in $template is same as size of $arguments
$count = substr_count($template, '%s');
$size = sizeof($arguments);
if ($count > $size) {
$arguments = $arguments + array_fill($size, $count - $size, '');
} else {
$template .= str_repeat(' %s', $size - $count);
}
return vsprintf($template, $arguments);
}
} | [
"protected",
"static",
"function",
"buildMessage",
"(",
"/*# string */",
"$",
"template",
",",
"array",
"$",
"arguments",
")",
"/*# : string */",
"{",
"// use formatter",
"if",
"(",
"self",
"::",
"hasFormatter",
"(",
")",
")",
"{",
"return",
"self",
"::",
"getFormatter",
"(",
")",
"->",
"formatMessage",
"(",
"$",
"template",
",",
"$",
"arguments",
")",
";",
"// default is vsprintf()",
"}",
"else",
"{",
"// make sure arguments are all strings",
"array_walk",
"(",
"$",
"arguments",
",",
"function",
"(",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"is_scalar",
"(",
"$",
"value",
")",
"?",
"(",
"string",
")",
"$",
"value",
":",
"substr",
"(",
"print_r",
"(",
"$",
"value",
",",
"true",
")",
",",
"0",
",",
"50",
")",
";",
"}",
")",
";",
"// make sure '%s' count in $template is same as size of $arguments",
"$",
"count",
"=",
"substr_count",
"(",
"$",
"template",
",",
"'%s'",
")",
";",
"$",
"size",
"=",
"sizeof",
"(",
"$",
"arguments",
")",
";",
"if",
"(",
"$",
"count",
">",
"$",
"size",
")",
"{",
"$",
"arguments",
"=",
"$",
"arguments",
"+",
"array_fill",
"(",
"$",
"size",
",",
"$",
"count",
"-",
"$",
"size",
",",
"''",
")",
";",
"}",
"else",
"{",
"$",
"template",
".=",
"str_repeat",
"(",
"' %s'",
",",
"$",
"size",
"-",
"$",
"count",
")",
";",
"}",
"return",
"vsprintf",
"(",
"$",
"template",
",",
"$",
"arguments",
")",
";",
"}",
"}"
] | Build message from template and arguments.
- Make sure '%s' matches the arguments provided.
- Use message formatter if exists
@param string $template message template
@param array $arguments arguments for the template
@return string
@access protected
@static | [
"Build",
"message",
"from",
"template",
"and",
"arguments",
"."
] | train | https://github.com/phossa/phossa-shared/blob/fcf140c09e94c3a441ee4e285de0b4c18cb6504b/src/Phossa/Shared/Message/MessageAbstract.php#L175-L202 |
RocketPropelledTortoise/Core | src/Translation/I18NToolbar.php | I18NToolbar.loadLanguage | public function loadLanguage($language)
{
if ($this->isLoaded($language)) {
return;
}
$this->strings[$language] = [];
$this->languagesLoaded[] = $language;
} | php | public function loadLanguage($language)
{
if ($this->isLoaded($language)) {
return;
}
$this->strings[$language] = [];
$this->languagesLoaded[] = $language;
} | [
"public",
"function",
"loadLanguage",
"(",
"$",
"language",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLoaded",
"(",
"$",
"language",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"strings",
"[",
"$",
"language",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"languagesLoaded",
"[",
"]",
"=",
"$",
"language",
";",
"}"
] | Load a language file
@param string $language
@return bool | [
"Load",
"a",
"language",
"file"
] | train | https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Translation/I18NToolbar.php#L56-L64 |
jonesiscoding/device | src/DeviceFeatureInfo.php | DeviceFeatureInfo.get | public function get( $item = null )
{
if( empty( $this->_detect ) || !array_key_exists( $item, $this->_detect ) )
{
$this->_detect = $this->detect();
}
if( $item )
{
return ( array_key_exists( $item, $this->_detect ) ) ? $this->_detect[ $item ] : false;
}
return $this->_detect;
} | php | public function get( $item = null )
{
if( empty( $this->_detect ) || !array_key_exists( $item, $this->_detect ) )
{
$this->_detect = $this->detect();
}
if( $item )
{
return ( array_key_exists( $item, $this->_detect ) ) ? $this->_detect[ $item ] : false;
}
return $this->_detect;
} | [
"public",
"function",
"get",
"(",
"$",
"item",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_detect",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"item",
",",
"$",
"this",
"->",
"_detect",
")",
")",
"{",
"$",
"this",
"->",
"_detect",
"=",
"$",
"this",
"->",
"detect",
"(",
")",
";",
"}",
"if",
"(",
"$",
"item",
")",
"{",
"return",
"(",
"array_key_exists",
"(",
"$",
"item",
",",
"$",
"this",
"->",
"_detect",
")",
")",
"?",
"$",
"this",
"->",
"_detect",
"[",
"$",
"item",
"]",
":",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"_detect",
";",
"}"
] | Retrieves the full results of the current client detection, or a specific parameter. Available parameters are
hidpi, width, height, speed, modern, touch, and cookies.
@param string|null $item The parameter you wish to detect
@return string|array|bool The detected parameter, or if $item was not given, the array of all parameters. | [
"Retrieves",
"the",
"full",
"results",
"of",
"the",
"current",
"client",
"detection",
"or",
"a",
"specific",
"parameter",
".",
"Available",
"parameters",
"are",
"hidpi",
"width",
"height",
"speed",
"modern",
"touch",
"and",
"cookies",
"."
] | train | https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DeviceFeatureInfo.php#L49-L62 |
jonesiscoding/device | src/DeviceFeatureInfo.php | DeviceFeatureInfo.detect | private function detect()
{
$detect = array();
$defaults = $this->getDefaults();
if( $this->isDetected() )
{
$detect = json_decode( $_COOKIE[ $this->cookieName ], true );
if( !is_null( $detect ) )
{
// Convert Boolean values from strings
foreach( $detect as $k => $v )
{
if( $v === "false" ) { $detect[ $k ] = $v = false; }
if( $v === "true" ) { $detect[ $k ] = $v = true; }
// Allow Server Overrides
if ( $v === false && in_array( $k, DetectDefaults::SERVER ) ) {
$detect[$k] = ( array_key_exists( $k, $defaults ) ) ? $defaults[ $k ] : $v;
}
}
}
}
elseif( !$this->DetectByUserAgent instanceof DetectByUserAgent )
{
// Attempt to get from User Agent
$this->DetectByUserAgent = new DetectByUserAgent();
$detect = $this->DetectByUserAgent->detect();
}
// Append Defaults
return ( !empty( $detect ) ) ? array_merge( $defaults, $detect ) : $defaults;
} | php | private function detect()
{
$detect = array();
$defaults = $this->getDefaults();
if( $this->isDetected() )
{
$detect = json_decode( $_COOKIE[ $this->cookieName ], true );
if( !is_null( $detect ) )
{
// Convert Boolean values from strings
foreach( $detect as $k => $v )
{
if( $v === "false" ) { $detect[ $k ] = $v = false; }
if( $v === "true" ) { $detect[ $k ] = $v = true; }
// Allow Server Overrides
if ( $v === false && in_array( $k, DetectDefaults::SERVER ) ) {
$detect[$k] = ( array_key_exists( $k, $defaults ) ) ? $defaults[ $k ] : $v;
}
}
}
}
elseif( !$this->DetectByUserAgent instanceof DetectByUserAgent )
{
// Attempt to get from User Agent
$this->DetectByUserAgent = new DetectByUserAgent();
$detect = $this->DetectByUserAgent->detect();
}
// Append Defaults
return ( !empty( $detect ) ) ? array_merge( $defaults, $detect ) : $defaults;
} | [
"private",
"function",
"detect",
"(",
")",
"{",
"$",
"detect",
"=",
"array",
"(",
")",
";",
"$",
"defaults",
"=",
"$",
"this",
"->",
"getDefaults",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isDetected",
"(",
")",
")",
"{",
"$",
"detect",
"=",
"json_decode",
"(",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookieName",
"]",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"detect",
")",
")",
"{",
"// Convert Boolean values from strings",
"foreach",
"(",
"$",
"detect",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"\"false\"",
")",
"{",
"$",
"detect",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"v",
"===",
"\"true\"",
")",
"{",
"$",
"detect",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
"=",
"true",
";",
"}",
"// Allow Server Overrides",
"if",
"(",
"$",
"v",
"===",
"false",
"&&",
"in_array",
"(",
"$",
"k",
",",
"DetectDefaults",
"::",
"SERVER",
")",
")",
"{",
"$",
"detect",
"[",
"$",
"k",
"]",
"=",
"(",
"array_key_exists",
"(",
"$",
"k",
",",
"$",
"defaults",
")",
")",
"?",
"$",
"defaults",
"[",
"$",
"k",
"]",
":",
"$",
"v",
";",
"}",
"}",
"}",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"DetectByUserAgent",
"instanceof",
"DetectByUserAgent",
")",
"{",
"// Attempt to get from User Agent",
"$",
"this",
"->",
"DetectByUserAgent",
"=",
"new",
"DetectByUserAgent",
"(",
")",
";",
"$",
"detect",
"=",
"$",
"this",
"->",
"DetectByUserAgent",
"->",
"detect",
"(",
")",
";",
"}",
"// Append Defaults",
"return",
"(",
"!",
"empty",
"(",
"$",
"detect",
")",
")",
"?",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"detect",
")",
":",
"$",
"defaults",
";",
"}"
] | Parses the cookie left by d.js. If the cookie is not set due to Javascript being disabled, or cookies being
being blocked, DetectByUserAgent is used to determine the values by the user agent.
Using the user agent can be quite flawed. As we are limiting it to feature detection, it makes a good backup here.
@return array | [
"Parses",
"the",
"cookie",
"left",
"by",
"d",
".",
"js",
".",
"If",
"the",
"cookie",
"is",
"not",
"set",
"due",
"to",
"Javascript",
"being",
"disabled",
"or",
"cookies",
"being",
"being",
"blocked",
"DetectByUserAgent",
"is",
"used",
"to",
"determine",
"the",
"values",
"by",
"the",
"user",
"agent",
"."
] | train | https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DeviceFeatureInfo.php#L221-L253 |
nicmart/Arrayze | src/MapsCollection.php | MapsCollection.registerMaps | public function registerMaps(array $maps)
{
foreach ($maps as $name => $map) {
$this->maps[$name] = $map;
}
return $this;
} | php | public function registerMaps(array $maps)
{
foreach ($maps as $name => $map) {
$this->maps[$name] = $map;
}
return $this;
} | [
"public",
"function",
"registerMaps",
"(",
"array",
"$",
"maps",
")",
"{",
"foreach",
"(",
"$",
"maps",
"as",
"$",
"name",
"=>",
"$",
"map",
")",
"{",
"$",
"this",
"->",
"maps",
"[",
"$",
"name",
"]",
"=",
"$",
"map",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | @param callable[] $maps
@return $this | [
"@param",
"callable",
"[]",
"$maps"
] | train | https://github.com/nicmart/Arrayze/blob/7a86c8a661456b5f7055857aeda3e6ee3af05b13/src/MapsCollection.php#L36-L43 |
nicmart/Arrayze | src/MapsCollection.php | MapsCollection.apply | public function apply($mapName, $value1, $value2 = null)
{
$args = func_get_args();
array_shift($args);
return call_user_func_array($this->getMap($mapName), $args);
} | php | public function apply($mapName, $value1, $value2 = null)
{
$args = func_get_args();
array_shift($args);
return call_user_func_array($this->getMap($mapName), $args);
} | [
"public",
"function",
"apply",
"(",
"$",
"mapName",
",",
"$",
"value1",
",",
"$",
"value2",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"args",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"this",
"->",
"getMap",
"(",
"$",
"mapName",
")",
",",
"$",
"args",
")",
";",
"}"
] | @param string $mapName
@param mixed $value
@return mixed | [
"@param",
"string",
"$mapName",
"@param",
"mixed",
"$value"
] | train | https://github.com/nicmart/Arrayze/blob/7a86c8a661456b5f7055857aeda3e6ee3af05b13/src/MapsCollection.php#L81-L87 |
nicmart/Arrayze | src/MapsCollection.php | MapsCollection.map | public function map($value/*, $value2, ... */)
{
$args = func_get_args();
foreach ($this->getMaps() as $name => $map)
{
yield $name => call_user_func_array($map, $args);
}
} | php | public function map($value/*, $value2, ... */)
{
$args = func_get_args();
foreach ($this->getMaps() as $name => $map)
{
yield $name => call_user_func_array($map, $args);
}
} | [
"public",
"function",
"map",
"(",
"$",
"value",
"/*, $value2, ... */",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getMaps",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"map",
")",
"{",
"yield",
"$",
"name",
"=>",
"call_user_func_array",
"(",
"$",
"map",
",",
"$",
"args",
")",
";",
"}",
"}"
] | @param $value
@return \Generator | [
"@param",
"$value"
] | train | https://github.com/nicmart/Arrayze/blob/7a86c8a661456b5f7055857aeda3e6ee3af05b13/src/MapsCollection.php#L94-L101 |
AnonymPHP/Anonym-Cookie | src/Anonym/Components/Http/CookieBag.php | CookieBag.rendeCookieString | private function rendeCookieString($cookie = '')
{
if ($cookie !== '') {
$explode = explode(";", $cookie);
$cookies = [];
foreach ($explode as $ex) {
$ex = explode('=', $ex, 2);
$cookies[trim($ex[0])] = ($ex[1]);
}
return $cookies;
}
} | php | private function rendeCookieString($cookie = '')
{
if ($cookie !== '') {
$explode = explode(";", $cookie);
$cookies = [];
foreach ($explode as $ex) {
$ex = explode('=', $ex, 2);
$cookies[trim($ex[0])] = ($ex[1]);
}
return $cookies;
}
} | [
"private",
"function",
"rendeCookieString",
"(",
"$",
"cookie",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"cookie",
"!==",
"''",
")",
"{",
"$",
"explode",
"=",
"explode",
"(",
"\";\"",
",",
"$",
"cookie",
")",
";",
"$",
"cookies",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"explode",
"as",
"$",
"ex",
")",
"{",
"$",
"ex",
"=",
"explode",
"(",
"'='",
",",
"$",
"ex",
",",
"2",
")",
";",
"$",
"cookies",
"[",
"trim",
"(",
"$",
"ex",
"[",
"0",
"]",
")",
"]",
"=",
"(",
"$",
"ex",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"cookies",
";",
"}",
"}"
] | Cookie verilerini parçalar
@param string $cookie
@return array | [
"Cookie",
"verilerini",
"parçalar"
] | train | https://github.com/AnonymPHP/Anonym-Cookie/blob/7e02403f76fab42355f02326c5589d3fca271e3b/src/Anonym/Components/Http/CookieBag.php#L48-L64 |
cubicmushroom/valueobjects | src/DateTime/Date.php | Date.fromNative | public static function fromNative()
{
$args = func_get_args();
$year = new Year($args[0]);
$month = Month::fromNative($args[1]);
$day = new MonthDay($args[2]);
return new static($year, $month, $day);
} | php | public static function fromNative()
{
$args = func_get_args();
$year = new Year($args[0]);
$month = Month::fromNative($args[1]);
$day = new MonthDay($args[2]);
return new static($year, $month, $day);
} | [
"public",
"static",
"function",
"fromNative",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"year",
"=",
"new",
"Year",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"$",
"month",
"=",
"Month",
"::",
"fromNative",
"(",
"$",
"args",
"[",
"1",
"]",
")",
";",
"$",
"day",
"=",
"new",
"MonthDay",
"(",
"$",
"args",
"[",
"2",
"]",
")",
";",
"return",
"new",
"static",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
";",
"}"
] | Returns a new Date from native year, month and day values
@param int $year
@param string $month
@param int $day
@return Date | [
"Returns",
"a",
"new",
"Date",
"from",
"native",
"year",
"month",
"and",
"day",
"values"
] | train | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L28-L37 |
cubicmushroom/valueobjects | src/DateTime/Date.php | Date.fromNativeDateTime | public static function fromNativeDateTime(\DateTime $date)
{
$year = \intval($date->format('Y'));
$month = Month::fromNativeDateTime($date);
$day = \intval($date->format('d'));
return new static(new Year($year), $month, new MonthDay($day));
} | php | public static function fromNativeDateTime(\DateTime $date)
{
$year = \intval($date->format('Y'));
$month = Month::fromNativeDateTime($date);
$day = \intval($date->format('d'));
return new static(new Year($year), $month, new MonthDay($day));
} | [
"public",
"static",
"function",
"fromNativeDateTime",
"(",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"$",
"year",
"=",
"\\",
"intval",
"(",
"$",
"date",
"->",
"format",
"(",
"'Y'",
")",
")",
";",
"$",
"month",
"=",
"Month",
"::",
"fromNativeDateTime",
"(",
"$",
"date",
")",
";",
"$",
"day",
"=",
"\\",
"intval",
"(",
"$",
"date",
"->",
"format",
"(",
"'d'",
")",
")",
";",
"return",
"new",
"static",
"(",
"new",
"Year",
"(",
"$",
"year",
")",
",",
"$",
"month",
",",
"new",
"MonthDay",
"(",
"$",
"day",
")",
")",
";",
"}"
] | Returns a new Date from a native PHP \DateTime
@param \DateTime $date
@return Date | [
"Returns",
"a",
"new",
"Date",
"from",
"a",
"native",
"PHP",
"\\",
"DateTime"
] | train | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L45-L52 |
cubicmushroom/valueobjects | src/DateTime/Date.php | Date.sameValueAs | public function sameValueAs(ValueObjectInterface $date)
{
if (false === Util::classEquals($this, $date)) {
return false;
}
return $this->getYear()->sameValueAs($date->getYear()) &&
$this->getMonth()->sameValueAs($date->getMonth()) &&
$this->getDay()->sameValueAs($date->getDay());
} | php | public function sameValueAs(ValueObjectInterface $date)
{
if (false === Util::classEquals($this, $date)) {
return false;
}
return $this->getYear()->sameValueAs($date->getYear()) &&
$this->getMonth()->sameValueAs($date->getMonth()) &&
$this->getDay()->sameValueAs($date->getDay());
} | [
"public",
"function",
"sameValueAs",
"(",
"ValueObjectInterface",
"$",
"date",
")",
"{",
"if",
"(",
"false",
"===",
"Util",
"::",
"classEquals",
"(",
"$",
"this",
",",
"$",
"date",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"getYear",
"(",
")",
"->",
"sameValueAs",
"(",
"$",
"date",
"->",
"getYear",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"getMonth",
"(",
")",
"->",
"sameValueAs",
"(",
"$",
"date",
"->",
"getMonth",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"getDay",
"(",
")",
"->",
"sameValueAs",
"(",
"$",
"date",
"->",
"getDay",
"(",
")",
")",
";",
"}"
] | Tells whether two Date are equal by comparing their values
@param ValueObjectInterface $date
@return bool | [
"Tells",
"whether",
"two",
"Date",
"are",
"equal",
"by",
"comparing",
"their",
"values"
] | train | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L94-L103 |
cubicmushroom/valueobjects | src/DateTime/Date.php | Date.toNativeDateTime | public function toNativeDateTime()
{
$year = $this->getYear()->toNative();
$month = $this->getMonth()->getNumericValue();
$day = $this->getDay()->toNative();
$date = new \DateTime();
$date->setDate($year, $month, $day);
$date->setTime(0, 0, 0);
return $date;
} | php | public function toNativeDateTime()
{
$year = $this->getYear()->toNative();
$month = $this->getMonth()->getNumericValue();
$day = $this->getDay()->toNative();
$date = new \DateTime();
$date->setDate($year, $month, $day);
$date->setTime(0, 0, 0);
return $date;
} | [
"public",
"function",
"toNativeDateTime",
"(",
")",
"{",
"$",
"year",
"=",
"$",
"this",
"->",
"getYear",
"(",
")",
"->",
"toNative",
"(",
")",
";",
"$",
"month",
"=",
"$",
"this",
"->",
"getMonth",
"(",
")",
"->",
"getNumericValue",
"(",
")",
";",
"$",
"day",
"=",
"$",
"this",
"->",
"getDay",
"(",
")",
"->",
"toNative",
"(",
")",
";",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"date",
"->",
"setDate",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
";",
"$",
"date",
"->",
"setTime",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"return",
"$",
"date",
";",
"}"
] | Returns a native PHP \DateTime version of the current Date
@return \DateTime | [
"Returns",
"a",
"native",
"PHP",
"\\",
"DateTime",
"version",
"of",
"the",
"current",
"Date"
] | train | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L140-L151 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.__static | static function __static()
{
DOMXPathNavigator::$nodeTypeMap = array(
XML_ELEMENT_NODE => XPathNodeType::Element,
XML_ATTRIBUTE_NODE => XPathNodeType::Attribute,
XML_TEXT_NODE => XPathNodeType::Text,
// XML_CDATA_SECTION_NODE => 4,
// XML_ENTITY_REF_NODE => 5,
// XML_ENTITY_NODE => 6,
XML_PI_NODE => XPathNodeType::ProcessingInstruction,
XML_COMMENT_NODE => XPathNodeType::Comment,
XML_DOCUMENT_NODE => XPathNodeType::Root,
// XML_DOCUMENT_TYPE_NODE => XPathNodeType::Element, // .NET does not consider this an element
// XML_DOCUMENT_FRAG_NODE => 11,
XML_NOTATION_NODE => 12,
// XML_HTML_DOCUMENT_NODE => 13,
// XML_DTD_NODE => 14,
XML_ELEMENT_DECL_NODE => XPathNodeType::Element,
XML_ATTRIBUTE_DECL_NODE => XPathNodeType::Attribute,
// XML_ENTITY_DECL_NODE => 17,
XML_NAMESPACE_DECL_NODE => XPathNodeType::NamespaceURI,
);
} | php | static function __static()
{
DOMXPathNavigator::$nodeTypeMap = array(
XML_ELEMENT_NODE => XPathNodeType::Element,
XML_ATTRIBUTE_NODE => XPathNodeType::Attribute,
XML_TEXT_NODE => XPathNodeType::Text,
// XML_CDATA_SECTION_NODE => 4,
// XML_ENTITY_REF_NODE => 5,
// XML_ENTITY_NODE => 6,
XML_PI_NODE => XPathNodeType::ProcessingInstruction,
XML_COMMENT_NODE => XPathNodeType::Comment,
XML_DOCUMENT_NODE => XPathNodeType::Root,
// XML_DOCUMENT_TYPE_NODE => XPathNodeType::Element, // .NET does not consider this an element
// XML_DOCUMENT_FRAG_NODE => 11,
XML_NOTATION_NODE => 12,
// XML_HTML_DOCUMENT_NODE => 13,
// XML_DTD_NODE => 14,
XML_ELEMENT_DECL_NODE => XPathNodeType::Element,
XML_ATTRIBUTE_DECL_NODE => XPathNodeType::Attribute,
// XML_ENTITY_DECL_NODE => 17,
XML_NAMESPACE_DECL_NODE => XPathNodeType::NamespaceURI,
);
} | [
"static",
"function",
"__static",
"(",
")",
"{",
"DOMXPathNavigator",
"::",
"$",
"nodeTypeMap",
"=",
"array",
"(",
"XML_ELEMENT_NODE",
"=>",
"XPathNodeType",
"::",
"Element",
",",
"XML_ATTRIBUTE_NODE",
"=>",
"XPathNodeType",
"::",
"Attribute",
",",
"XML_TEXT_NODE",
"=>",
"XPathNodeType",
"::",
"Text",
",",
"// XML_CDATA_SECTION_NODE => 4,\r",
"// XML_ENTITY_REF_NODE => 5,\r",
"// XML_ENTITY_NODE => 6,\r",
"XML_PI_NODE",
"=>",
"XPathNodeType",
"::",
"ProcessingInstruction",
",",
"XML_COMMENT_NODE",
"=>",
"XPathNodeType",
"::",
"Comment",
",",
"XML_DOCUMENT_NODE",
"=>",
"XPathNodeType",
"::",
"Root",
",",
"// XML_DOCUMENT_TYPE_NODE => XPathNodeType::Element, // .NET does not consider this an element\r",
"// XML_DOCUMENT_FRAG_NODE => 11,\r",
"XML_NOTATION_NODE",
"=>",
"12",
",",
"// XML_HTML_DOCUMENT_NODE => 13,\r",
"// XML_DTD_NODE => 14,\r",
"XML_ELEMENT_DECL_NODE",
"=>",
"XPathNodeType",
"::",
"Element",
",",
"XML_ATTRIBUTE_DECL_NODE",
"=>",
"XPathNodeType",
"::",
"Attribute",
",",
"// XML_ENTITY_DECL_NODE => 17,\r",
"XML_NAMESPACE_DECL_NODE",
"=>",
"XPathNodeType",
"::",
"NamespaceURI",
",",
")",
";",
"}"
] | Static constructor | [
"Static",
"constructor"
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L98-L122 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.ComparePosition | public function ComparePosition( $other, $useLineNo = false)
{
$thisDomNode = $this->getUnderlyingObject();
$otherDomNode = $other->getUnderlyingObject();
$doc1 = $thisDomNode->baseURI;
$doc2 = $otherDomNode->baseURI;
if ( strcasecmp( $doc1, $doc2 ) != 0 )
// if ( spl_object_hash( $this->domNode->ownerDocument ) != spl_object_hash( $other->getUnderlyingObject()->ownerDocument ) )
return XmlNodeOrder::Unknown;
$thisPath = $thisDomNode->getNodePath();
$otherPath = $otherDomNode->getNodePath();
// Convert node names into a set positions
// This is necessary because the getNodePath returns named nodes.
// However there has to be a question mark over performance since
// an XPath query is being performed for every segment of both the
// 'this' path and the 'other' path.
// In the case where a parent has named child nodes that are not
// in a lexical order such as:
// <a>
// <c/>
// <b/>
// </a>
// Then sorting on the path will result in a list that is not
// document ordered. By changing the name for the correct position
// in the parent the set of paths can be sorted.
$convert = function( $xPath, $nodePath )
{
$parts = explode( "/", $nodePath );
$length = 0;
foreach ( $parts as $key => &$part )
{
$length++;
if ( $part == "" ) continue;
$length += strlen( $part );
$result = $xPath->evaluate( "count(" . substr( $nodePath, 0, $length -1 ) . "/preceding-sibling::*) + 1" );
$part = $result;
}
unset( $part );
return implode( "/", $parts );
};
$xPath = new \DOMXPath( $thisDomNode instanceof \DOMDocument ? $thisDomNode : $thisDomNode->ownerDocument );
$thisPath = $convert( $xPath, $thisPath );
$xPath = new \DOMXPath( $otherDomNode instanceof \DOMDocument ? $otherDomNode : $otherDomNode->ownerDocument );
$otherPath = $convert( $xPath, $otherPath );
if ( $useLineNo )
{
$thisPath = $thisDomNode->getLineNo() . "-" . $thisPath;
$otherPath = $otherDomNode->getLineNo() . "-" . $otherPath;
}
// Using strnatcasecmp so /xx[20] will follow /xx[3] which does not happen with other sort types
$compare = strnatcasecmp( $thisPath, $otherPath );
return $compare == 0
? XmlNodeOrder::Same
: ( $compare < 0 ? XmlNodeOrder::Before : XmlNodeOrder::After );
} | php | public function ComparePosition( $other, $useLineNo = false)
{
$thisDomNode = $this->getUnderlyingObject();
$otherDomNode = $other->getUnderlyingObject();
$doc1 = $thisDomNode->baseURI;
$doc2 = $otherDomNode->baseURI;
if ( strcasecmp( $doc1, $doc2 ) != 0 )
// if ( spl_object_hash( $this->domNode->ownerDocument ) != spl_object_hash( $other->getUnderlyingObject()->ownerDocument ) )
return XmlNodeOrder::Unknown;
$thisPath = $thisDomNode->getNodePath();
$otherPath = $otherDomNode->getNodePath();
// Convert node names into a set positions
// This is necessary because the getNodePath returns named nodes.
// However there has to be a question mark over performance since
// an XPath query is being performed for every segment of both the
// 'this' path and the 'other' path.
// In the case where a parent has named child nodes that are not
// in a lexical order such as:
// <a>
// <c/>
// <b/>
// </a>
// Then sorting on the path will result in a list that is not
// document ordered. By changing the name for the correct position
// in the parent the set of paths can be sorted.
$convert = function( $xPath, $nodePath )
{
$parts = explode( "/", $nodePath );
$length = 0;
foreach ( $parts as $key => &$part )
{
$length++;
if ( $part == "" ) continue;
$length += strlen( $part );
$result = $xPath->evaluate( "count(" . substr( $nodePath, 0, $length -1 ) . "/preceding-sibling::*) + 1" );
$part = $result;
}
unset( $part );
return implode( "/", $parts );
};
$xPath = new \DOMXPath( $thisDomNode instanceof \DOMDocument ? $thisDomNode : $thisDomNode->ownerDocument );
$thisPath = $convert( $xPath, $thisPath );
$xPath = new \DOMXPath( $otherDomNode instanceof \DOMDocument ? $otherDomNode : $otherDomNode->ownerDocument );
$otherPath = $convert( $xPath, $otherPath );
if ( $useLineNo )
{
$thisPath = $thisDomNode->getLineNo() . "-" . $thisPath;
$otherPath = $otherDomNode->getLineNo() . "-" . $otherPath;
}
// Using strnatcasecmp so /xx[20] will follow /xx[3] which does not happen with other sort types
$compare = strnatcasecmp( $thisPath, $otherPath );
return $compare == 0
? XmlNodeOrder::Same
: ( $compare < 0 ? XmlNodeOrder::Before : XmlNodeOrder::After );
} | [
"public",
"function",
"ComparePosition",
"(",
"$",
"other",
",",
"$",
"useLineNo",
"=",
"false",
")",
"{",
"$",
"thisDomNode",
"=",
"$",
"this",
"->",
"getUnderlyingObject",
"(",
")",
";",
"$",
"otherDomNode",
"=",
"$",
"other",
"->",
"getUnderlyingObject",
"(",
")",
";",
"$",
"doc1",
"=",
"$",
"thisDomNode",
"->",
"baseURI",
";",
"$",
"doc2",
"=",
"$",
"otherDomNode",
"->",
"baseURI",
";",
"if",
"(",
"strcasecmp",
"(",
"$",
"doc1",
",",
"$",
"doc2",
")",
"!=",
"0",
")",
"// if ( spl_object_hash( $this->domNode->ownerDocument ) != spl_object_hash( $other->getUnderlyingObject()->ownerDocument ) )\r",
"return",
"XmlNodeOrder",
"::",
"Unknown",
";",
"$",
"thisPath",
"=",
"$",
"thisDomNode",
"->",
"getNodePath",
"(",
")",
";",
"$",
"otherPath",
"=",
"$",
"otherDomNode",
"->",
"getNodePath",
"(",
")",
";",
"// Convert node names into a set positions\r",
"// This is necessary because the getNodePath returns named nodes.\r",
"// However there has to be a question mark over performance since\r",
"// an XPath query is being performed for every segment of both the\r",
"// 'this' path and the 'other' path.\r",
"// In the case where a parent has named child nodes that are not\r",
"// in a lexical order such as:\r",
"// <a>\r",
"// <c/>\r",
"// <b/>\r",
"// </a>\r",
"// Then sorting on the path will result in a list that is not\r",
"// document ordered. By changing the name for the correct position\r",
"// in the parent the set of paths can be sorted.\r",
"$",
"convert",
"=",
"function",
"(",
"$",
"xPath",
",",
"$",
"nodePath",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"nodePath",
")",
";",
"$",
"length",
"=",
"0",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"key",
"=>",
"&",
"$",
"part",
")",
"{",
"$",
"length",
"++",
";",
"if",
"(",
"$",
"part",
"==",
"\"\"",
")",
"continue",
";",
"$",
"length",
"+=",
"strlen",
"(",
"$",
"part",
")",
";",
"$",
"result",
"=",
"$",
"xPath",
"->",
"evaluate",
"(",
"\"count(\"",
".",
"substr",
"(",
"$",
"nodePath",
",",
"0",
",",
"$",
"length",
"-",
"1",
")",
".",
"\"/preceding-sibling::*) + 1\"",
")",
";",
"$",
"part",
"=",
"$",
"result",
";",
"}",
"unset",
"(",
"$",
"part",
")",
";",
"return",
"implode",
"(",
"\"/\"",
",",
"$",
"parts",
")",
";",
"}",
";",
"$",
"xPath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"thisDomNode",
"instanceof",
"\\",
"DOMDocument",
"?",
"$",
"thisDomNode",
":",
"$",
"thisDomNode",
"->",
"ownerDocument",
")",
";",
"$",
"thisPath",
"=",
"$",
"convert",
"(",
"$",
"xPath",
",",
"$",
"thisPath",
")",
";",
"$",
"xPath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"otherDomNode",
"instanceof",
"\\",
"DOMDocument",
"?",
"$",
"otherDomNode",
":",
"$",
"otherDomNode",
"->",
"ownerDocument",
")",
";",
"$",
"otherPath",
"=",
"$",
"convert",
"(",
"$",
"xPath",
",",
"$",
"otherPath",
")",
";",
"if",
"(",
"$",
"useLineNo",
")",
"{",
"$",
"thisPath",
"=",
"$",
"thisDomNode",
"->",
"getLineNo",
"(",
")",
".",
"\"-\"",
".",
"$",
"thisPath",
";",
"$",
"otherPath",
"=",
"$",
"otherDomNode",
"->",
"getLineNo",
"(",
")",
".",
"\"-\"",
".",
"$",
"otherPath",
";",
"}",
"// Using strnatcasecmp so /xx[20] will follow /xx[3] which does not happen with other sort types\r",
"$",
"compare",
"=",
"strnatcasecmp",
"(",
"$",
"thisPath",
",",
"$",
"otherPath",
")",
";",
"return",
"$",
"compare",
"==",
"0",
"?",
"XmlNodeOrder",
"::",
"Same",
":",
"(",
"$",
"compare",
"<",
"0",
"?",
"XmlNodeOrder",
"::",
"Before",
":",
"XmlNodeOrder",
"::",
"After",
")",
";",
"}"
] | Compares the position of the current XPathNavigator with the
position of the XPathNavigator specified.
@param XPathNavigator $other : The XPathNavigator to compare against.
@param bool $useLineNo (Default: false)
@return XmlNodeOrder An XmlNodeOrder value representing the comparative position of the two XPathNavigator objects. | [
"Compares",
"the",
"position",
"of",
"the",
"current",
"XPathNavigator",
"with",
"the",
"position",
"of",
"the",
"XPathNavigator",
"specified",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L155-L217 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getLineNo | public function getLineNo()
{
if ( ! isset( $this->domNode ) || $this->domNode instanceof \DOMDocument )
{
return 0;
}
return $this->domNode->getLineNo();
} | php | public function getLineNo()
{
if ( ! isset( $this->domNode ) || $this->domNode instanceof \DOMDocument )
{
return 0;
}
return $this->domNode->getLineNo();
} | [
"public",
"function",
"getLineNo",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"this",
"->",
"domNode",
"->",
"getLineNo",
"(",
")",
";",
"}"
] | return the line number in the underlying XML document of the current node | [
"return",
"the",
"line",
"number",
"in",
"the",
"underlying",
"XML",
"document",
"of",
"the",
"current",
"node"
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L222-L230 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.GetAttribute | public function GetAttribute( $localName, $namespaceURI )
{
if ( $this->domNode->nodeType != XML_ELEMENT_NODE )
{
return "";
}
foreach ( $this->domNode->attributes as /** @var \DOMAttr $attribute */ $attribute )
{
if ( $attribute->namespaceURI != $namespaceURI || $attribute->localName != $localName )
{
continue;
}
return (string)$attribute->nodeValue;
}
return "";
} | php | public function GetAttribute( $localName, $namespaceURI )
{
if ( $this->domNode->nodeType != XML_ELEMENT_NODE )
{
return "";
}
foreach ( $this->domNode->attributes as /** @var \DOMAttr $attribute */ $attribute )
{
if ( $attribute->namespaceURI != $namespaceURI || $attribute->localName != $localName )
{
continue;
}
return (string)$attribute->nodeValue;
}
return "";
} | [
"public",
"function",
"GetAttribute",
"(",
"$",
"localName",
",",
"$",
"namespaceURI",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"!=",
"XML_ELEMENT_NODE",
")",
"{",
"return",
"\"\"",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"domNode",
"->",
"attributes",
"as",
"/** @var \\DOMAttr $attribute */",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"attribute",
"->",
"namespaceURI",
"!=",
"$",
"namespaceURI",
"||",
"$",
"attribute",
"->",
"localName",
"!=",
"$",
"localName",
")",
"{",
"continue",
";",
"}",
"return",
"(",
"string",
")",
"$",
"attribute",
"->",
"nodeValue",
";",
"}",
"return",
"\"\"",
";",
"}"
] | Gets the value of the attribute with the specified local name and namespace URI.
@param string $localName : The local name of the attribute.
@param string $namespaceURI : The namespace URI of the attribute.
@return string A string that contains the value of the specified attribute; Empty
if a matching attribute is not found, or if the XPathNavigator
is not positioned on an element node. | [
"Gets",
"the",
"value",
"of",
"the",
"attribute",
"with",
"the",
"specified",
"local",
"name",
"and",
"namespace",
"URI",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L253-L271 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getHasChildren | public function getHasChildren( $type = null )
{
if ( is_null( $this->domNode ) ) return false;
$hasAnyChildren = $this->domNode->hasChildNodes();
if ( ! $hasAnyChildren || is_null( $type ) ) return $hasAnyChildren;
$clone = $this->CloneInstance();
return $clone->MoveToChild( $type );
} | php | public function getHasChildren( $type = null )
{
if ( is_null( $this->domNode ) ) return false;
$hasAnyChildren = $this->domNode->hasChildNodes();
if ( ! $hasAnyChildren || is_null( $type ) ) return $hasAnyChildren;
$clone = $this->CloneInstance();
return $clone->MoveToChild( $type );
} | [
"public",
"function",
"getHasChildren",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"false",
";",
"$",
"hasAnyChildren",
"=",
"$",
"this",
"->",
"domNode",
"->",
"hasChildNodes",
"(",
")",
";",
"if",
"(",
"!",
"$",
"hasAnyChildren",
"||",
"is_null",
"(",
"$",
"type",
")",
")",
"return",
"$",
"hasAnyChildren",
";",
"$",
"clone",
"=",
"$",
"this",
"->",
"CloneInstance",
"(",
")",
";",
"return",
"$",
"clone",
"->",
"MoveToChild",
"(",
"$",
"type",
")",
";",
"}"
] | Not used but implement
Gets a value indicating whether the current node has any child nodes.
@param XPathNodeType $type
@return bool $HasChildren true if the current node has any child nodes; otherwise, false. | [
"Not",
"used",
"but",
"implement",
"Gets",
"a",
"value",
"indicating",
"whether",
"the",
"current",
"node",
"has",
"any",
"child",
"nodes",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L305-L313 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getInnerXml | public function getInnerXml()
{
if ( is_null( $this->domNode ) ) return null;
$owner = $this->domNode instanceof \DOMDocument ? $this->domNode : $this->domNode->ownerDocument;
$xml = $owner->saveXml( $this->domNode, LIBXML_NOEMPTYTAG );
$xml = ltrim( preg_replace( "/^<\?xml.*\?>/", "", $xml ) );
$xml = ltrim( preg_replace( "/^<!DOCTYPE[^>[]*(\[[^]]*\])?>/s", "", $xml ) );
return $xml;
} | php | public function getInnerXml()
{
if ( is_null( $this->domNode ) ) return null;
$owner = $this->domNode instanceof \DOMDocument ? $this->domNode : $this->domNode->ownerDocument;
$xml = $owner->saveXml( $this->domNode, LIBXML_NOEMPTYTAG );
$xml = ltrim( preg_replace( "/^<\?xml.*\?>/", "", $xml ) );
$xml = ltrim( preg_replace( "/^<!DOCTYPE[^>[]*(\[[^]]*\])?>/s", "", $xml ) );
return $xml;
} | [
"public",
"function",
"getInnerXml",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"null",
";",
"$",
"owner",
"=",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMDocument",
"?",
"$",
"this",
"->",
"domNode",
":",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
";",
"$",
"xml",
"=",
"$",
"owner",
"->",
"saveXml",
"(",
"$",
"this",
"->",
"domNode",
",",
"LIBXML_NOEMPTYTAG",
")",
";",
"$",
"xml",
"=",
"ltrim",
"(",
"preg_replace",
"(",
"\"/^<\\?xml.*\\?>/\"",
",",
"\"\"",
",",
"$",
"xml",
")",
")",
";",
"$",
"xml",
"=",
"ltrim",
"(",
"preg_replace",
"(",
"\"/^<!DOCTYPE[^>[]*(\\[[^]]*\\])?>/s\"",
",",
"\"\"",
",",
"$",
"xml",
")",
")",
";",
"return",
"$",
"xml",
";",
"}"
] | Not used but implement
Gets or sets the markup representing the child nodes of the current node.
@return string A string that contains the markup of the child nodes of the current node. | [
"Not",
"used",
"but",
"implement",
"Gets",
"or",
"sets",
"the",
"markup",
"representing",
"the",
"child",
"nodes",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L321-L329 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getLocalName | public function getLocalName()
{
if ( is_null( $this->domNode ) ) return null;
if ( $this->domNode instanceof \DOMNameSpaceNode )
{
return $this->domNode->localName;
}
else
{
return $this->domNode->nodeType == XPathNodeType::ProcessingInstruction
? "{$this->domNode->nodeName}"
: "{$this->domNode->localName}";
}
} | php | public function getLocalName()
{
if ( is_null( $this->domNode ) ) return null;
if ( $this->domNode instanceof \DOMNameSpaceNode )
{
return $this->domNode->localName;
}
else
{
return $this->domNode->nodeType == XPathNodeType::ProcessingInstruction
? "{$this->domNode->nodeName}"
: "{$this->domNode->localName}";
}
} | [
"public",
"function",
"getLocalName",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMNameSpaceNode",
")",
"{",
"return",
"$",
"this",
"->",
"domNode",
"->",
"localName",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"==",
"XPathNodeType",
"::",
"ProcessingInstruction",
"?",
"\"{$this->domNode->nodeName}\"",
":",
"\"{$this->domNode->localName}\"",
";",
"}",
"}"
] | When overridden in a derived class, gets the XPathNavigator.Name
of the current node without any namespace prefix.
@return string A string that contains the local name of the current node, or Empty
if the current node does not have a name (for example, text or comment nodes). | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"gets",
"the",
"XPathNavigator",
".",
"Name",
"of",
"the",
"current",
"node",
"without",
"any",
"namespace",
"prefix",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L350-L363 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getName | public function getName()
{
if ( is_null( $this->domNode ) ) return null;
if ( $this->domNode instanceof \DOMNameSpaceNode )
{
return $this->domNode->prefix;
}
else
{
return empty( $this->domNode->prefix )
? "{$this->domNode->localName}"
: "{$this->domNode->prefix}:{$this->domNode->localName}";
}
} | php | public function getName()
{
if ( is_null( $this->domNode ) ) return null;
if ( $this->domNode instanceof \DOMNameSpaceNode )
{
return $this->domNode->prefix;
}
else
{
return empty( $this->domNode->prefix )
? "{$this->domNode->localName}"
: "{$this->domNode->prefix}:{$this->domNode->localName}";
}
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMNameSpaceNode",
")",
"{",
"return",
"$",
"this",
"->",
"domNode",
"->",
"prefix",
";",
"}",
"else",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"domNode",
"->",
"prefix",
")",
"?",
"\"{$this->domNode->localName}\"",
":",
"\"{$this->domNode->prefix}:{$this->domNode->localName}\"",
";",
"}",
"}"
] | When overridden in a derived class, gets the qualified name of the current node.
@return string A string that contains the qualified XPathNavigator.Name of the
current node, or Empty if the current node does not have a name
(for example, text or comment nodes). | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"gets",
"the",
"qualified",
"name",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L372-L386 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getNamespaceURI | public function getNamespaceURI()
{
if ( is_null( $this->domNode ) ) return null;
return is_null( $this->domNode->namespaceURI ) ? "" : $this->domNode->namespaceURI;
} | php | public function getNamespaceURI()
{
if ( is_null( $this->domNode ) ) return null;
return is_null( $this->domNode->namespaceURI ) ? "" : $this->domNode->namespaceURI;
} | [
"public",
"function",
"getNamespaceURI",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"null",
";",
"return",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
"->",
"namespaceURI",
")",
"?",
"\"\"",
":",
"$",
"this",
"->",
"domNode",
"->",
"namespaceURI",
";",
"}"
] | When overridden in a derived class, gets the namespace URI of the current node.
@return string A string that contains the namespace URI of the current node,
or Empty if the current node has no namespace URI. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"gets",
"the",
"namespace",
"URI",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L394-L398 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getNodeType | public function getNodeType()
{
if ( is_null( $this->domNode ) ) return null;
return isset( DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ] )
? DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ]
: XPathNodeType::Element;
} | php | public function getNodeType()
{
if ( is_null( $this->domNode ) ) return null;
return isset( DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ] )
? DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ]
: XPathNodeType::Element;
} | [
"public",
"function",
"getNodeType",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"null",
";",
"return",
"isset",
"(",
"DOMXPathNavigator",
"::",
"$",
"nodeTypeMap",
"[",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"]",
")",
"?",
"DOMXPathNavigator",
"::",
"$",
"nodeTypeMap",
"[",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"]",
":",
"XPathNodeType",
"::",
"Element",
";",
"}"
] | When overridden in a derived class, gets the XPathNodeType of the current node.
@return XPathNodeType One of the XPathNodeType values representing the current node. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"gets",
"the",
"XPathNodeType",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L416-L422 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getOuterXml | public function getOuterXml()
{
if ( is_null( $this->domNode ) ) return "";
return is_null( $this->domNode->parentNode )
? $this->domNode->ownerDocument->saveXml( $this->domNode )
: $this->domNode->ownerDocument->saveXml( $this->domNode->parentNode );
} | php | public function getOuterXml()
{
if ( is_null( $this->domNode ) ) return "";
return is_null( $this->domNode->parentNode )
? $this->domNode->ownerDocument->saveXml( $this->domNode )
: $this->domNode->ownerDocument->saveXml( $this->domNode->parentNode );
} | [
"public",
"function",
"getOuterXml",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"\"\"",
";",
"return",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
")",
"?",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
"->",
"saveXml",
"(",
"$",
"this",
"->",
"domNode",
")",
":",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
"->",
"saveXml",
"(",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
")",
";",
"}"
] | Gets or sets the markup representing the opening and closing tags of the current node and its child nodes.
@return string A string that contains the markup representing the opening and closing
tags of the current node and its child nodes. | [
"Gets",
"or",
"sets",
"the",
"markup",
"representing",
"the",
"opening",
"and",
"closing",
"tags",
"of",
"the",
"current",
"node",
"and",
"its",
"child",
"nodes",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L430-L436 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getSchemaInfo | public function getSchemaInfo()
{
if ( is_null( $this->domNode ) ) return null;
switch( $this->domNode->nodeType )
{
case XML_ATTRIBUTE_NODE:
case XML_ELEMENT_NODE:
return new DOMName( $this->domNode );
case XML_TEXT_NODE:
return new DOMName( $this->domNode->parentNode );
default:
return new DOMSchemaInfo( $this->domNode );
}
} | php | public function getSchemaInfo()
{
if ( is_null( $this->domNode ) ) return null;
switch( $this->domNode->nodeType )
{
case XML_ATTRIBUTE_NODE:
case XML_ELEMENT_NODE:
return new DOMName( $this->domNode );
case XML_TEXT_NODE:
return new DOMName( $this->domNode->parentNode );
default:
return new DOMSchemaInfo( $this->domNode );
}
} | [
"public",
"function",
"getSchemaInfo",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"null",
";",
"switch",
"(",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
")",
"{",
"case",
"XML_ATTRIBUTE_NODE",
":",
"case",
"XML_ELEMENT_NODE",
":",
"return",
"new",
"DOMName",
"(",
"$",
"this",
"->",
"domNode",
")",
";",
"case",
"XML_TEXT_NODE",
":",
"return",
"new",
"DOMName",
"(",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
")",
";",
"default",
":",
"return",
"new",
"DOMSchemaInfo",
"(",
"$",
"this",
"->",
"domNode",
")",
";",
"}",
"}"
] | Gets the schema information that has been assigned to the current node as a result of schema validation.
@return IXmlSchemaInfo An IXmlSchemaInfo object that contains the schema information
for the current node. | [
"Gets",
"the",
"schema",
"information",
"that",
"has",
"been",
"assigned",
"to",
"the",
"current",
"node",
"as",
"a",
"result",
"of",
"schema",
"validation",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L455-L471 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.getXmlLang | public function getXmlLang()
{
// Take and work on a copy of the node so it can be manipulated
$node = $this->domNode;
while ( ! $node instanceof \DOMDocument )
{
if ( $node->hasAttributes() )
{
foreach ( $node->attributes as $name => $attrNode )
{
// This should return the lang attribute of the node if there is one.
if ( $name != "lang" || $attrNode->localName != "lang" || $attrNode->namespaceURI != XmlReservedNs::xml ) continue;
return $attrNode->nodeValue;
}
}
// If not, check the parent recursively
$node = $node->parentNode;
}
return "";
} | php | public function getXmlLang()
{
// Take and work on a copy of the node so it can be manipulated
$node = $this->domNode;
while ( ! $node instanceof \DOMDocument )
{
if ( $node->hasAttributes() )
{
foreach ( $node->attributes as $name => $attrNode )
{
// This should return the lang attribute of the node if there is one.
if ( $name != "lang" || $attrNode->localName != "lang" || $attrNode->namespaceURI != XmlReservedNs::xml ) continue;
return $attrNode->nodeValue;
}
}
// If not, check the parent recursively
$node = $node->parentNode;
}
return "";
} | [
"public",
"function",
"getXmlLang",
"(",
")",
"{",
"// Take and work on a copy of the node so it can be manipulated\r",
"$",
"node",
"=",
"$",
"this",
"->",
"domNode",
";",
"while",
"(",
"!",
"$",
"node",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"hasAttributes",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"attrNode",
")",
"{",
"// This should return the lang attribute of the node if there is one.\r",
"if",
"(",
"$",
"name",
"!=",
"\"lang\"",
"||",
"$",
"attrNode",
"->",
"localName",
"!=",
"\"lang\"",
"||",
"$",
"attrNode",
"->",
"namespaceURI",
"!=",
"XmlReservedNs",
"::",
"xml",
")",
"continue",
";",
"return",
"$",
"attrNode",
"->",
"nodeValue",
";",
"}",
"}",
"// If not, check the parent recursively\r",
"$",
"node",
"=",
"$",
"node",
"->",
"parentNode",
";",
"}",
"return",
"\"\"",
";",
"}"
] | Not used but implement
Gets the xml:lang scope for the current node.
@return string $XmlLang
A string that contains the value of the xml:lang scope, or Empty
if the current node has no xml:lang scope value to return. | [
"Not",
"used",
"but",
"implement",
"Gets",
"the",
"xml",
":",
"lang",
"scope",
"for",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L493-L515 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.CloneInstance | public function CloneInstance()
{
// Clone in this sense means be able to have a different current position so creating a new
// DOMXPathNavigator instance should be sufficient. There is no need to clone the current node.
return is_null( $this->domNode )
? $this
: new DOMXPathNavigator( $this->domNode, $this->nsManager, $this->nsTable );
} | php | public function CloneInstance()
{
// Clone in this sense means be able to have a different current position so creating a new
// DOMXPathNavigator instance should be sufficient. There is no need to clone the current node.
return is_null( $this->domNode )
? $this
: new DOMXPathNavigator( $this->domNode, $this->nsManager, $this->nsTable );
} | [
"public",
"function",
"CloneInstance",
"(",
")",
"{",
"// Clone in this sense means be able to have a different current position so creating a new\r",
"// DOMXPathNavigator instance should be sufficient. There is no need to clone the current node.\r",
"return",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"?",
"$",
"this",
":",
"new",
"DOMXPathNavigator",
"(",
"$",
"this",
"->",
"domNode",
",",
"$",
"this",
"->",
"nsManager",
",",
"$",
"this",
"->",
"nsTable",
")",
";",
"}"
] | When overridden in a derived class, creates a new XPathNavigator
positioned at the same node as this XPathNavigator.
@return XPathNavigator A new XPathNavigator positioned at the same node as this XPathNavigator. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"creates",
"a",
"new",
"XPathNavigator",
"positioned",
"at",
"the",
"same",
"node",
"as",
"this",
"XPathNavigator",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L585-L592 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.IsSamePosition | public function IsSamePosition( $other )
{
if ( is_null( $this->domNode ) || is_null( $other ) ) return false;
return $this->domNode->isSameNode( $other->getUnderlyingObject() );
} | php | public function IsSamePosition( $other )
{
if ( is_null( $this->domNode ) || is_null( $other ) ) return false;
return $this->domNode->isSameNode( $other->getUnderlyingObject() );
} | [
"public",
"function",
"IsSamePosition",
"(",
"$",
"other",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"is_null",
"(",
"$",
"other",
")",
")",
"return",
"false",
";",
"return",
"$",
"this",
"->",
"domNode",
"->",
"isSameNode",
"(",
"$",
"other",
"->",
"getUnderlyingObject",
"(",
")",
")",
";",
"}"
] | When overridden in a derived class, determines whether the current XPathNavigator
is at the same position as the specified XPathNavigator.
@param XPathNavigator $other : The XPathNavigator to compare to this XPathNavigator.
@return bool true if the two XPathNavigator objects have the same position; otherwise, false. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"determines",
"whether",
"the",
"current",
"XPathNavigator",
"is",
"at",
"the",
"same",
"position",
"as",
"the",
"specified",
"XPathNavigator",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L602-L606 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.IsWhitespaceNode | public function IsWhitespaceNode()
{
return $this->getNodeType() == XPathNodeType::Text ||
$this->getNodeType() == XPathNodeType::Whitespace ||
$this->getNodeType() == XPathNodeType::SignificantWhitespace
? preg_match( "/^\s+$/", $this->getValue() ) // Test for only whitespace
: false;
} | php | public function IsWhitespaceNode()
{
return $this->getNodeType() == XPathNodeType::Text ||
$this->getNodeType() == XPathNodeType::Whitespace ||
$this->getNodeType() == XPathNodeType::SignificantWhitespace
? preg_match( "/^\s+$/", $this->getValue() ) // Test for only whitespace
: false;
} | [
"public",
"function",
"IsWhitespaceNode",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getNodeType",
"(",
")",
"==",
"XPathNodeType",
"::",
"Text",
"||",
"$",
"this",
"->",
"getNodeType",
"(",
")",
"==",
"XPathNodeType",
"::",
"Whitespace",
"||",
"$",
"this",
"->",
"getNodeType",
"(",
")",
"==",
"XPathNodeType",
"::",
"SignificantWhitespace",
"?",
"preg_match",
"(",
"\"/^\\s+$/\"",
",",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
"// Test for only whitespace\r",
":",
"false",
";",
"}"
] | IsWhitespaceNode
@return bool | [
"IsWhitespaceNode"
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L612-L619 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveTo | public function MoveTo( $other )
{
if ( is_null( $this->domNode ) || is_null( $other ) ) return false;
// Replace the domNode with a clone of the one from $other
$this->domNode = $other->getUnderlyingObject(); // ->cloneNode();
return true;
} | php | public function MoveTo( $other )
{
if ( is_null( $this->domNode ) || is_null( $other ) ) return false;
// Replace the domNode with a clone of the one from $other
$this->domNode = $other->getUnderlyingObject(); // ->cloneNode();
return true;
} | [
"public",
"function",
"MoveTo",
"(",
"$",
"other",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"is_null",
"(",
"$",
"other",
")",
")",
"return",
"false",
";",
"// Replace the domNode with a clone of the one from $other\r",
"$",
"this",
"->",
"domNode",
"=",
"$",
"other",
"->",
"getUnderlyingObject",
"(",
")",
";",
"// ->cloneNode();\r",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator
to the same position as the specified XPathNavigator.
@param XPathNavigator $other : The XPathNavigator positioned on the node that you want to move to.
@return bool true if the XPathNavigator is successful moving to the same position as the specified
XPathNavigator; otherwise, false. If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"same",
"position",
"as",
"the",
"specified",
"XPathNavigator",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L630-L637 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToChild | public function MoveToChild( $kind )
{
if ( is_null( $this->domNode ) ||
is_null( $kind ) ||
! property_exists( $this->domNode, 'firstChild') // ||
// ! $this->domNode->hasChildNodes()
) return false;
// Create a list of the valid DOM node types based on the $kind value
$domNodeTypes = array_keys( array_filter(
\lyquidity\XPath2\DOM\DOMXPathNavigator::$nodeTypeMap,
function( $nodeType ) use( $kind )
{
return $kind == \lyquidity\xml\xpath\XPathNodeType::All || $nodeType == $kind;
}
) );
// Take a copy of the dom node
/** @var \DOMNode $next */
$next = $this->domNode->firstChild;
if ( is_null( $next ) ) return;
do
{
// If the $next node type is valid then store the next node type as the new dom node and return true
if ( in_array( $next->nodeType, $domNodeTypes ) )
{
$this->domNode = $next;
return true;
}
}
while( ! is_null( $next = $next->nextSibling ) );
return false;
} | php | public function MoveToChild( $kind )
{
if ( is_null( $this->domNode ) ||
is_null( $kind ) ||
! property_exists( $this->domNode, 'firstChild') // ||
// ! $this->domNode->hasChildNodes()
) return false;
// Create a list of the valid DOM node types based on the $kind value
$domNodeTypes = array_keys( array_filter(
\lyquidity\XPath2\DOM\DOMXPathNavigator::$nodeTypeMap,
function( $nodeType ) use( $kind )
{
return $kind == \lyquidity\xml\xpath\XPathNodeType::All || $nodeType == $kind;
}
) );
// Take a copy of the dom node
/** @var \DOMNode $next */
$next = $this->domNode->firstChild;
if ( is_null( $next ) ) return;
do
{
// If the $next node type is valid then store the next node type as the new dom node and return true
if ( in_array( $next->nodeType, $domNodeTypes ) )
{
$this->domNode = $next;
return true;
}
}
while( ! is_null( $next = $next->nextSibling ) );
return false;
} | [
"public",
"function",
"MoveToChild",
"(",
"$",
"kind",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"is_null",
"(",
"$",
"kind",
")",
"||",
"!",
"property_exists",
"(",
"$",
"this",
"->",
"domNode",
",",
"'firstChild'",
")",
"// ||\r",
"// ! $this->domNode->hasChildNodes()\r",
")",
"return",
"false",
";",
"// Create a list of the valid DOM node types based on the $kind value\r",
"$",
"domNodeTypes",
"=",
"array_keys",
"(",
"array_filter",
"(",
"\\",
"lyquidity",
"\\",
"XPath2",
"\\",
"DOM",
"\\",
"DOMXPathNavigator",
"::",
"$",
"nodeTypeMap",
",",
"function",
"(",
"$",
"nodeType",
")",
"use",
"(",
"$",
"kind",
")",
"{",
"return",
"$",
"kind",
"==",
"\\",
"lyquidity",
"\\",
"xml",
"\\",
"xpath",
"\\",
"XPathNodeType",
"::",
"All",
"||",
"$",
"nodeType",
"==",
"$",
"kind",
";",
"}",
")",
")",
";",
"// Take a copy of the dom node\r",
"/** @var \\DOMNode $next */",
"$",
"next",
"=",
"$",
"this",
"->",
"domNode",
"->",
"firstChild",
";",
"if",
"(",
"is_null",
"(",
"$",
"next",
")",
")",
"return",
";",
"do",
"{",
"// If the $next node type is valid then store the next node type as the new dom node and return true\r",
"if",
"(",
"in_array",
"(",
"$",
"next",
"->",
"nodeType",
",",
"$",
"domNodeTypes",
")",
")",
"{",
"$",
"this",
"->",
"domNode",
"=",
"$",
"next",
";",
"return",
"true",
";",
"}",
"}",
"while",
"(",
"!",
"is_null",
"(",
"$",
"next",
"=",
"$",
"next",
"->",
"nextSibling",
")",
")",
";",
"return",
"false",
";",
"}"
] | Moves the XPathNavigator to the child node of the XPathNodeType specified.
@param XPathNodeType $kind The XPathNodeType of the child node to move to.
@return bool Returns true if the XPathNavigator is successful moving to the child node; otherwise, false.
If false, the position of the XPathNavigator is unchanged. | [
"Moves",
"the",
"XPathNavigator",
"to",
"the",
"child",
"node",
"of",
"the",
"XPathNodeType",
"specified",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L646-L680 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToFirstAttribute | public function MoveToFirstAttribute()
{
// If the current node is already an attribute or there are no attributes return false
if ( is_null( $this->domNode ) || $this->domNode instanceof \DOMAttr || ! $this->domNode->hasAttributes() ) return false;
$this->domNode = $this->domNode->attributes->item(0);
return true;
} | php | public function MoveToFirstAttribute()
{
// If the current node is already an attribute or there are no attributes return false
if ( is_null( $this->domNode ) || $this->domNode instanceof \DOMAttr || ! $this->domNode->hasAttributes() ) return false;
$this->domNode = $this->domNode->attributes->item(0);
return true;
} | [
"public",
"function",
"MoveToFirstAttribute",
"(",
")",
"{",
"// If the current node is already an attribute or there are no attributes return false\r",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMAttr",
"||",
"!",
"$",
"this",
"->",
"domNode",
"->",
"hasAttributes",
"(",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"this",
"->",
"domNode",
"->",
"attributes",
"->",
"item",
"(",
"0",
")",
";",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator to the first attribute of the current node.
@return bool Returns true if the XPathNavigator is successful moving to the first attribute of the current node;
otherwise, false. If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"first",
"attribute",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L688-L695 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToAttribute | public function MoveToAttribute( $localName, $namespaceURI )
{
if ( ! $this->MoveToFirstAttribute() )
{
return false;
}
do
{
if ( $this->getLocalName() == $localName && ( ( is_null( $namespaceURI ) && empty( $this->getNamespaceURI() ) ) || $this->getNamespaceURI() == $namespaceURI ) )
{
return true;
}
} while ( $this->MoveToNextAttribute() );
// If any attribute was found but not the desired attribute return to the parent
$this->MoveToParent();
return false;
} | php | public function MoveToAttribute( $localName, $namespaceURI )
{
if ( ! $this->MoveToFirstAttribute() )
{
return false;
}
do
{
if ( $this->getLocalName() == $localName && ( ( is_null( $namespaceURI ) && empty( $this->getNamespaceURI() ) ) || $this->getNamespaceURI() == $namespaceURI ) )
{
return true;
}
} while ( $this->MoveToNextAttribute() );
// If any attribute was found but not the desired attribute return to the parent
$this->MoveToParent();
return false;
} | [
"public",
"function",
"MoveToAttribute",
"(",
"$",
"localName",
",",
"$",
"namespaceURI",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"MoveToFirstAttribute",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"do",
"{",
"if",
"(",
"$",
"this",
"->",
"getLocalName",
"(",
")",
"==",
"$",
"localName",
"&&",
"(",
"(",
"is_null",
"(",
"$",
"namespaceURI",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"getNamespaceURI",
"(",
")",
")",
")",
"||",
"$",
"this",
"->",
"getNamespaceURI",
"(",
")",
"==",
"$",
"namespaceURI",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"while",
"(",
"$",
"this",
"->",
"MoveToNextAttribute",
"(",
")",
")",
";",
"// If any attribute was found but not the desired attribute return to the parent\r",
"$",
"this",
"->",
"MoveToParent",
"(",
")",
";",
"return",
"false",
";",
"}"
] | Moves the XPathNavigator to the attribute with the matching local name and namespace URI.
@param string $localName : The local name of the attribute.
@param string $namespaceURI : The namespace URI of the attribute; null for an empty namespace.
@return bool Returns true if the XPathNavigator is successful moving to the attribute; otherwise, false.
If false, the position of the XPathNavigator is unchanged. | [
"Moves",
"the",
"XPathNavigator",
"to",
"the",
"attribute",
"with",
"the",
"matching",
"local",
"name",
"and",
"namespace",
"URI",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L706-L725 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToFirstChild | public function MoveToFirstChild()
{
if (
is_null( $this->domNode ) ||
( ! $this->domNode instanceof \DOMDocument && ! $this->domNode instanceof \DOMElement ) ||
! $this->domNode->hasChildNodes()
) return false;
// if ( $this->domNode instanceof \DOMDocument )
// {
// $this->domNode = $this->domNode->documentElement;
// return true;
// }
$this->domNode = $this->domNode->firstChild;
return true;
} | php | public function MoveToFirstChild()
{
if (
is_null( $this->domNode ) ||
( ! $this->domNode instanceof \DOMDocument && ! $this->domNode instanceof \DOMElement ) ||
! $this->domNode->hasChildNodes()
) return false;
// if ( $this->domNode instanceof \DOMDocument )
// {
// $this->domNode = $this->domNode->documentElement;
// return true;
// }
$this->domNode = $this->domNode->firstChild;
return true;
} | [
"public",
"function",
"MoveToFirstChild",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"(",
"!",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMDocument",
"&&",
"!",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMElement",
")",
"||",
"!",
"$",
"this",
"->",
"domNode",
"->",
"hasChildNodes",
"(",
")",
")",
"return",
"false",
";",
"// if ( $this->domNode instanceof \\DOMDocument )\r",
"// {\r",
"// \t$this->domNode = $this->domNode->documentElement;\r",
"// \treturn true;\r",
"// }\r",
"$",
"this",
"->",
"domNode",
"=",
"$",
"this",
"->",
"domNode",
"->",
"firstChild",
";",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator to the first child node of the current node.
@return bool Returns true if the XPathNavigator is successful moving to the first child node of the current node;
otherwise, false. If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"first",
"child",
"node",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L733-L749 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToFirstNamespace | public function MoveToFirstNamespace( $namespaceScope = XPathNamespaceScope::Local )
{
if ( is_null( $this->domNode ) ) return false;
if ( $this->domNode->nodeType != XML_ELEMENT_NODE && $this->domNode->nodeType != XML_DOCUMENT_NODE ) return false;
$expression = $namespaceScope == XPathNamespaceScope::Local
? 'namespace::*[not(. = ../../namespace::*)]'
: 'namespace::*';
$xpath = new \DOMXPath( $this->domNode->nodeType == XML_DOCUMENT_NODE ? $this->domNode : $this->domNode->ownerDocument );
$namespaces = $xpath->query( $expression, $this->domNode );
if ( ! $namespaces || $namespaces->length == 0 ) return false;
$this->domNode = $namespaces[ $namespaces->length - 1 ];
return true;
} | php | public function MoveToFirstNamespace( $namespaceScope = XPathNamespaceScope::Local )
{
if ( is_null( $this->domNode ) ) return false;
if ( $this->domNode->nodeType != XML_ELEMENT_NODE && $this->domNode->nodeType != XML_DOCUMENT_NODE ) return false;
$expression = $namespaceScope == XPathNamespaceScope::Local
? 'namespace::*[not(. = ../../namespace::*)]'
: 'namespace::*';
$xpath = new \DOMXPath( $this->domNode->nodeType == XML_DOCUMENT_NODE ? $this->domNode : $this->domNode->ownerDocument );
$namespaces = $xpath->query( $expression, $this->domNode );
if ( ! $namespaces || $namespaces->length == 0 ) return false;
$this->domNode = $namespaces[ $namespaces->length - 1 ];
return true;
} | [
"public",
"function",
"MoveToFirstNamespace",
"(",
"$",
"namespaceScope",
"=",
"XPathNamespaceScope",
"::",
"Local",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"!=",
"XML_ELEMENT_NODE",
"&&",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"!=",
"XML_DOCUMENT_NODE",
")",
"return",
"false",
";",
"$",
"expression",
"=",
"$",
"namespaceScope",
"==",
"XPathNamespaceScope",
"::",
"Local",
"?",
"'namespace::*[not(. = ../../namespace::*)]'",
":",
"'namespace::*'",
";",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"==",
"XML_DOCUMENT_NODE",
"?",
"$",
"this",
"->",
"domNode",
":",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
")",
";",
"$",
"namespaces",
"=",
"$",
"xpath",
"->",
"query",
"(",
"$",
"expression",
",",
"$",
"this",
"->",
"domNode",
")",
";",
"if",
"(",
"!",
"$",
"namespaces",
"||",
"$",
"namespaces",
"->",
"length",
"==",
"0",
")",
"return",
"false",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"namespaces",
"[",
"$",
"namespaces",
"->",
"length",
"-",
"1",
"]",
";",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator to the first namespace node that matches the
XPathNamespaceScope specified.
@param XPathNamespaceScope namespaceScope : An XPathNamespaceScope value describing the namespace scope.
@return bool Returns true if the XPathNavigator is successful moving to the first namespace node; otherwise, false.
If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"first",
"namespace",
"node",
"that",
"matches",
"the",
"XPathNamespaceScope",
"specified",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L760-L776 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.isNodeAncestorOf | public function isNodeAncestorOf( $target )
{
if ( $this->domNode instanceof \DOMDocument ) return false;
if ( $target->getUnderlyingObject() instanceof \DOMDocument ) return false;
// Clone so the target's position is not changed on exit
$targetClone = $target->CloneInstance();
$targetClone->MoveToParent();
if ( $this->IsSamePosition( $targetClone ) ) return true;
return $this->isNodeAncestorOf( $targetClone );
} | php | public function isNodeAncestorOf( $target )
{
if ( $this->domNode instanceof \DOMDocument ) return false;
if ( $target->getUnderlyingObject() instanceof \DOMDocument ) return false;
// Clone so the target's position is not changed on exit
$targetClone = $target->CloneInstance();
$targetClone->MoveToParent();
if ( $this->IsSamePosition( $targetClone ) ) return true;
return $this->isNodeAncestorOf( $targetClone );
} | [
"public",
"function",
"isNodeAncestorOf",
"(",
"$",
"target",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMDocument",
")",
"return",
"false",
";",
"if",
"(",
"$",
"target",
"->",
"getUnderlyingObject",
"(",
")",
"instanceof",
"\\",
"DOMDocument",
")",
"return",
"false",
";",
"// Clone so the target's position is not changed on exit\r",
"$",
"targetClone",
"=",
"$",
"target",
"->",
"CloneInstance",
"(",
")",
";",
"$",
"targetClone",
"->",
"MoveToParent",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"IsSamePosition",
"(",
"$",
"targetClone",
")",
")",
"return",
"true",
";",
"return",
"$",
"this",
"->",
"isNodeAncestorOf",
"(",
"$",
"targetClone",
")",
";",
"}"
] | Checks to determine if the current node is an ancestor of $target
@param DOMXPathNavigator $target The node to determine if the current node is an ancestor
@return bool | [
"Checks",
"to",
"determine",
"if",
"the",
"current",
"node",
"is",
"an",
"ancestor",
"of",
"$target"
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L783-L793 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToFirst | public function MoveToFirst()
{
if ( ! isset( $this->domNode ) || ! $this->getIsNode() ) return false;
// The DOMDocument and document element are their own first siblings
if ( $this->domNode instanceof \DOMDocument || $this->domNode->parentNode instanceof \DOMDocument ) return true;
$this->domNode = $this->domNode->parentNode->firstChild;
return true;
} | php | public function MoveToFirst()
{
if ( ! isset( $this->domNode ) || ! $this->getIsNode() ) return false;
// The DOMDocument and document element are their own first siblings
if ( $this->domNode instanceof \DOMDocument || $this->domNode->parentNode instanceof \DOMDocument ) return true;
$this->domNode = $this->domNode->parentNode->firstChild;
return true;
} | [
"public",
"function",
"MoveToFirst",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"!",
"$",
"this",
"->",
"getIsNode",
"(",
")",
")",
"return",
"false",
";",
"// The DOMDocument and document element are their own first siblings\r",
"if",
"(",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMDocument",
"||",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
"instanceof",
"\\",
"DOMDocument",
")",
"return",
"true",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
"->",
"firstChild",
";",
"return",
"true",
";",
"}"
] | Moves the XPathNavigator to the first sibling node of the current node.
@return bool Returns true if the XPathNavigator is successful moving to the first sibling node of the current node;
false if there is no first sibling, or if the XPathNavigator is currently positioned on an attribute
node. If the XPathNavigator is already positioned on the first sibling, XPathNavigator will return true
and will not move its position.If XPathNavigator.MoveToFirst returns false because there is no first
sibling, or if XPathNavigator is currently positioned on an attribute, the position of the XPathNavigator
is unchanged. | [
"Moves",
"the",
"XPathNavigator",
"to",
"the",
"first",
"sibling",
"node",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L805-L814 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToFollowing | public function MoveToFollowing( $kind, $end = null )
{
if ( is_null( $this->domNode ) ||
is_null( $kind ) ||
$this->domNode instanceof \DOMAttr ||
$this->domNode instanceof \DOMNameSpaceNode
) return false;
if ( ! is_null( $end ) && $this->IsSamePosition( $end ) ) return false;
if ( $this->domNode instanceof \DOMDocument )
{
$this->domNode = $this->domNode->documentElement;
return true;
}
/**
* @var \DOMElement $node
*/
$node = $this->domNode;
while( true )
{
if ( $node->hasChildNodes() )
{
$node = $node->firstChild;
}
else
{
while( true )
{
if ( is_null( $node->nextSibling ) )
{
if ( $node->parentNode instanceof \DOMDocument ) return false;
$node = $node->parentNode;
}
else
{
$node = $node->nextSibling;
if ( ! is_null( $end ) && $node->isSameNode( $end->getUnderlyingObject() ) ) return false;
break;
}
}
}
if ( XPathNodeType::All == $kind || $node->nodeType == $kind ) break;
}
$this->domNode = $node;
return true;
} | php | public function MoveToFollowing( $kind, $end = null )
{
if ( is_null( $this->domNode ) ||
is_null( $kind ) ||
$this->domNode instanceof \DOMAttr ||
$this->domNode instanceof \DOMNameSpaceNode
) return false;
if ( ! is_null( $end ) && $this->IsSamePosition( $end ) ) return false;
if ( $this->domNode instanceof \DOMDocument )
{
$this->domNode = $this->domNode->documentElement;
return true;
}
/**
* @var \DOMElement $node
*/
$node = $this->domNode;
while( true )
{
if ( $node->hasChildNodes() )
{
$node = $node->firstChild;
}
else
{
while( true )
{
if ( is_null( $node->nextSibling ) )
{
if ( $node->parentNode instanceof \DOMDocument ) return false;
$node = $node->parentNode;
}
else
{
$node = $node->nextSibling;
if ( ! is_null( $end ) && $node->isSameNode( $end->getUnderlyingObject() ) ) return false;
break;
}
}
}
if ( XPathNodeType::All == $kind || $node->nodeType == $kind ) break;
}
$this->domNode = $node;
return true;
} | [
"public",
"function",
"MoveToFollowing",
"(",
"$",
"kind",
",",
"$",
"end",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"is_null",
"(",
"$",
"kind",
")",
"||",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMAttr",
"||",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMNameSpaceNode",
")",
"return",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"end",
")",
"&&",
"$",
"this",
"->",
"IsSamePosition",
"(",
"$",
"end",
")",
")",
"return",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"$",
"this",
"->",
"domNode",
"=",
"$",
"this",
"->",
"domNode",
"->",
"documentElement",
";",
"return",
"true",
";",
"}",
"/**\r\n\t\t * @var \\DOMElement $node\r\n\t\t */",
"$",
"node",
"=",
"$",
"this",
"->",
"domNode",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"hasChildNodes",
"(",
")",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"firstChild",
";",
"}",
"else",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"node",
"->",
"nextSibling",
")",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"parentNode",
"instanceof",
"\\",
"DOMDocument",
")",
"return",
"false",
";",
"$",
"node",
"=",
"$",
"node",
"->",
"parentNode",
";",
"}",
"else",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"nextSibling",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"end",
")",
"&&",
"$",
"node",
"->",
"isSameNode",
"(",
"$",
"end",
"->",
"getUnderlyingObject",
"(",
")",
")",
")",
"return",
"false",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"XPathNodeType",
"::",
"All",
"==",
"$",
"kind",
"||",
"$",
"node",
"->",
"nodeType",
"==",
"$",
"kind",
")",
"break",
";",
"}",
"$",
"this",
"->",
"domNode",
"=",
"$",
"node",
";",
"return",
"true",
";",
"}"
] | Moves the XPathNavigator to the following element of the XPathNodeType specified, to the boundary specified,
in document order.
@param XPathNodeType $kind : The XPathNodeType of the element. The XPathNodeType cannot be XPathNodeType.Attribute or
XPathNodeType.Namespace.
@param XPathNavigator $end : (optional) The XPathNavigator object positioned on the element boundary which the current
XPathNavigator will not move past while searching for the following element.
@return bool true if the XPathNavigator moved successfully; otherwise false. | [
"Moves",
"the",
"XPathNavigator",
"to",
"the",
"following",
"element",
"of",
"the",
"XPathNodeType",
"specified",
"to",
"the",
"boundary",
"specified",
"in",
"document",
"order",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L827-L878 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToNext | public function MoveToNext( $kind = XPathNodeType::All )
{
if ( is_null( $this->domNode ) || is_null( $kind ) /* || ! $this->domNode instanceof \DOMElement */ ) return false;
// Create a list of the valid DOM node types based on the $kind value
$domNodeTypes = array_keys( array_filter(
DOMXPathNavigator::$nodeTypeMap,
function( $nodeType ) use( $kind )
{
return $kind == XPathNodeType::All || $nodeType == $kind;
}
) );
// Take a copy of the dom node
$next = $this->domNode;
while( ! is_null( $next = $next->nextSibling ) )
{
// If the $next node type is valid then store the next node type as the new dom node and return true
if ( in_array( $next->nodeType, $domNodeTypes ) )
{
$this->domNode = $next;
return true;
}
}
return false;
} | php | public function MoveToNext( $kind = XPathNodeType::All )
{
if ( is_null( $this->domNode ) || is_null( $kind ) /* || ! $this->domNode instanceof \DOMElement */ ) return false;
// Create a list of the valid DOM node types based on the $kind value
$domNodeTypes = array_keys( array_filter(
DOMXPathNavigator::$nodeTypeMap,
function( $nodeType ) use( $kind )
{
return $kind == XPathNodeType::All || $nodeType == $kind;
}
) );
// Take a copy of the dom node
$next = $this->domNode;
while( ! is_null( $next = $next->nextSibling ) )
{
// If the $next node type is valid then store the next node type as the new dom node and return true
if ( in_array( $next->nodeType, $domNodeTypes ) )
{
$this->domNode = $next;
return true;
}
}
return false;
} | [
"public",
"function",
"MoveToNext",
"(",
"$",
"kind",
"=",
"XPathNodeType",
"::",
"All",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"is_null",
"(",
"$",
"kind",
")",
"/* || ! $this->domNode instanceof \\DOMElement */",
")",
"return",
"false",
";",
"// Create a list of the valid DOM node types based on the $kind value\r",
"$",
"domNodeTypes",
"=",
"array_keys",
"(",
"array_filter",
"(",
"DOMXPathNavigator",
"::",
"$",
"nodeTypeMap",
",",
"function",
"(",
"$",
"nodeType",
")",
"use",
"(",
"$",
"kind",
")",
"{",
"return",
"$",
"kind",
"==",
"XPathNodeType",
"::",
"All",
"||",
"$",
"nodeType",
"==",
"$",
"kind",
";",
"}",
")",
")",
";",
"// Take a copy of the dom node\r",
"$",
"next",
"=",
"$",
"this",
"->",
"domNode",
";",
"while",
"(",
"!",
"is_null",
"(",
"$",
"next",
"=",
"$",
"next",
"->",
"nextSibling",
")",
")",
"{",
"// If the $next node type is valid then store the next node type as the new dom node and return true\r",
"if",
"(",
"in_array",
"(",
"$",
"next",
"->",
"nodeType",
",",
"$",
"domNodeTypes",
")",
")",
"{",
"$",
"this",
"->",
"domNode",
"=",
"$",
"next",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Moves the XPathNavigator to the next sibling node of the current
node that matches the XPathNodeType specified.
@param XPathNodeType $kind : (optional) The XPathNodeType of the sibling node to move to.
@return bool true if the XPathNavigator is successful moving to the next sibling node; otherwise,
false if there are no more siblings or if the XPathNavigator is currently positioned
on an attribute node. If false, the position of the XPathNavigator is unchanged. | [
"Moves",
"the",
"XPathNavigator",
"to",
"the",
"next",
"sibling",
"node",
"of",
"the",
"current",
"node",
"that",
"matches",
"the",
"XPathNodeType",
"specified",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L889-L915 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToNextAttribute | public function MoveToNextAttribute()
{
if ( is_null( $this->domNode ) || ! $this->domNode instanceof \DOMAttr )
{
return false;
}
$next = $this->domNode->nextSibling;
if ( is_null( $next ) ) return false;
$this->domNode = $next;
return true;
} | php | public function MoveToNextAttribute()
{
if ( is_null( $this->domNode ) || ! $this->domNode instanceof \DOMAttr )
{
return false;
}
$next = $this->domNode->nextSibling;
if ( is_null( $next ) ) return false;
$this->domNode = $next;
return true;
} | [
"public",
"function",
"MoveToNextAttribute",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"!",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMAttr",
")",
"{",
"return",
"false",
";",
"}",
"$",
"next",
"=",
"$",
"this",
"->",
"domNode",
"->",
"nextSibling",
";",
"if",
"(",
"is_null",
"(",
"$",
"next",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"next",
";",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator
to the next attribute.
@return bool Returns true if the XPathNavigator is successful moving to the next attribute;
false if there are no more attributes. If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"next",
"attribute",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L924-L937 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToNextNamespace | public function MoveToNextNamespace( $namespaceScope = XPathNamespaceScope::Local )
{
if ( is_null( $this->domNode ) ) return false;
if ( $this->domNode->nodeType != XML_NAMESPACE_DECL_NODE ) return false;
$expression = $namespaceScope == XPathNamespaceScope::Local
? 'namespace::*[not(. = ../../namespace::*)]'
: 'namespace::*';
$xpath = new \DOMXPath( $this->domNode->nodeType == XML_DOCUMENT_NODE ? $this->domNode : $this->domNode->ownerDocument );
$namespaces = $xpath->query( $expression, $this->domNode->parentNode );
if ( ! count( $namespaces ) ) return false;
// Find the current node among the enties in the $namespaces list
$current = -1;
foreach ( $namespaces as $node )
{
$current++;
// Can't use the ->isSameNode() function with a DOMNamespaceNode for some reason
// So this concoction is used instead.
if ( $this->domNode->parentNode->getNodePath() . "/" . $this->domNode->nodeName == $node->parentNode->getNodePath() . "/" . $node->nodeName )
{
break;
}
}
if ( $current <= 0 ) return false;
$current--;
$this->domNode = $namespaces[ $current ];
return true;
} | php | public function MoveToNextNamespace( $namespaceScope = XPathNamespaceScope::Local )
{
if ( is_null( $this->domNode ) ) return false;
if ( $this->domNode->nodeType != XML_NAMESPACE_DECL_NODE ) return false;
$expression = $namespaceScope == XPathNamespaceScope::Local
? 'namespace::*[not(. = ../../namespace::*)]'
: 'namespace::*';
$xpath = new \DOMXPath( $this->domNode->nodeType == XML_DOCUMENT_NODE ? $this->domNode : $this->domNode->ownerDocument );
$namespaces = $xpath->query( $expression, $this->domNode->parentNode );
if ( ! count( $namespaces ) ) return false;
// Find the current node among the enties in the $namespaces list
$current = -1;
foreach ( $namespaces as $node )
{
$current++;
// Can't use the ->isSameNode() function with a DOMNamespaceNode for some reason
// So this concoction is used instead.
if ( $this->domNode->parentNode->getNodePath() . "/" . $this->domNode->nodeName == $node->parentNode->getNodePath() . "/" . $node->nodeName )
{
break;
}
}
if ( $current <= 0 ) return false;
$current--;
$this->domNode = $namespaces[ $current ];
return true;
} | [
"public",
"function",
"MoveToNextNamespace",
"(",
"$",
"namespaceScope",
"=",
"XPathNamespaceScope",
"::",
"Local",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"!=",
"XML_NAMESPACE_DECL_NODE",
")",
"return",
"false",
";",
"$",
"expression",
"=",
"$",
"namespaceScope",
"==",
"XPathNamespaceScope",
"::",
"Local",
"?",
"'namespace::*[not(. = ../../namespace::*)]'",
":",
"'namespace::*'",
";",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"==",
"XML_DOCUMENT_NODE",
"?",
"$",
"this",
"->",
"domNode",
":",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
")",
";",
"$",
"namespaces",
"=",
"$",
"xpath",
"->",
"query",
"(",
"$",
"expression",
",",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
")",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"namespaces",
")",
")",
"return",
"false",
";",
"// Find the current node among the enties in the $namespaces list\r",
"$",
"current",
"=",
"-",
"1",
";",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"node",
")",
"{",
"$",
"current",
"++",
";",
"// Can't use the ->isSameNode() function with a DOMNamespaceNode for some reason\r",
"// So this concoction is used instead.\r",
"if",
"(",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
"->",
"getNodePath",
"(",
")",
".",
"\"/\"",
".",
"$",
"this",
"->",
"domNode",
"->",
"nodeName",
"==",
"$",
"node",
"->",
"parentNode",
"->",
"getNodePath",
"(",
")",
".",
"\"/\"",
".",
"$",
"node",
"->",
"nodeName",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"current",
"<=",
"0",
")",
"return",
"false",
";",
"$",
"current",
"--",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"namespaces",
"[",
"$",
"current",
"]",
";",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator to the next namespace node matching the
XPathNamespaceScope specified.
@param XPathNamespaceScope $namespaceScope : (optional) An XPathNamespaceScope value describing the namespace scope.
@return bool Returns true if the XPathNavigator is successful moving to the next namespace node; otherwise,
false. If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"next",
"namespace",
"node",
"matching",
"the",
"XPathNamespaceScope",
"specified",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L947-L980 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToParent | public function MoveToParent()
{
if ( is_null( $this->domNode ) ) return false;
$parent = $this->domNode->parentNode;
if ( is_null( $parent ) ) return false;
$this->domNode = $parent;
return true;
} | php | public function MoveToParent()
{
if ( is_null( $this->domNode ) ) return false;
$parent = $this->domNode->parentNode;
if ( is_null( $parent ) ) return false;
$this->domNode = $parent;
return true;
} | [
"public",
"function",
"MoveToParent",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"false",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"domNode",
"->",
"parentNode",
";",
"if",
"(",
"is_null",
"(",
"$",
"parent",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"parent",
";",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator to the parent node of the current node.
@return bool Returns true if the XPathNavigator is successful moving to the parent node of the current node; otherwise,
false. If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"parent",
"node",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L988-L997 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToPrevious | public function MoveToPrevious()
{
if ( is_null( $this->domNode ) || $this->domNode instanceof \DOMAttr ) return false;
$previous = $this->domNode->previousSibling;
if ( is_null( $previous ) ) return false;
$this->domNode = $previous;
return true;
} | php | public function MoveToPrevious()
{
if ( is_null( $this->domNode ) || $this->domNode instanceof \DOMAttr ) return false;
$previous = $this->domNode->previousSibling;
if ( is_null( $previous ) ) return false;
$this->domNode = $previous;
return true;
} | [
"public",
"function",
"MoveToPrevious",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
"||",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMAttr",
")",
"return",
"false",
";",
"$",
"previous",
"=",
"$",
"this",
"->",
"domNode",
"->",
"previousSibling",
";",
"if",
"(",
"is_null",
"(",
"$",
"previous",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"previous",
";",
"return",
"true",
";",
"}"
] | When overridden in a derived class, moves the XPathNavigator to the previous sibling node of the current node.
@return bool Returns true if the XPathNavigator is successful moving to the previous sibling node; otherwise,
false if there is no previous sibling node or if the XPathNavigator is currently positioned on an
attribute node. If false, the position of the XPathNavigator is unchanged. | [
"When",
"overridden",
"in",
"a",
"derived",
"class",
"moves",
"the",
"XPathNavigator",
"to",
"the",
"previous",
"sibling",
"node",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L1006-L1016 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToDocumentElement | public function MoveToDocumentElement()
{
if ( is_null( $this->domNode ) ) return false;
// Already at the root?
$newNode = $this->domNode->nodeType == XML_DOCUMENT_NODE
? $this->domNode
: $this->domNode->ownerDocument;
$this->domNode = $newNode->documentElement;
return true;
} | php | public function MoveToDocumentElement()
{
if ( is_null( $this->domNode ) ) return false;
// Already at the root?
$newNode = $this->domNode->nodeType == XML_DOCUMENT_NODE
? $this->domNode
: $this->domNode->ownerDocument;
$this->domNode = $newNode->documentElement;
return true;
} | [
"public",
"function",
"MoveToDocumentElement",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"false",
";",
"// Already at the root?\r",
"$",
"newNode",
"=",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"==",
"XML_DOCUMENT_NODE",
"?",
"$",
"this",
"->",
"domNode",
":",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"newNode",
"->",
"documentElement",
";",
"return",
"true",
";",
"}"
] | Moves the XPathNavigator to the root node that the current node belongs to.
@return void | [
"Moves",
"the",
"XPathNavigator",
"to",
"the",
"root",
"node",
"that",
"the",
"current",
"node",
"belongs",
"to",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L1022-L1033 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.MoveToRoot | public function MoveToRoot()
{
if ( is_null( $this->domNode ) ) return false;
// Already at the root?
if ( $this->domNode->nodeType == XML_DOCUMENT_NODE ) return true;
$this->domNode = $this->domNode->ownerDocument;
return true;
} | php | public function MoveToRoot()
{
if ( is_null( $this->domNode ) ) return false;
// Already at the root?
if ( $this->domNode->nodeType == XML_DOCUMENT_NODE ) return true;
$this->domNode = $this->domNode->ownerDocument;
return true;
} | [
"public",
"function",
"MoveToRoot",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"false",
";",
"// Already at the root?\r",
"if",
"(",
"$",
"this",
"->",
"domNode",
"->",
"nodeType",
"==",
"XML_DOCUMENT_NODE",
")",
"return",
"true",
";",
"$",
"this",
"->",
"domNode",
"=",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
";",
"return",
"true",
";",
"}"
] | Moves the XPathNavigator to the root node that the current node belongs to.
@return void | [
"Moves",
"the",
"XPathNavigator",
"to",
"the",
"root",
"node",
"that",
"the",
"current",
"node",
"belongs",
"to",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L1039-L1048 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.SelectChildrenByName | public function SelectChildrenByName( $name, $namespaceURI )
{
$clone = $this->CloneInstance();
if ( ! $clone->getHasChildren() )
return new XPathNodeIterator( null, null );
$clone->MoveToFirstChild();
return new XPathNodeIterator( $this, function( /** @var DOMXPathNavigator $nav */ $nav ) use( $name, $namespaceURI )
{
return $nav->getLocalName() == $name && ( empty( $namespace ) || $nav->getNamespaceURI() == $namespaceURI ) ;
} );
} | php | public function SelectChildrenByName( $name, $namespaceURI )
{
$clone = $this->CloneInstance();
if ( ! $clone->getHasChildren() )
return new XPathNodeIterator( null, null );
$clone->MoveToFirstChild();
return new XPathNodeIterator( $this, function( /** @var DOMXPathNavigator $nav */ $nav ) use( $name, $namespaceURI )
{
return $nav->getLocalName() == $name && ( empty( $namespace ) || $nav->getNamespaceURI() == $namespaceURI ) ;
} );
} | [
"public",
"function",
"SelectChildrenByName",
"(",
"$",
"name",
",",
"$",
"namespaceURI",
")",
"{",
"$",
"clone",
"=",
"$",
"this",
"->",
"CloneInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"clone",
"->",
"getHasChildren",
"(",
")",
")",
"return",
"new",
"XPathNodeIterator",
"(",
"null",
",",
"null",
")",
";",
"$",
"clone",
"->",
"MoveToFirstChild",
"(",
")",
";",
"return",
"new",
"XPathNodeIterator",
"(",
"$",
"this",
",",
"function",
"(",
"/** @var DOMXPathNavigator $nav */",
"$",
"nav",
")",
"use",
"(",
"$",
"name",
",",
"$",
"namespaceURI",
")",
"{",
"return",
"$",
"nav",
"->",
"getLocalName",
"(",
")",
"==",
"$",
"name",
"&&",
"(",
"empty",
"(",
"$",
"namespace",
")",
"||",
"$",
"nav",
"->",
"getNamespaceURI",
"(",
")",
"==",
"$",
"namespaceURI",
")",
";",
"}",
")",
";",
"}"
] | Not used
Selects all the child nodes of the current node that have the local name and
namespace URI specified.
@param string $name : The local name of the child nodes.
@param string $namespaceURI : The namespace URI of the child nodes.
@return XPathNodeIterator An XPathNodeIterator that contains the selected nodes.
@throws \lyquidity\xml\exceptions\ArgumentNullException: null cannot be passed as a parameter. | [
"Not",
"used",
"Selects",
"all",
"the",
"child",
"nodes",
"of",
"the",
"current",
"node",
"that",
"have",
"the",
"local",
"name",
"and",
"namespace",
"URI",
"specified",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L1062-L1073 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.SelectChildrenByType | public function SelectChildrenByType( $type )
{
$clone = $this->CloneInstance();
if ( ! $clone->getHasChildren() )
return EmptyIterator::$Shared; // XPathNodeIterator( null, null );
if ( ! $clone->MoveToFirstChild() )
return EmptyIterator::$Shared; //XPathNodeIterator( null, null );
return new XPathNodeIterator( $clone, function( /** @var DOMXPathNavigator $nav */ $nav ) use( $type )
{
$nodeType = $nav->getNodeType();
return $type == XPathNodeType::All || $type == $nodeType;
} );
} | php | public function SelectChildrenByType( $type )
{
$clone = $this->CloneInstance();
if ( ! $clone->getHasChildren() )
return EmptyIterator::$Shared; // XPathNodeIterator( null, null );
if ( ! $clone->MoveToFirstChild() )
return EmptyIterator::$Shared; //XPathNodeIterator( null, null );
return new XPathNodeIterator( $clone, function( /** @var DOMXPathNavigator $nav */ $nav ) use( $type )
{
$nodeType = $nav->getNodeType();
return $type == XPathNodeType::All || $type == $nodeType;
} );
} | [
"public",
"function",
"SelectChildrenByType",
"(",
"$",
"type",
")",
"{",
"$",
"clone",
"=",
"$",
"this",
"->",
"CloneInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"clone",
"->",
"getHasChildren",
"(",
")",
")",
"return",
"EmptyIterator",
"::",
"$",
"Shared",
";",
"// XPathNodeIterator( null, null );\r",
"if",
"(",
"!",
"$",
"clone",
"->",
"MoveToFirstChild",
"(",
")",
")",
"return",
"EmptyIterator",
"::",
"$",
"Shared",
";",
"//XPathNodeIterator( null, null );\r",
"return",
"new",
"XPathNodeIterator",
"(",
"$",
"clone",
",",
"function",
"(",
"/** @var DOMXPathNavigator $nav */",
"$",
"nav",
")",
"use",
"(",
"$",
"type",
")",
"{",
"$",
"nodeType",
"=",
"$",
"nav",
"->",
"getNodeType",
"(",
")",
";",
"return",
"$",
"type",
"==",
"XPathNodeType",
"::",
"All",
"||",
"$",
"type",
"==",
"$",
"nodeType",
";",
"}",
")",
";",
"}"
] | Not used
Selects all the child nodes of the current node that have the local name and
namespace URI specified.
@param XPathNodeType $type : The type of the child nodes to return.
@return XPathNodeIterator An XPathNodeIterator that contains the selected nodes.
@throws \lyquidity\xml\exceptions\ArgumentNullException: null cannot be passed as a parameter. | [
"Not",
"used",
"Selects",
"all",
"the",
"child",
"nodes",
"of",
"the",
"current",
"node",
"that",
"have",
"the",
"local",
"name",
"and",
"namespace",
"URI",
"specified",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L1084-L1098 |
bseddon/XPath20 | DOM/DOMXPathNavigator.php | DOMXPathNavigator.ToString | public function ToString()
{
if ( is_null( $this->domNode ) ) return "";
if ( $this->domNode instanceof \DOMDocument )
{
$result = $this->domNode->saveXML( null );
// Remove any initial PI
$result = preg_replace( "/^<\?xml.*\?>\s/", "", $result );
return $result;
}
else
{
// InnerXml?
// return array_reduce(
// iterator_to_array( $this->domNode->childNodes ),
// function ( $carry, /** @var \DOMNode */ $child )
// {
// return $carry.$child->ownerDocument->saveXML( $child );
// }
// );
$result = $this->domNode->ownerDocument->SaveXML( $this->domNode );
return $result;
}
} | php | public function ToString()
{
if ( is_null( $this->domNode ) ) return "";
if ( $this->domNode instanceof \DOMDocument )
{
$result = $this->domNode->saveXML( null );
// Remove any initial PI
$result = preg_replace( "/^<\?xml.*\?>\s/", "", $result );
return $result;
}
else
{
// InnerXml?
// return array_reduce(
// iterator_to_array( $this->domNode->childNodes ),
// function ( $carry, /** @var \DOMNode */ $child )
// {
// return $carry.$child->ownerDocument->saveXML( $child );
// }
// );
$result = $this->domNode->ownerDocument->SaveXML( $this->domNode );
return $result;
}
} | [
"public",
"function",
"ToString",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"domNode",
")",
")",
"return",
"\"\"",
";",
"if",
"(",
"$",
"this",
"->",
"domNode",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"domNode",
"->",
"saveXML",
"(",
"null",
")",
";",
"// Remove any initial PI\r",
"$",
"result",
"=",
"preg_replace",
"(",
"\"/^<\\?xml.*\\?>\\s/\"",
",",
"\"\"",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"// InnerXml?\r",
"// return array_reduce(\r",
"// \titerator_to_array( $this->domNode->childNodes ),\r",
"// \tfunction ( $carry, /** @var \\DOMNode */ $child )\r",
"// \t{\r",
"// \t\treturn $carry.$child->ownerDocument->saveXML( $child );\r",
"// \t}\r",
"// );\r",
"$",
"result",
"=",
"$",
"this",
"->",
"domNode",
"->",
"ownerDocument",
"->",
"SaveXML",
"(",
"$",
"this",
"->",
"domNode",
")",
";",
"return",
"$",
"result",
";",
"}",
"}"
] | Gets the text value of the current node.
@return string A string that contains the text value of the current node. | [
"Gets",
"the",
"text",
"value",
"of",
"the",
"current",
"node",
"."
] | train | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L1105-L1128 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/Index/IndexFactory.php | IndexFactory.create | public function create($name, $hashKey, $rangeKey, $projectionType, $projectionAttributes, $readCapacity, $writeCapacity)
{
if ($rangeKey !== null) {
return new CompositeIndex($this->class, $name, $hashKey, $rangeKey, $projectionType, $projectionAttributes, $readCapacity, $writeCapacity);
}
return new Index($this->class, $name, $hashKey, $projectionType, $projectionAttributes, $readCapacity, $writeCapacity);
} | php | public function create($name, $hashKey, $rangeKey, $projectionType, $projectionAttributes, $readCapacity, $writeCapacity)
{
if ($rangeKey !== null) {
return new CompositeIndex($this->class, $name, $hashKey, $rangeKey, $projectionType, $projectionAttributes, $readCapacity, $writeCapacity);
}
return new Index($this->class, $name, $hashKey, $projectionType, $projectionAttributes, $readCapacity, $writeCapacity);
} | [
"public",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"hashKey",
",",
"$",
"rangeKey",
",",
"$",
"projectionType",
",",
"$",
"projectionAttributes",
",",
"$",
"readCapacity",
",",
"$",
"writeCapacity",
")",
"{",
"if",
"(",
"$",
"rangeKey",
"!==",
"null",
")",
"{",
"return",
"new",
"CompositeIndex",
"(",
"$",
"this",
"->",
"class",
",",
"$",
"name",
",",
"$",
"hashKey",
",",
"$",
"rangeKey",
",",
"$",
"projectionType",
",",
"$",
"projectionAttributes",
",",
"$",
"readCapacity",
",",
"$",
"writeCapacity",
")",
";",
"}",
"return",
"new",
"Index",
"(",
"$",
"this",
"->",
"class",
",",
"$",
"name",
",",
"$",
"hashKey",
",",
"$",
"projectionType",
",",
"$",
"projectionAttributes",
",",
"$",
"readCapacity",
",",
"$",
"writeCapacity",
")",
";",
"}"
] | @param string $name
@param HashKey $hashKey
@param RangeKey|null $rangeKey
@param string $projectionType
@param array|null $projectionAttributes
@param string $readCapacity
@param string $writeCapacity
@return CompositeIndex|Index | [
"@param",
"string",
"$name",
"@param",
"HashKey",
"$hashKey",
"@param",
"RangeKey|null",
"$rangeKey",
"@param",
"string",
"$projectionType",
"@param",
"array|null",
"$projectionAttributes",
"@param",
"string",
"$readCapacity",
"@param",
"string",
"$writeCapacity"
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/Index/IndexFactory.php#L52-L59 |
ciims/ciims-plugins-awsuploader | CiiAWSUploader.php | CiiAWSUploader.getCdnURI | private function getCdnURI($path)
{
$cleancdn = explode('/', $path);
unset($cleancdn[0]);
unset($cleancdn[1]);
reset($cleancdn);
return implode($cleancdn, '/');
} | php | private function getCdnURI($path)
{
$cleancdn = explode('/', $path);
unset($cleancdn[0]);
unset($cleancdn[1]);
reset($cleancdn);
return implode($cleancdn, '/');
} | [
"private",
"function",
"getCdnURI",
"(",
"$",
"path",
")",
"{",
"$",
"cleancdn",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"unset",
"(",
"$",
"cleancdn",
"[",
"0",
"]",
")",
";",
"unset",
"(",
"$",
"cleancdn",
"[",
"1",
"]",
")",
";",
"reset",
"(",
"$",
"cleancdn",
")",
";",
"return",
"implode",
"(",
"$",
"cleancdn",
",",
"'/'",
")",
";",
"}"
] | Retrieves a clean version of the CDN URI
@param string $path
@return string | [
"Retrieves",
"a",
"clean",
"version",
"of",
"the",
"CDN",
"URI"
] | train | https://github.com/ciims/ciims-plugins-awsuploader/blob/59e447e59f873521ebf966051fab6334696546a2/CiiAWSUploader.php#L60-L67 |
jkaflik/process-util | src/ProcessUtil/ProcessUtil.php | ProcessUtil.executeCommand | public function executeCommand(array $arguments, $processBuilderCallback = null)
{
$processBuilder = clone $this->processBuilder;
$processBuilder->setArguments($arguments);
if (is_callable($processBuilderCallback)) {
$processBuilderCallback($processBuilder);
}
$process = $processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
if (127 === $process->getExitCode()) {
throw new ExecutableNotFoundException($process);
}
throw new ProcessFailedException($process);
}
return $process;
} | php | public function executeCommand(array $arguments, $processBuilderCallback = null)
{
$processBuilder = clone $this->processBuilder;
$processBuilder->setArguments($arguments);
if (is_callable($processBuilderCallback)) {
$processBuilderCallback($processBuilder);
}
$process = $processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
if (127 === $process->getExitCode()) {
throw new ExecutableNotFoundException($process);
}
throw new ProcessFailedException($process);
}
return $process;
} | [
"public",
"function",
"executeCommand",
"(",
"array",
"$",
"arguments",
",",
"$",
"processBuilderCallback",
"=",
"null",
")",
"{",
"$",
"processBuilder",
"=",
"clone",
"$",
"this",
"->",
"processBuilder",
";",
"$",
"processBuilder",
"->",
"setArguments",
"(",
"$",
"arguments",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"processBuilderCallback",
")",
")",
"{",
"$",
"processBuilderCallback",
"(",
"$",
"processBuilder",
")",
";",
"}",
"$",
"process",
"=",
"$",
"processBuilder",
"->",
"getProcess",
"(",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"if",
"(",
"!",
"$",
"process",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"if",
"(",
"127",
"===",
"$",
"process",
"->",
"getExitCode",
"(",
")",
")",
"{",
"throw",
"new",
"ExecutableNotFoundException",
"(",
"$",
"process",
")",
";",
"}",
"throw",
"new",
"ProcessFailedException",
"(",
"$",
"process",
")",
";",
"}",
"return",
"$",
"process",
";",
"}"
] | Executes given command
@param array $arguments
@param null $processBuilderCallback
@return \Symfony\Component\Process\Process
@throws ExecutableNotFoundException
@throws ProcessFailedException | [
"Executes",
"given",
"command"
] | train | https://github.com/jkaflik/process-util/blob/8d77f677189980e18e7b57e836d8908b56822bb8/src/ProcessUtil/ProcessUtil.php#L63-L84 |
QueuePHP/Queue | src/Worker/Worker.php | Worker.runJob | private function runJob(JobInterface $job)
{
$this->log(LogLevel::DEBUG, 'Job starting');
$status = $this->executor->execute($job);
$this->log(LogLevel::DEBUG, 'Job finished');
return $status;
} | php | private function runJob(JobInterface $job)
{
$this->log(LogLevel::DEBUG, 'Job starting');
$status = $this->executor->execute($job);
$this->log(LogLevel::DEBUG, 'Job finished');
return $status;
} | [
"private",
"function",
"runJob",
"(",
"JobInterface",
"$",
"job",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"DEBUG",
",",
"'Job starting'",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"executor",
"->",
"execute",
"(",
"$",
"job",
")",
";",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"DEBUG",
",",
"'Job finished'",
")",
";",
"return",
"$",
"status",
";",
"}"
] | @param JobInterface $job
@return bool | [
"@param",
"JobInterface",
"$job"
] | train | https://github.com/QueuePHP/Queue/blob/b21b9ff87430f9aaf3a07e2591601363642019bc/src/Worker/Worker.php#L122-L129 |
angrycoders/db-driver | src/Db.php | Db.createTable | public function createTable($tableName, $attributes)
{
try {
$this->db->createTable($tableName, $attributes);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | php | public function createTable($tableName, $attributes)
{
try {
$this->db->createTable($tableName, $attributes);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | [
"public",
"function",
"createTable",
"(",
"$",
"tableName",
",",
"$",
"attributes",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"createTable",
"(",
"$",
"tableName",
",",
"$",
"attributes",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DbException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Creates a table with the specified name and attributes
@param string $tableName
@param array $attributes
@throws DbException | [
"Creates",
"a",
"table",
"with",
"the",
"specified",
"name",
"and",
"attributes"
] | train | https://github.com/angrycoders/db-driver/blob/e5df527ac0ea5fa434cbda79692f37cf6f2abc73/src/Db.php#L60-L67 |
angrycoders/db-driver | src/Db.php | Db.deleteTable | public function deleteTable($tableName)
{
try {
$this->db->deleteTable($tableName);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | php | public function deleteTable($tableName)
{
try {
$this->db->deleteTable($tableName);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | [
"public",
"function",
"deleteTable",
"(",
"$",
"tableName",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"deleteTable",
"(",
"$",
"tableName",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DbException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Delete a table from db
@param string $tableName the name of the table
@throws DbException | [
"Delete",
"a",
"table",
"from",
"db"
] | train | https://github.com/angrycoders/db-driver/blob/e5df527ac0ea5fa434cbda79692f37cf6f2abc73/src/Db.php#L74-L81 |
angrycoders/db-driver | src/Db.php | Db.insertRecord | public function insertRecord($tableName, $newRecord)
{
try {
$this->db->insertRecord($tableName, $newRecord);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | php | public function insertRecord($tableName, $newRecord)
{
try {
$this->db->insertRecord($tableName, $newRecord);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | [
"public",
"function",
"insertRecord",
"(",
"$",
"tableName",
",",
"$",
"newRecord",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"insertRecord",
"(",
"$",
"tableName",
",",
"$",
"newRecord",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DbException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Inserts a new record to the db
@param string $tableName
@param array $newRecord
@throws DbException | [
"Inserts",
"a",
"new",
"record",
"to",
"the",
"db"
] | train | https://github.com/angrycoders/db-driver/blob/e5df527ac0ea5fa434cbda79692f37cf6f2abc73/src/Db.php#L89-L96 |
angrycoders/db-driver | src/Db.php | Db.deleteRecord | public function deleteRecord($tableName, $value, $field)
{
try {
$this->db->deleteRecord($tableName, $value, $field);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | php | public function deleteRecord($tableName, $value, $field)
{
try {
$this->db->deleteRecord($tableName, $value, $field);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | [
"public",
"function",
"deleteRecord",
"(",
"$",
"tableName",
",",
"$",
"value",
",",
"$",
"field",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"deleteRecord",
"(",
"$",
"tableName",
",",
"$",
"value",
",",
"$",
"field",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DbException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Deletes the specified record from the table
@param string $tableName name of table
@param string $value the value to be matched
@param string $field the field to check value matched
@throws DbException | [
"Deletes",
"the",
"specified",
"record",
"from",
"the",
"table"
] | train | https://github.com/angrycoders/db-driver/blob/e5df527ac0ea5fa434cbda79692f37cf6f2abc73/src/Db.php#L105-L112 |
angrycoders/db-driver | src/Db.php | Db.getRecord | public function getRecord($tableName, $field, $value, $fields = array())
{
try {
return $this->db->getRecord($tableName, $field, $value, $fields);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | php | public function getRecord($tableName, $field, $value, $fields = array())
{
try {
return $this->db->getRecord($tableName, $field, $value, $fields);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | [
"public",
"function",
"getRecord",
"(",
"$",
"tableName",
",",
"$",
"field",
",",
"$",
"value",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"getRecord",
"(",
"$",
"tableName",
",",
"$",
"field",
",",
"$",
"value",
",",
"$",
"fields",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DbException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Return record(s) from specified table
@param string $tableName
@param string $field field to match
@param string $value value to match with field
@param array $fields columns to be returned
@return string executable SQL statement
@throws DbException | [
"Return",
"record",
"(",
"s",
")",
"from",
"specified",
"table"
] | train | https://github.com/angrycoders/db-driver/blob/e5df527ac0ea5fa434cbda79692f37cf6f2abc73/src/Db.php#L123-L130 |
angrycoders/db-driver | src/Db.php | Db.updateRecord | public function updateRecord($tableName, $fields, $values, $field, $value)
{
try {
return $this->db->updateRecord($tableName, $fields, $values, $field, $value);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | php | public function updateRecord($tableName, $fields, $values, $field, $value)
{
try {
return $this->db->updateRecord($tableName, $fields, $values, $field, $value);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | [
"public",
"function",
"updateRecord",
"(",
"$",
"tableName",
",",
"$",
"fields",
",",
"$",
"values",
",",
"$",
"field",
",",
"$",
"value",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"updateRecord",
"(",
"$",
"tableName",
",",
"$",
"fields",
",",
"$",
"values",
",",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DbException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | updates record(s) in db
@param string $tableName the name of table in db
@param array $fields the fields to be updated
@param array $values the values to update the fields
@param string $field the field to check
@param string $value the value of the field to check
@throws DbException | [
"updates",
"record",
"(",
"s",
")",
"in",
"db"
] | train | https://github.com/angrycoders/db-driver/blob/e5df527ac0ea5fa434cbda79692f37cf6f2abc73/src/Db.php#L141-L148 |
angrycoders/db-driver | src/Db.php | Db.getAllRecords | public function getAllRecords($tableName, $fields = array(), $limit = 0, $start = 0)
{
try {
return $this->db->getAllRecords($tableName, $fields, $limit, $start);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | php | public function getAllRecords($tableName, $fields = array(), $limit = 0, $start = 0)
{
try {
return $this->db->getAllRecords($tableName, $fields, $limit, $start);
} catch (\Exception $e) {
throw new DbException($e->getMessage());
}
} | [
"public",
"function",
"getAllRecords",
"(",
"$",
"tableName",
",",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"limit",
"=",
"0",
",",
"$",
"start",
"=",
"0",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"getAllRecords",
"(",
"$",
"tableName",
",",
"$",
"fields",
",",
"$",
"limit",
",",
"$",
"start",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DbException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Get all record from db
@param $tableName the name of table in db
@param array $fields the field to be returned. Returns all fields if not specified
@param int $limit the number of records to return. Returns all record if not returned
@param int $start the record index to start record. Starts from the first record if not specified
@throws DbException
@return mixed the records from db | [
"Get",
"all",
"record",
"from",
"db"
] | train | https://github.com/angrycoders/db-driver/blob/e5df527ac0ea5fa434cbda79692f37cf6f2abc73/src/Db.php#L159-L166 |
mossphp/moss-storage | Moss/Storage/Schema/Schema.php | Schema.retrieveModels | protected function retrieveModels(array $entity = [])
{
$models = [];
foreach ((array) $entity as $node) {
$models[] = $this->models->get($node);
}
if (empty($models)) {
$models = $this->models->all();
}
return $models;
} | php | protected function retrieveModels(array $entity = [])
{
$models = [];
foreach ((array) $entity as $node) {
$models[] = $this->models->get($node);
}
if (empty($models)) {
$models = $this->models->all();
}
return $models;
} | [
"protected",
"function",
"retrieveModels",
"(",
"array",
"$",
"entity",
"=",
"[",
"]",
")",
"{",
"$",
"models",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"entity",
"as",
"$",
"node",
")",
"{",
"$",
"models",
"[",
"]",
"=",
"$",
"this",
"->",
"models",
"->",
"get",
"(",
"$",
"node",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"models",
")",
")",
"{",
"$",
"models",
"=",
"$",
"this",
"->",
"models",
"->",
"all",
"(",
")",
";",
"}",
"return",
"$",
"models",
";",
"}"
] | Returns array with models for operation
@param array $entity
@return ModelInterface[] | [
"Returns",
"array",
"with",
"models",
"for",
"operation"
] | train | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Schema/Schema.php#L129-L141 |
mossphp/moss-storage | Moss/Storage/Schema/Schema.php | Schema.buildCreate | protected function buildCreate(array $models)
{
$schemaManager = $this->connection->getSchemaManager();
foreach ($models as $model) {
if ($schemaManager->tablesExist([$model->table()])) {
throw new SchemaException(sprintf('Unable to create table, table "%s" already exists', $model->table()));
}
$this->createTable($this->schema, $model);
}
$this->queries = array_merge(
$this->queries,
$this->schema->toSql($this->connection->getDatabasePlatform())
);
} | php | protected function buildCreate(array $models)
{
$schemaManager = $this->connection->getSchemaManager();
foreach ($models as $model) {
if ($schemaManager->tablesExist([$model->table()])) {
throw new SchemaException(sprintf('Unable to create table, table "%s" already exists', $model->table()));
}
$this->createTable($this->schema, $model);
}
$this->queries = array_merge(
$this->queries,
$this->schema->toSql($this->connection->getDatabasePlatform())
);
} | [
"protected",
"function",
"buildCreate",
"(",
"array",
"$",
"models",
")",
"{",
"$",
"schemaManager",
"=",
"$",
"this",
"->",
"connection",
"->",
"getSchemaManager",
"(",
")",
";",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"schemaManager",
"->",
"tablesExist",
"(",
"[",
"$",
"model",
"->",
"table",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"SchemaException",
"(",
"sprintf",
"(",
"'Unable to create table, table \"%s\" already exists'",
",",
"$",
"model",
"->",
"table",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"createTable",
"(",
"$",
"this",
"->",
"schema",
",",
"$",
"model",
")",
";",
"}",
"$",
"this",
"->",
"queries",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"queries",
",",
"$",
"this",
"->",
"schema",
"->",
"toSql",
"(",
"$",
"this",
"->",
"connection",
"->",
"getDatabasePlatform",
"(",
")",
")",
")",
";",
"}"
] | Builds create table queries
@param ModelInterface[] $models
@throws SchemaException | [
"Builds",
"create",
"table",
"queries"
] | train | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Schema/Schema.php#L150-L166 |
mossphp/moss-storage | Moss/Storage/Schema/Schema.php | Schema.createTable | protected function createTable(SchemaAsset $schema, ModelInterface $model)
{
$table = $schema->createTable($this->quoteIdentifier($model->table()));
foreach ($model->fields() as $field) {
$table->addColumn(
$this->quoteIdentifier($field->mappedName()),
$field->type(),
$field->attributes()
);
}
foreach ($model->indexes() as $index) {
switch ($index->type()) {
case 'primary':
$table->setPrimaryKey(
$this->quoteIdentifier($index->fields()),
$this->quoteIdentifier($index->name())
);
break;
case 'unique':
$table->addUniqueIndex(
$this->quoteIdentifier($index->fields()),
$this->quoteIdentifier($index->name())
);
break;
case 'foreign':
$table->addForeignKeyConstraint(
$index->table(),
$this->quoteIdentifier(array_keys($index->fields())),
$this->quoteIdentifier(array_values($index->fields())),
['onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT'],
$this->quoteIdentifier($index->name())
);
break;
case 'index':
default:
$table->addIndex(
$this->quoteIdentifier($index->fields()),
$this->quoteIdentifier($index->name())
);
}
}
} | php | protected function createTable(SchemaAsset $schema, ModelInterface $model)
{
$table = $schema->createTable($this->quoteIdentifier($model->table()));
foreach ($model->fields() as $field) {
$table->addColumn(
$this->quoteIdentifier($field->mappedName()),
$field->type(),
$field->attributes()
);
}
foreach ($model->indexes() as $index) {
switch ($index->type()) {
case 'primary':
$table->setPrimaryKey(
$this->quoteIdentifier($index->fields()),
$this->quoteIdentifier($index->name())
);
break;
case 'unique':
$table->addUniqueIndex(
$this->quoteIdentifier($index->fields()),
$this->quoteIdentifier($index->name())
);
break;
case 'foreign':
$table->addForeignKeyConstraint(
$index->table(),
$this->quoteIdentifier(array_keys($index->fields())),
$this->quoteIdentifier(array_values($index->fields())),
['onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT'],
$this->quoteIdentifier($index->name())
);
break;
case 'index':
default:
$table->addIndex(
$this->quoteIdentifier($index->fields()),
$this->quoteIdentifier($index->name())
);
}
}
} | [
"protected",
"function",
"createTable",
"(",
"SchemaAsset",
"$",
"schema",
",",
"ModelInterface",
"$",
"model",
")",
"{",
"$",
"table",
"=",
"$",
"schema",
"->",
"createTable",
"(",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"model",
"->",
"table",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"model",
"->",
"fields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"table",
"->",
"addColumn",
"(",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"field",
"->",
"mappedName",
"(",
")",
")",
",",
"$",
"field",
"->",
"type",
"(",
")",
",",
"$",
"field",
"->",
"attributes",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"model",
"->",
"indexes",
"(",
")",
"as",
"$",
"index",
")",
"{",
"switch",
"(",
"$",
"index",
"->",
"type",
"(",
")",
")",
"{",
"case",
"'primary'",
":",
"$",
"table",
"->",
"setPrimaryKey",
"(",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"fields",
"(",
")",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"name",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"'unique'",
":",
"$",
"table",
"->",
"addUniqueIndex",
"(",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"fields",
"(",
")",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"name",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"'foreign'",
":",
"$",
"table",
"->",
"addForeignKeyConstraint",
"(",
"$",
"index",
"->",
"table",
"(",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"array_keys",
"(",
"$",
"index",
"->",
"fields",
"(",
")",
")",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"array_values",
"(",
"$",
"index",
"->",
"fields",
"(",
")",
")",
")",
",",
"[",
"'onUpdate'",
"=>",
"'CASCADE'",
",",
"'onDelete'",
"=>",
"'RESTRICT'",
"]",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"name",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"'index'",
":",
"default",
":",
"$",
"table",
"->",
"addIndex",
"(",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"fields",
"(",
")",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"name",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | Creates table from model into schema
@param SchemaAsset $schema
@param ModelInterface $model | [
"Creates",
"table",
"from",
"model",
"into",
"schema"
] | train | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Schema/Schema.php#L197-L240 |
Subsets and Splits