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 listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
wp-cli/scaffold-command | src/Scaffold_Command.php | Scaffold_Command.child_theme | public function child_theme( $args, $assoc_args ) {
$theme_slug = $args[0];
if ( in_array( $theme_slug, array( '.', '..' ), true ) ) {
WP_CLI::error( "Invalid theme slug specified. The slug cannot be '.' or '..'." );
}
$defaults = array(
'theme_name' => ucfirst( $theme_slug ),
'author' => 'Me',
... | php | public function child_theme( $args, $assoc_args ) {
$theme_slug = $args[0];
if ( in_array( $theme_slug, array( '.', '..' ), true ) ) {
WP_CLI::error( "Invalid theme slug specified. The slug cannot be '.' or '..'." );
}
$defaults = array(
'theme_name' => ucfirst( $theme_slug ),
'author' => 'Me',
... | [
"public",
"function",
"child_theme",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"theme_slug",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"theme_slug",
",",
"array",
"(",
"'.'",
",",
"'..'",
")",
",",
"true"... | Generates child theme based on an existing theme.
Creates a child theme folder with `functions.php` and `style.css` files.
## OPTIONS
<slug>
: The slug for the new child theme.
--parent_theme=<slug>
: What to put in the 'Template:' header in 'style.css'.
[--theme_name=<title>]
: What to put in the 'Theme Name:' he... | [
"Generates",
"child",
"theme",
"based",
"on",
"an",
"existing",
"theme",
"."
] | train | https://github.com/wp-cli/scaffold-command/blob/9c6450e9ccf2d032913fced69f3188bc8ec4e3e6/src/Scaffold_Command.php#L511-L558 |
wp-cli/scaffold-command | src/Scaffold_Command.php | Scaffold_Command.plugin | public function plugin( $args, $assoc_args ) {
$plugin_slug = $args[0];
$plugin_name = ucwords( str_replace( '-', ' ', $plugin_slug ) );
$plugin_package = str_replace( ' ', '_', $plugin_name );
if ( in_array( $plugin_slug, array( '.', '..' ), true ) ) {
WP_CLI::error( "Invalid plugin slug specified. T... | php | public function plugin( $args, $assoc_args ) {
$plugin_slug = $args[0];
$plugin_name = ucwords( str_replace( '-', ' ', $plugin_slug ) );
$plugin_package = str_replace( ' ', '_', $plugin_name );
if ( in_array( $plugin_slug, array( '.', '..' ), true ) ) {
WP_CLI::error( "Invalid plugin slug specified. T... | [
"public",
"function",
"plugin",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"plugin_slug",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"plugin_name",
"=",
"ucwords",
"(",
"str_replace",
"(",
"'-'",
",",
"' '",
",",
"$",
"plugin_slug",
")"... | Generates starter code for a plugin.
The following files are always generated:
* `plugin-slug.php` is the main PHP plugin file.
* `readme.txt` is the readme file for the plugin.
* `package.json` needed by NPM holds various metadata relevant to the project. Packages: `grunt`, `grunt-wp-i18n` and `grunt-wp-readme-to-ma... | [
"Generates",
"starter",
"code",
"for",
"a",
"plugin",
"."
] | train | https://github.com/wp-cli/scaffold-command/blob/9c6450e9ccf2d032913fced69f3188bc8ec4e3e6/src/Scaffold_Command.php#L659-L730 |
wp-cli/scaffold-command | src/Scaffold_Command.php | Scaffold_Command.check_target_directory | private function check_target_directory( $type, $target_dir ) {
$parent_dir = dirname( self::canonicalize_path( str_replace( '\\', '/', $target_dir ) ) );
if ( 'theme' === $type && str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) !== $parent_dir ) {
return sprintf( 'The target directory \'%1$s\' is not in \... | php | private function check_target_directory( $type, $target_dir ) {
$parent_dir = dirname( self::canonicalize_path( str_replace( '\\', '/', $target_dir ) ) );
if ( 'theme' === $type && str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) !== $parent_dir ) {
return sprintf( 'The target directory \'%1$s\' is not in \... | [
"private",
"function",
"check_target_directory",
"(",
"$",
"type",
",",
"$",
"target_dir",
")",
"{",
"$",
"parent_dir",
"=",
"dirname",
"(",
"self",
"::",
"canonicalize_path",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"target_dir",
")",
")",
... | Checks that the `$target_dir` is a child directory of the WP themes or plugins directory, depending on `$type`.
@param string $type "theme" or "plugin"
@param string $target_dir The theme/plugin directory to check.
@return null|string Returns null on success, error message on error. | [
"Checks",
"that",
"the",
"$target_dir",
"is",
"a",
"child",
"directory",
"of",
"the",
"WP",
"themes",
"or",
"plugins",
"directory",
"depending",
"on",
"$type",
"."
] | train | https://github.com/wp-cli/scaffold-command/blob/9c6450e9ccf2d032913fced69f3188bc8ec4e3e6/src/Scaffold_Command.php#L960-L973 |
wp-cli/scaffold-command | src/Scaffold_Command.php | Scaffold_Command.extract_dashicon | private function extract_dashicon( $assoc_args ) {
$dashicon = \WP_CLI\Utils\get_flag_value( $assoc_args, 'dashicon' );
if ( ! $dashicon ) {
return null;
}
return preg_replace( '/dashicon(-|s-)/', '', $dashicon );
} | php | private function extract_dashicon( $assoc_args ) {
$dashicon = \WP_CLI\Utils\get_flag_value( $assoc_args, 'dashicon' );
if ( ! $dashicon ) {
return null;
}
return preg_replace( '/dashicon(-|s-)/', '', $dashicon );
} | [
"private",
"function",
"extract_dashicon",
"(",
"$",
"assoc_args",
")",
"{",
"$",
"dashicon",
"=",
"\\",
"WP_CLI",
"\\",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'dashicon'",
")",
";",
"if",
"(",
"!",
"$",
"dashicon",
")",
"{",
"ret... | Extracts dashicon name when provided or return null otherwise.
@param array $assoc_args
@return string|null | [
"Extracts",
"dashicon",
"name",
"when",
"provided",
"or",
"return",
"null",
"otherwise",
"."
] | train | https://github.com/wp-cli/scaffold-command/blob/9c6450e9ccf2d032913fced69f3188bc8ec4e3e6/src/Scaffold_Command.php#L1035-L1041 |
wp-cli/scaffold-command | src/Scaffold_Command.php | Scaffold_Command.get_textdomain | private function get_textdomain( $textdomain, $args ) {
if ( strlen( $textdomain ) ) {
return $textdomain;
}
if ( $args['theme'] ) {
return $this->get_theme_name( $args['theme'] );
}
if ( $args['plugin'] && true !== $args['plugin'] ) {
return $args['plugin'];
}
return 'YOUR-TEXTDOMAIN';
} | php | private function get_textdomain( $textdomain, $args ) {
if ( strlen( $textdomain ) ) {
return $textdomain;
}
if ( $args['theme'] ) {
return $this->get_theme_name( $args['theme'] );
}
if ( $args['plugin'] && true !== $args['plugin'] ) {
return $args['plugin'];
}
return 'YOUR-TEXTDOMAIN';
} | [
"private",
"function",
"get_textdomain",
"(",
"$",
"textdomain",
",",
"$",
"args",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"textdomain",
")",
")",
"{",
"return",
"$",
"textdomain",
";",
"}",
"if",
"(",
"$",
"args",
"[",
"'theme'",
"]",
")",
"{",
"... | If you're writing your files to your theme directory your textdomain also needs to be the same as your theme.
Same goes for when plugin is being used. | [
"If",
"you",
"re",
"writing",
"your",
"files",
"to",
"your",
"theme",
"directory",
"your",
"textdomain",
"also",
"needs",
"to",
"be",
"the",
"same",
"as",
"your",
"theme",
".",
"Same",
"goes",
"for",
"when",
"plugin",
"is",
"being",
"used",
"."
] | train | https://github.com/wp-cli/scaffold-command/blob/9c6450e9ccf2d032913fced69f3188bc8ec4e3e6/src/Scaffold_Command.php#L1047-L1061 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.protocolVersion | public function protocolVersion($protocol_version = null)
{
if (null !== $protocol_version) {
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->protocol_version = (string) $protocol_version;
return $this;
}
... | php | public function protocolVersion($protocol_version = null)
{
if (null !== $protocol_version) {
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->protocol_version = (string) $protocol_version;
return $this;
}
... | [
"public",
"function",
"protocolVersion",
"(",
"$",
"protocol_version",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"protocol_version",
")",
"{",
"// Require that the response be unlocked before changing it",
"$",
"this",
"->",
"requireUnlocked",
"(",
")",
... | Get (or set) the HTTP protocol version
Simply calling this method without any arguments returns the current protocol version.
Calling with an integer argument, however, attempts to set the protocol version to what
was provided by the argument.
@param string $protocol_version
@return string|AbstractResponse | [
"Get",
"(",
"or",
"set",
")",
"the",
"HTTP",
"protocol",
"version"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L130-L142 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.body | public function body($body = null)
{
if (null !== $body) {
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->body = (string) $body;
return $this;
}
return $this->body;
} | php | public function body($body = null)
{
if (null !== $body) {
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->body = (string) $body;
return $this;
}
return $this->body;
} | [
"public",
"function",
"body",
"(",
"$",
"body",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"body",
")",
"{",
"// Require that the response be unlocked before changing it",
"$",
"this",
"->",
"requireUnlocked",
"(",
")",
";",
"$",
"this",
"->",
"bo... | Get (or set) the response's body content
Simply calling this method without any arguments returns the current response body.
Calling with an argument, however, sets the response body to what was provided by the argument.
@param string $body The body content string
@return string|AbstractResponse | [
"Get",
"(",
"or",
"set",
")",
"the",
"response",
"s",
"body",
"content"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L153-L165 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.code | public function code($code = null)
{
if (null !== $code) {
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->status = new HttpStatus($code);
return $this;
}
return $this->status->getCode();
} | php | public function code($code = null)
{
if (null !== $code) {
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->status = new HttpStatus($code);
return $this;
}
return $this->status->getCode();
} | [
"public",
"function",
"code",
"(",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"code",
")",
"{",
"// Require that the response be unlocked before changing it",
"$",
"this",
"->",
"requireUnlocked",
"(",
")",
";",
"$",
"this",
"->",
"st... | Get (or set) the HTTP response code
Simply calling this method without any arguments returns the current response code.
Calling with an integer argument, however, attempts to set the response code to what
was provided by the argument.
@param int $code The HTTP status code to send
@return int|AbstractResponse | [
"Get",
"(",
"or",
"set",
")",
"the",
"HTTP",
"response",
"code"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L207-L219 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.prepend | public function prepend($content)
{
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->body = $content . $this->body;
return $this;
} | php | public function prepend($content)
{
// Require that the response be unlocked before changing it
$this->requireUnlocked();
$this->body = $content . $this->body;
return $this;
} | [
"public",
"function",
"prepend",
"(",
"$",
"content",
")",
"{",
"// Require that the response be unlocked before changing it",
"$",
"this",
"->",
"requireUnlocked",
"(",
")",
";",
"$",
"this",
"->",
"body",
"=",
"$",
"content",
".",
"$",
"this",
"->",
"body",
... | Prepend a string to the response's content body
@param string $content The string to prepend
@return AbstractResponse | [
"Prepend",
"a",
"string",
"to",
"the",
"response",
"s",
"content",
"body"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L227-L235 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.sendHeaders | public function sendHeaders($cookies_also = true, $override = false)
{
if (headers_sent() && !$override) {
return $this;
}
// Send our HTTP status line
header($this->httpStatusLine());
// Iterate through our Headers data collection and send each header
f... | php | public function sendHeaders($cookies_also = true, $override = false)
{
if (headers_sent() && !$override) {
return $this;
}
// Send our HTTP status line
header($this->httpStatusLine());
// Iterate through our Headers data collection and send each header
f... | [
"public",
"function",
"sendHeaders",
"(",
"$",
"cookies_also",
"=",
"true",
",",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
"&&",
"!",
"$",
"override",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// Send our HTTP status... | Send our HTTP headers
@param boolean $cookies_also Whether or not to also send the cookies after sending the normal headers
@param boolean $override Whether or not to override the check if headers have already been sent
@return AbstractResponse | [
"Send",
"our",
"HTTP",
"headers"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L325-L344 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.sendCookies | public function sendCookies($override = false)
{
if (headers_sent() && !$override) {
return $this;
}
// Iterate through our Cookies data collection and set each cookie natively
foreach ($this->cookies as $cookie) {
// Use the built-in PHP "setcookie" function... | php | public function sendCookies($override = false)
{
if (headers_sent() && !$override) {
return $this;
}
// Iterate through our Cookies data collection and set each cookie natively
foreach ($this->cookies as $cookie) {
// Use the built-in PHP "setcookie" function... | [
"public",
"function",
"sendCookies",
"(",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
"&&",
"!",
"$",
"override",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// Iterate through our Cookies data collection and set each cookie nativ... | Send our HTTP response cookies
@param boolean $override Whether or not to override the check if headers have already been sent
@return AbstractResponse | [
"Send",
"our",
"HTTP",
"response",
"cookies"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L352-L373 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.send | public function send($override = false)
{
if ($this->sent && !$override) {
throw new ResponseAlreadySentException('Response has already been sent');
}
// Send our response data
$this->sendHeaders();
$this->sendBody();
// Lock the response from further mo... | php | public function send($override = false)
{
if ($this->sent && !$override) {
throw new ResponseAlreadySentException('Response has already been sent');
}
// Send our response data
$this->sendHeaders();
$this->sendBody();
// Lock the response from further mo... | [
"public",
"function",
"send",
"(",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sent",
"&&",
"!",
"$",
"override",
")",
"{",
"throw",
"new",
"ResponseAlreadySentException",
"(",
"'Response has already been sent'",
")",
";",
"}",
... | Send the response and lock it
@param boolean $override Whether or not to override the check if the response has already been sent
@throws ResponseAlreadySentException If the response has already been sent
@return AbstractResponse | [
"Send",
"the",
"response",
"and",
"lock",
"it"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L394-L416 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.chunk | public function chunk()
{
if (false === $this->chunked) {
$this->chunked = true;
$this->header('Transfer-encoding', 'chunked');
flush();
}
if (($body_length = strlen($this->body)) > 0) {
printf("%x\r\n", $body_length);
$this->sendB... | php | public function chunk()
{
if (false === $this->chunked) {
$this->chunked = true;
$this->header('Transfer-encoding', 'chunked');
flush();
}
if (($body_length = strlen($this->body)) > 0) {
printf("%x\r\n", $body_length);
$this->sendB... | [
"public",
"function",
"chunk",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"chunked",
")",
"{",
"$",
"this",
"->",
"chunked",
"=",
"true",
";",
"$",
"this",
"->",
"header",
"(",
"'Transfer-encoding'",
",",
"'chunked'",
")",
";",
"flu... | Enable response chunking
@link https://github.com/klein/klein.php/wiki/Response-Chunking
@link http://bit.ly/hg3gHb
@return AbstractResponse | [
"Enable",
"response",
"chunking"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L435-L452 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.cookie | public function cookie(
$key,
$value = '',
$expiry = null,
$path = '/',
$domain = null,
$secure = false,
$httponly = false
) {
if (null === $expiry) {
$expiry = time() + (3600 * 24 * 30);
}
$this->cookies->set(
... | php | public function cookie(
$key,
$value = '',
$expiry = null,
$path = '/',
$domain = null,
$secure = false,
$httponly = false
) {
if (null === $expiry) {
$expiry = time() + (3600 * 24 * 30);
}
$this->cookies->set(
... | [
"public",
"function",
"cookie",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"''",
",",
"$",
"expiry",
"=",
"null",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"secure",
"=",
"false",
",",
"$",
"httponly",
"=",
"false",
... | Sets a response cookie
@param string $key The name of the cookie
@param string $value The value to set the cookie with
@param int $expiry The time that the cookie should expire
@param string $path The path of which to restrict the cookie
@param string $domain The domain of w... | [
"Sets",
"a",
"response",
"cookie"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L480-L499 |
klein/klein.php | src/Klein/AbstractResponse.php | AbstractResponse.redirect | public function redirect($url, $code = 302)
{
$this->code($code);
$this->header('Location', $url);
$this->lock();
return $this;
} | php | public function redirect($url, $code = 302)
{
$this->code($code);
$this->header('Location', $url);
$this->lock();
return $this;
} | [
"public",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"code",
"=",
"302",
")",
"{",
"$",
"this",
"->",
"code",
"(",
"$",
"code",
")",
";",
"$",
"this",
"->",
"header",
"(",
"'Location'",
",",
"$",
"url",
")",
";",
"$",
"this",
"->",
"loc... | Redirects the request to another URL
@param string $url The URL to redirect to
@param int $code The HTTP status code to use for redirection
@return AbstractResponse | [
"Redirects",
"the",
"request",
"to",
"another",
"URL"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/AbstractResponse.php#L521-L528 |
klein/klein.php | src/Klein/DataCollection/ServerDataCollection.php | ServerDataCollection.getHeaders | public function getHeaders()
{
// Define a headers array
$headers = array();
foreach ($this->attributes as $key => $value) {
// Does our server attribute have our header prefix?
if (self::hasPrefix($key, self::$http_header_prefix)) {
// Add our server... | php | public function getHeaders()
{
// Define a headers array
$headers = array();
foreach ($this->attributes as $key => $value) {
// Does our server attribute have our header prefix?
if (self::hasPrefix($key, self::$http_header_prefix)) {
// Add our server... | [
"public",
"function",
"getHeaders",
"(",
")",
"{",
"// Define a headers array",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Does our server attribute have our... | Get our headers from our server data collection
PHP is weird... it puts all of the HTTP request
headers in the $_SERVER array. This handles that
@return array | [
"Get",
"our",
"headers",
"from",
"our",
"server",
"data",
"collection"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/ServerDataCollection.php#L80-L100 |
klein/klein.php | src/Klein/DataCollection/ResponseCookieDataCollection.php | ResponseCookieDataCollection.set | public function set($key, $value)
{
if (!$value instanceof ResponseCookie) {
$value = new ResponseCookie($key, $value);
}
return parent::set($key, $value);
} | php | public function set($key, $value)
{
if (!$value instanceof ResponseCookie) {
$value = new ResponseCookie($key, $value);
}
return parent::set($key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"ResponseCookie",
")",
"{",
"$",
"value",
"=",
"new",
"ResponseCookie",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"retur... | Set a cookie
{@inheritdoc}
A value may either be a string or a ResponseCookie instance
String values will be converted into a ResponseCookie with
the "name" of the cookie being set from the "key"
Obviously, the developer is free to organize this collection
however they like, and can be more explicit by passing a mor... | [
"Set",
"a",
"cookie"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/ResponseCookieDataCollection.php#L60-L67 |
klein/klein.php | src/Klein/HttpStatus.php | HttpStatus.getFormattedString | public function getFormattedString()
{
$string = (string) $this->code;
if (null !== $this->message) {
$string = $string . ' ' . $this->message;
}
return $string;
} | php | public function getFormattedString()
{
$string = (string) $this->code;
if (null !== $this->message) {
$string = $string . ' ' . $this->message;
}
return $string;
} | [
"public",
"function",
"getFormattedString",
"(",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"code",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"message",
")",
"{",
"$",
"string",
"=",
"$",
"string",
".",
"' '",
".",... | Get a string representation of our HTTP status
@return string | [
"Get",
"a",
"string",
"representation",
"of",
"our",
"HTTP",
"status"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/HttpStatus.php#L162-L171 |
klein/klein.php | src/Klein/Klein.php | Klein.parseLooseArgumentOrder | protected function parseLooseArgumentOrder(array $args)
{
// Get the arguments in a very loose format
$callback = array_pop($args);
$path = array_pop($args);
$method = array_pop($args);
// Return a named parameter array
return array(
'method' => $method,
... | php | protected function parseLooseArgumentOrder(array $args)
{
// Get the arguments in a very loose format
$callback = array_pop($args);
$path = array_pop($args);
$method = array_pop($args);
// Return a named parameter array
return array(
'method' => $method,
... | [
"protected",
"function",
"parseLooseArgumentOrder",
"(",
"array",
"$",
"args",
")",
"{",
"// Get the arguments in a very loose format",
"$",
"callback",
"=",
"array_pop",
"(",
"$",
"args",
")",
";",
"$",
"path",
"=",
"array_pop",
"(",
"$",
"args",
")",
";",
"$... | Parse our extremely loose argument order of our "respond" method and its aliases
This method takes its arguments in a loose format and order.
The method signature is simply there for documentation purposes, but allows
for the minimum of a callback to be passed in its current configuration.
@see Klein::respond()
@para... | [
"Parse",
"our",
"extremely",
"loose",
"argument",
"order",
"of",
"our",
"respond",
"method",
"and",
"its",
"aliases"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L299-L312 |
klein/klein.php | src/Klein/Klein.php | Klein.respond | public function respond($method, $path = '*', $callback = null)
{
// Get the arguments in a very loose format
extract(
$this->parseLooseArgumentOrder(func_get_args()),
EXTR_OVERWRITE
);
$route = $this->route_factory->build($callback, $path, $method);
... | php | public function respond($method, $path = '*', $callback = null)
{
// Get the arguments in a very loose format
extract(
$this->parseLooseArgumentOrder(func_get_args()),
EXTR_OVERWRITE
);
$route = $this->route_factory->build($callback, $path, $method);
... | [
"public",
"function",
"respond",
"(",
"$",
"method",
",",
"$",
"path",
"=",
"'*'",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"// Get the arguments in a very loose format",
"extract",
"(",
"$",
"this",
"->",
"parseLooseArgumentOrder",
"(",
"func_get_args",
"("... | Add a new route to be matched on dispatch
Essentially, this method is a standard "Route" builder/factory,
allowing a loose argument format and a standard way of creating
Route instances
This method takes its arguments in a very loose format
The only "required" parameter is the callback (which is very strange consider... | [
"Add",
"a",
"new",
"route",
"to",
"be",
"matched",
"on",
"dispatch"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L343-L356 |
klein/klein.php | src/Klein/Klein.php | Klein.with | public function with($namespace, $routes)
{
$previous = $this->route_factory->getNamespace();
$this->route_factory->appendNamespace($namespace);
if (is_callable($routes)) {
if (is_string($routes)) {
$routes($this);
} else {
call_user_... | php | public function with($namespace, $routes)
{
$previous = $this->route_factory->getNamespace();
$this->route_factory->appendNamespace($namespace);
if (is_callable($routes)) {
if (is_string($routes)) {
$routes($this);
} else {
call_user_... | [
"public",
"function",
"with",
"(",
"$",
"namespace",
",",
"$",
"routes",
")",
"{",
"$",
"previous",
"=",
"$",
"this",
"->",
"route_factory",
"->",
"getNamespace",
"(",
")",
";",
"$",
"this",
"->",
"route_factory",
"->",
"appendNamespace",
"(",
"$",
"name... | Collect a set of routes under a common namespace
The routes may be passed in as either a callable (which holds the route definitions),
or as a string of a filename, of which to "include" under the Klein router scope
<code>
$router = new Klein();
$router->with('/users', function($router) {
$router->respond( '/', func... | [
"Collect",
"a",
"set",
"of",
"routes",
"under",
"a",
"common",
"namespace"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L383-L400 |
klein/klein.php | src/Klein/Klein.php | Klein.dispatch | public function dispatch(
Request $request = null,
AbstractResponse $response = null,
$send_response = true,
$capture = self::DISPATCH_NO_CAPTURE
) {
// Set/Initialize our objects to be sent in each callback
$this->request = $request ?: Request::createFromGlobals();
... | php | public function dispatch(
Request $request = null,
AbstractResponse $response = null,
$send_response = true,
$capture = self::DISPATCH_NO_CAPTURE
) {
// Set/Initialize our objects to be sent in each callback
$this->request = $request ?: Request::createFromGlobals();
... | [
"public",
"function",
"dispatch",
"(",
"Request",
"$",
"request",
"=",
"null",
",",
"AbstractResponse",
"$",
"response",
"=",
"null",
",",
"$",
"send_response",
"=",
"true",
",",
"$",
"capture",
"=",
"self",
"::",
"DISPATCH_NO_CAPTURE",
")",
"{",
"// Set/Ini... | Dispatch the request to the appropriate route(s)
Dispatch with optionally injected dependencies
This DI allows for easy testing, object mocking, or class extension
@param Request $request The request object to give to each callback
@param AbstractResponse $response The response object to give to each ... | [
"Dispatch",
"the",
"request",
"to",
"the",
"appropriate",
"route",
"(",
"s",
")"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L414-L708 |
klein/klein.php | src/Klein/Klein.php | Klein.compileRoute | protected function compileRoute($route)
{
// First escape all of the non-named param (non [block]s) for regex-chars
$route = preg_replace_callback(
static::ROUTE_ESCAPE_REGEX,
function ($match) {
return preg_quote($match[0]);
},
$route
... | php | protected function compileRoute($route)
{
// First escape all of the non-named param (non [block]s) for regex-chars
$route = preg_replace_callback(
static::ROUTE_ESCAPE_REGEX,
function ($match) {
return preg_quote($match[0]);
},
$route
... | [
"protected",
"function",
"compileRoute",
"(",
"$",
"route",
")",
"{",
"// First escape all of the non-named param (non [block]s) for regex-chars",
"$",
"route",
"=",
"preg_replace_callback",
"(",
"static",
"::",
"ROUTE_ESCAPE_REGEX",
",",
"function",
"(",
"$",
"match",
")... | Compiles a route string to a regular expression
@param string $route The route string to compile
@return string | [
"Compiles",
"a",
"route",
"string",
"to",
"a",
"regular",
"expression"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L716-L760 |
klein/klein.php | src/Klein/Klein.php | Klein.validateRegularExpression | private function validateRegularExpression($regex)
{
$error_string = null;
// Set an error handler temporarily
set_error_handler(
function ($errno, $errstr) use (&$error_string) {
$error_string = $errstr;
},
E_NOTICE | E_WARNING
);... | php | private function validateRegularExpression($regex)
{
$error_string = null;
// Set an error handler temporarily
set_error_handler(
function ($errno, $errstr) use (&$error_string) {
$error_string = $errstr;
},
E_NOTICE | E_WARNING
);... | [
"private",
"function",
"validateRegularExpression",
"(",
"$",
"regex",
")",
"{",
"$",
"error_string",
"=",
"null",
";",
"// Set an error handler temporarily",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
")",
"use",
"(",
"&",
"$",... | Validate a regular expression
This simply checks if the regular expression is able to be compiled
and converts any warnings or notices in the compilation to an exception
@param string $regex The regular expression to validate
@throws RegularExpressionCompilationException If the expression can... | [
"Validate",
"a",
"regular",
"expression"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L772-L798 |
klein/klein.php | src/Klein/Klein.php | Klein.getPathFor | public function getPathFor($route_name, array $params = null, $flatten_regex = true)
{
// First, grab the route
$route = $this->routes->get($route_name);
// Make sure we are getting a valid route
if (null === $route) {
throw new OutOfBoundsException('No such route with n... | php | public function getPathFor($route_name, array $params = null, $flatten_regex = true)
{
// First, grab the route
$route = $this->routes->get($route_name);
// Make sure we are getting a valid route
if (null === $route) {
throw new OutOfBoundsException('No such route with n... | [
"public",
"function",
"getPathFor",
"(",
"$",
"route_name",
",",
"array",
"$",
"params",
"=",
"null",
",",
"$",
"flatten_regex",
"=",
"true",
")",
"{",
"// First, grab the route",
"$",
"route",
"=",
"$",
"this",
"->",
"routes",
"->",
"get",
"(",
"$",
"ro... | Get the path for a given route
This looks up the route by its passed name and returns
the path/url for that route, with its URL params as
placeholders unless you pass a valid key-value pair array
of the placeholder params and their values
If a pathname is a complex/custom regular expression, this
method will simply r... | [
"Get",
"the",
"path",
"for",
"a",
"given",
"route"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L824-L862 |
klein/klein.php | src/Klein/Klein.php | Klein.handleRouteCallback | protected function handleRouteCallback(Route $route, RouteCollection $matched, array $methods_matched)
{
// Handle the callback
$returned = call_user_func(
$route->getCallback(), // Instead of relying on the slower "invoke" magic
$this->request,
$this->response,
... | php | protected function handleRouteCallback(Route $route, RouteCollection $matched, array $methods_matched)
{
// Handle the callback
$returned = call_user_func(
$route->getCallback(), // Instead of relying on the slower "invoke" magic
$this->request,
$this->response,
... | [
"protected",
"function",
"handleRouteCallback",
"(",
"Route",
"$",
"route",
",",
"RouteCollection",
"$",
"matched",
",",
"array",
"$",
"methods_matched",
")",
"{",
"// Handle the callback",
"$",
"returned",
"=",
"call_user_func",
"(",
"$",
"route",
"->",
"getCallb... | Handle a route's callback
This handles common exceptions and their output
to keep the "dispatch()" method DRY
@param Route $route
@param RouteCollection $matched
@param array $methods_matched
@return void | [
"Handle",
"a",
"route",
"s",
"callback"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L875-L899 |
klein/klein.php | src/Klein/Klein.php | Klein.error | protected function error($err)
{
$type = get_class($err);
$msg = $err->getMessage();
try {
if (!$this->error_callbacks->isEmpty()) {
foreach ($this->error_callbacks as $callback) {
if (is_callable($callback)) {
if (is_s... | php | protected function error($err)
{
$type = get_class($err);
$msg = $err->getMessage();
try {
if (!$this->error_callbacks->isEmpty()) {
foreach ($this->error_callbacks as $callback) {
if (is_callable($callback)) {
if (is_s... | [
"protected",
"function",
"error",
"(",
"$",
"err",
")",
"{",
"$",
"type",
"=",
"get_class",
"(",
"$",
"err",
")",
";",
"$",
"msg",
"=",
"$",
"err",
"->",
"getMessage",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"error_callbacks... | Routes an exception through the error callbacks
TODO: Change the `$err` parameter to type-hint against `Throwable` once
PHP 5.x support is no longer necessary.
@param Exception|Throwable $err The exception that occurred
@throws UnhandledException If the error/exception isn't handled by an error callback
@return ... | [
"Routes",
"an",
"exception",
"through",
"the",
"error",
"callbacks"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L922-L975 |
klein/klein.php | src/Klein/Klein.php | Klein.httpError | protected function httpError(HttpExceptionInterface $http_exception, RouteCollection $matched, $methods_matched)
{
if (!$this->response->isLocked()) {
$this->response->code($http_exception->getCode());
}
if (!$this->http_error_callbacks->isEmpty()) {
foreach ($this->... | php | protected function httpError(HttpExceptionInterface $http_exception, RouteCollection $matched, $methods_matched)
{
if (!$this->response->isLocked()) {
$this->response->code($http_exception->getCode());
}
if (!$this->http_error_callbacks->isEmpty()) {
foreach ($this->... | [
"protected",
"function",
"httpError",
"(",
"HttpExceptionInterface",
"$",
"http_exception",
",",
"RouteCollection",
"$",
"matched",
",",
"$",
"methods_matched",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"response",
"->",
"isLocked",
"(",
")",
")",
"{",
"$... | Handles an HTTP error exception through our HTTP error callbacks
@param HttpExceptionInterface $http_exception The exception that occurred
@param RouteCollection $matched The collection of routes that were matched in dispatch
@param array $methods_matched The HTTP methods that we... | [
"Handles",
"an",
"HTTP",
"error",
"exception",
"through",
"our",
"HTTP",
"error",
"callbacks"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L996-L1032 |
klein/klein.php | src/Klein/Klein.php | Klein.callAfterDispatchCallbacks | protected function callAfterDispatchCallbacks()
{
try {
foreach ($this->after_filter_callbacks as $callback) {
if (is_callable($callback)) {
if (is_string($callback)) {
$callback($this);
} else {
... | php | protected function callAfterDispatchCallbacks()
{
try {
foreach ($this->after_filter_callbacks as $callback) {
if (is_callable($callback)) {
if (is_string($callback)) {
$callback($this);
} else {
... | [
"protected",
"function",
"callAfterDispatchCallbacks",
"(",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"after_filter_callbacks",
"as",
"$",
"callback",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"if",
"(",
"is_st... | Runs through and executes the after dispatch callbacks
@return void | [
"Runs",
"through",
"and",
"executes",
"the",
"after",
"dispatch",
"callbacks"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L1052-L1071 |
klein/klein.php | src/Klein/Klein.php | Klein.skipNext | public function skipNext($num = 1)
{
$skip = new DispatchHaltedException(null, DispatchHaltedException::SKIP_NEXT);
$skip->setNumberOfSkips($num);
throw $skip;
} | php | public function skipNext($num = 1)
{
$skip = new DispatchHaltedException(null, DispatchHaltedException::SKIP_NEXT);
$skip->setNumberOfSkips($num);
throw $skip;
} | [
"public",
"function",
"skipNext",
"(",
"$",
"num",
"=",
"1",
")",
"{",
"$",
"skip",
"=",
"new",
"DispatchHaltedException",
"(",
"null",
",",
"DispatchHaltedException",
"::",
"SKIP_NEXT",
")",
";",
"$",
"skip",
"->",
"setNumberOfSkips",
"(",
"$",
"num",
")"... | Quick alias to skip the next callback/route method from executing
@param int $num The number of next matches to skip
@throws DispatchHaltedException To halt/skip the current dispatch loop
@return void | [
"Quick",
"alias",
"to",
"skip",
"the",
"next",
"callback",
"/",
"route",
"method",
"from",
"executing"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L1096-L1102 |
klein/klein.php | src/Klein/Klein.php | Klein.options | public function options($path = '*', $callback = null)
{
// Options the arguments in a very loose format
extract(
$this->parseLooseArgumentOrder(func_get_args()),
EXTR_OVERWRITE
);
return $this->respond('OPTIONS', $path, $callback);
} | php | public function options($path = '*', $callback = null)
{
// Options the arguments in a very loose format
extract(
$this->parseLooseArgumentOrder(func_get_args()),
EXTR_OVERWRITE
);
return $this->respond('OPTIONS', $path, $callback);
} | [
"public",
"function",
"options",
"(",
"$",
"path",
"=",
"'*'",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"// Options the arguments in a very loose format",
"extract",
"(",
"$",
"this",
"->",
"parseLooseArgumentOrder",
"(",
"func_get_args",
"(",
")",
")",
",",... | OPTIONS alias for "respond()"
@see Klein::respond()
@param string $path
@param callable $callback
@return Route | [
"OPTIONS",
"alias",
"for",
"respond",
"()"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Klein.php#L1139-L1148 |
klein/klein.php | src/Klein/Response.php | Response.chunk | public function chunk($str = null)
{
parent::chunk();
if (null !== $str) {
printf("%x\r\n", strlen($str));
echo "$str\r\n";
flush();
}
return $this;
} | php | public function chunk($str = null)
{
parent::chunk();
if (null !== $str) {
printf("%x\r\n", strlen($str));
echo "$str\r\n";
flush();
}
return $this;
} | [
"public",
"function",
"chunk",
"(",
"$",
"str",
"=",
"null",
")",
"{",
"parent",
"::",
"chunk",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"str",
")",
"{",
"printf",
"(",
"\"%x\\r\\n\"",
",",
"strlen",
"(",
"$",
"str",
")",
")",
";",
"echo",
... | Enable response chunking
@link https://github.com/klein/klein.php/wiki/Response-Chunking
@link http://bit.ly/hg3gHb
@param string $str An optional string to send as a response "chunk"
@return Response | [
"Enable",
"response",
"chunking"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Response.php#L35-L46 |
klein/klein.php | src/Klein/Response.php | Response.dump | public function dump($obj)
{
if (is_array($obj) || is_object($obj)) {
$obj = print_r($obj, true);
}
$this->append('<pre>' . htmlentities($obj, ENT_QUOTES) . "</pre><br />\n");
return $this;
} | php | public function dump($obj)
{
if (is_array($obj) || is_object($obj)) {
$obj = print_r($obj, true);
}
$this->append('<pre>' . htmlentities($obj, ENT_QUOTES) . "</pre><br />\n");
return $this;
} | [
"public",
"function",
"dump",
"(",
"$",
"obj",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"obj",
")",
"||",
"is_object",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"obj",
"=",
"print_r",
"(",
"$",
"obj",
",",
"true",
")",
";",
"}",
"$",
"this",
"->... | Dump a variable
@param mixed $obj The variable to dump
@return Response | [
"Dump",
"a",
"variable"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Response.php#L54-L63 |
klein/klein.php | src/Klein/Response.php | Response.file | public function file($path, $filename = null, $mimetype = null)
{
if ($this->sent) {
throw new ResponseAlreadySentException('Response has already been sent');
}
$this->body('');
$this->noCache();
if (null === $filename) {
$filename = basename($path);... | php | public function file($path, $filename = null, $mimetype = null)
{
if ($this->sent) {
throw new ResponseAlreadySentException('Response has already been sent');
}
$this->body('');
$this->noCache();
if (null === $filename) {
$filename = basename($path);... | [
"public",
"function",
"file",
"(",
"$",
"path",
",",
"$",
"filename",
"=",
"null",
",",
"$",
"mimetype",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sent",
")",
"{",
"throw",
"new",
"ResponseAlreadySentException",
"(",
"'Response has already been... | Sends a file
It should be noted that this method disables caching
of the response by default, as dynamically created
files responses are usually downloads of some type
and rarely make sense to be HTTP cached
Also, this method removes any data/content that is
currently in the response body and replaces it with
the fil... | [
"Sends",
"a",
"file"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Response.php#L83-L131 |
klein/klein.php | src/Klein/Response.php | Response.json | public function json($object, $jsonp_prefix = null)
{
$this->body('');
$this->noCache();
$json = json_encode($object);
if (null !== $jsonp_prefix) {
// Should ideally be application/json-p once adopted
$this->header('Content-Type', 'text/javascript');
... | php | public function json($object, $jsonp_prefix = null)
{
$this->body('');
$this->noCache();
$json = json_encode($object);
if (null !== $jsonp_prefix) {
// Should ideally be application/json-p once adopted
$this->header('Content-Type', 'text/javascript');
... | [
"public",
"function",
"json",
"(",
"$",
"object",
",",
"$",
"jsonp_prefix",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"body",
"(",
"''",
")",
";",
"$",
"this",
"->",
"noCache",
"(",
")",
";",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"object",
"... | Sends an object as json or jsonp by providing the padding prefix
It should be noted that this method disables caching
of the response by default, as json responses are usually
dynamic and rarely make sense to be HTTP cached
Also, this method removes any data/content that is
currently in the response body and replaces... | [
"Sends",
"an",
"object",
"as",
"json",
"or",
"jsonp",
"by",
"providing",
"the",
"padding",
"prefix"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Response.php#L148-L167 |
klein/klein.php | src/Klein/App.php | App.register | public function register($name, $closure)
{
if (isset($this->services[$name])) {
throw new DuplicateServiceException('A service is already registered under '. $name);
}
$this->services[$name] = function () use ($closure) {
static $instance;
if (null === $... | php | public function register($name, $closure)
{
if (isset($this->services[$name])) {
throw new DuplicateServiceException('A service is already registered under '. $name);
}
$this->services[$name] = function () use ($closure) {
static $instance;
if (null === $... | [
"public",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"closure",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"services",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"DuplicateServiceException",
"(",
"'A service is already regist... | Register a lazy service
@param string $name The name of the service
@param callable $closure The callable function to execute when requesting our service
@throws DuplicateServiceException If an attempt is made to register two services with the same name
@return mixed | [
"Register",
"a",
"lazy",
"service"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/App.php#L86-L100 |
klein/klein.php | src/Klein/DataCollection/RouteCollection.php | RouteCollection.set | public function set($key, $value)
{
if (!$value instanceof Route) {
$value = new Route($value);
}
return parent::set($key, $value);
} | php | public function set($key, $value)
{
if (!$value instanceof Route) {
$value = new Route($value);
}
return parent::set($key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"Route",
")",
"{",
"$",
"value",
"=",
"new",
"Route",
"(",
"$",
"value",
")",
";",
"}",
"return",
"parent",
"::",
"set",
"(",
... | Set a route
{@inheritdoc}
A value may either be a callable or a Route instance
Callable values will be converted into a Route with
the "name" of the route being set from the "key"
A developer may add a named route to the collection
by passing the name of the route as the "$key" and an
instance of a Route as the "$va... | [
"Set",
"a",
"route"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/RouteCollection.php#L59-L66 |
klein/klein.php | src/Klein/DataCollection/RouteCollection.php | RouteCollection.addRoute | public function addRoute(Route $route)
{
/**
* Auto-generate a name from the object's hash
* This makes it so that we can autogenerate names
* that ensure duplicate route instances are overridden
*/
$name = spl_object_hash($route);
return $this->set($name... | php | public function addRoute(Route $route)
{
/**
* Auto-generate a name from the object's hash
* This makes it so that we can autogenerate names
* that ensure duplicate route instances are overridden
*/
$name = spl_object_hash($route);
return $this->set($name... | [
"public",
"function",
"addRoute",
"(",
"Route",
"$",
"route",
")",
"{",
"/**\n * Auto-generate a name from the object's hash\n * This makes it so that we can autogenerate names\n * that ensure duplicate route instances are overridden\n */",
"$",
"name",
"=",
... | Add a route instance to the collection
This will auto-generate a name
@param Route $route
@return RouteCollection | [
"Add",
"a",
"route",
"instance",
"to",
"the",
"collection"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/RouteCollection.php#L76-L86 |
klein/klein.php | src/Klein/DataCollection/RouteCollection.php | RouteCollection.add | public function add($route)
{
if (!$route instanceof Route) {
$route = new Route($route);
}
return $this->addRoute($route);
} | php | public function add($route)
{
if (!$route instanceof Route) {
$route = new Route($route);
}
return $this->addRoute($route);
} | [
"public",
"function",
"add",
"(",
"$",
"route",
")",
"{",
"if",
"(",
"!",
"$",
"route",
"instanceof",
"Route",
")",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"route",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"$",
"rout... | Add a route to the collection
This allows a more generic form that
will take a Route instance, string callable
or any other Route class compatible callback
@param Route|callable $route
@return RouteCollection | [
"Add",
"a",
"route",
"to",
"the",
"collection"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/RouteCollection.php#L98-L105 |
klein/klein.php | src/Klein/DataCollection/RouteCollection.php | RouteCollection.prepareNamed | public function prepareNamed()
{
// Create a new collection so we can keep our order
$prepared = new static();
foreach ($this as $key => $route) {
$route_name = $route->getName();
if (null !== $route_name) {
// Add the route to the new set with the n... | php | public function prepareNamed()
{
// Create a new collection so we can keep our order
$prepared = new static();
foreach ($this as $key => $route) {
$route_name = $route->getName();
if (null !== $route_name) {
// Add the route to the new set with the n... | [
"public",
"function",
"prepareNamed",
"(",
")",
"{",
"// Create a new collection so we can keep our order",
"$",
"prepared",
"=",
"new",
"static",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"route",
")",
"{",
"$",
"route_name",
... | Prepare the named routes in the collection
This loops through every route to set the collection's
key name for that route to equal the routes name, if
its changed
Thankfully, because routes are all objects, this doesn't
take much memory as its simply moving references around
@return RouteCollection | [
"Prepare",
"the",
"named",
"routes",
"in",
"the",
"collection"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/RouteCollection.php#L119-L139 |
klein/klein.php | src/Klein/Request.php | Request.id | public function id($hash = true)
{
if (null === $this->id) {
$this->id = uniqid();
if ($hash) {
$this->id = sha1($this->id);
}
}
return $this->id;
} | php | public function id($hash = true)
{
if (null === $this->id) {
$this->id = uniqid();
if ($hash) {
$this->id = sha1($this->id);
}
}
return $this->id;
} | [
"public",
"function",
"id",
"(",
"$",
"hash",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"id",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"uniqid",
"(",
")",
";",
"if",
"(",
"$",
"hash",
")",
"{",
"$",
"this",
"->",
"i... | Gets a unique ID for the request
Generates one on the first call
@param boolean $hash Whether or not to hash the ID on creation
@return string | [
"Gets",
"a",
"unique",
"ID",
"for",
"the",
"request"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Request.php#L156-L167 |
klein/klein.php | src/Klein/Request.php | Request.params | public function params($mask = null, $fill_with_nulls = true)
{
/*
* Make sure that each key in the mask has at least a
* null value, since the user will expect the key to exist
*/
if (null !== $mask && $fill_with_nulls) {
$attributes = array_fill_keys($mask, n... | php | public function params($mask = null, $fill_with_nulls = true)
{
/*
* Make sure that each key in the mask has at least a
* null value, since the user will expect the key to exist
*/
if (null !== $mask && $fill_with_nulls) {
$attributes = array_fill_keys($mask, n... | [
"public",
"function",
"params",
"(",
"$",
"mask",
"=",
"null",
",",
"$",
"fill_with_nulls",
"=",
"true",
")",
"{",
"/*\n * Make sure that each key in the mask has at least a\n * null value, since the user will expect the key to exist\n */",
"if",
"(",
"nul... | Returns all parameters (GET, POST, named, and cookies) that match the mask
Takes an optional mask param that contains the names of any params
you'd like this method to exclude in the returned array
@see \Klein\DataCollection\DataCollection::all()
@param array $mask The parameter mask array
@param boolea... | [
"Returns",
"all",
"parameters",
"(",
"GET",
"POST",
"named",
"and",
"cookies",
")",
"that",
"match",
"the",
"mask"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Request.php#L266-L286 |
klein/klein.php | src/Klein/Request.php | Request.pathname | public function pathname()
{
$uri = $this->uri();
// Strip the query string from the URI
$uri = strstr($uri, '?', true) ?: $uri;
return $uri;
} | php | public function pathname()
{
$uri = $this->uri();
// Strip the query string from the URI
$uri = strstr($uri, '?', true) ?: $uri;
return $uri;
} | [
"public",
"function",
"pathname",
"(",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"uri",
"(",
")",
";",
"// Strip the query string from the URI",
"$",
"uri",
"=",
"strstr",
"(",
"$",
"uri",
",",
"'?'",
",",
"true",
")",
"?",
":",
"$",
"uri",
";",
... | Get the request's pathname
@return string | [
"Get",
"the",
"request",
"s",
"pathname"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Request.php#L411-L419 |
klein/klein.php | src/Klein/Request.php | Request.method | public function method($is = null, $allow_override = true)
{
$method = $this->server->get('REQUEST_METHOD', 'GET');
// Override
if ($allow_override && $method === 'POST') {
// For legacy servers, override the HTTP method with the X-HTTP-Method-Override header or _method paramete... | php | public function method($is = null, $allow_override = true)
{
$method = $this->server->get('REQUEST_METHOD', 'GET');
// Override
if ($allow_override && $method === 'POST') {
// For legacy servers, override the HTTP method with the X-HTTP-Method-Override header or _method paramete... | [
"public",
"function",
"method",
"(",
"$",
"is",
"=",
"null",
",",
"$",
"allow_override",
"=",
"true",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"server",
"->",
"get",
"(",
"'REQUEST_METHOD'",
",",
"'GET'",
")",
";",
"// Override",
"if",
"(",
"... | Gets the request method, or checks it against $is
<code>
// POST request example
$request->method() // returns 'POST'
$request->method('post') // returns true
$request->method('get') // returns false
</code>
@param string $is The method to check the current request method against
@param boolean $allow_override Whe... | [
"Gets",
"the",
"request",
"method",
"or",
"checks",
"it",
"against",
"$is"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Request.php#L435-L457 |
klein/klein.php | src/Klein/Request.php | Request.query | public function query($key, $value = null)
{
$query = array();
parse_str(
$this->server()->get('QUERY_STRING'),
$query
);
if (is_array($key)) {
$query = array_merge($query, $key);
} else {
$query[$key] = $value;
}
... | php | public function query($key, $value = null)
{
$query = array();
parse_str(
$this->server()->get('QUERY_STRING'),
$query
);
if (is_array($key)) {
$query = array_merge($query, $key);
} else {
$query[$key] = $value;
}
... | [
"public",
"function",
"query",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"array",
"(",
")",
";",
"parse_str",
"(",
"$",
"this",
"->",
"server",
"(",
")",
"->",
"get",
"(",
"'QUERY_STRING'",
")",
",",
"$",
"quer... | Adds to or modifies the current query string
@param string $key The name of the query param
@param mixed $value The value of the query param
@return string | [
"Adds",
"to",
"or",
"modifies",
"the",
"current",
"query",
"string"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Request.php#L466-L488 |
klein/klein.php | src/Klein/Exceptions/RoutePathCompilationException.php | RoutePathCompilationException.createFromRoute | public static function createFromRoute(Route $route, $previous = null)
{
$error = (null !== $previous) ? $previous->getMessage() : null;
$code = (null !== $previous) ? $previous->getCode() : null;
$message = sprintf(static::MESSAGE_FORMAT, $route->getPath());
$message .= ' '. sprin... | php | public static function createFromRoute(Route $route, $previous = null)
{
$error = (null !== $previous) ? $previous->getMessage() : null;
$code = (null !== $previous) ? $previous->getCode() : null;
$message = sprintf(static::MESSAGE_FORMAT, $route->getPath());
$message .= ' '. sprin... | [
"public",
"static",
"function",
"createFromRoute",
"(",
"Route",
"$",
"route",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"error",
"=",
"(",
"null",
"!==",
"$",
"previous",
")",
"?",
"$",
"previous",
"->",
"getMessage",
"(",
")",
":",
"null",
... | Create a RoutePathCompilationException from a route
and an optional previous exception
TODO: Change the `$previous` parameter to type-hint against `Throwable`
once PHP 5.x support is no longer necessary.
@param Route $route The route that failed to compile
@param Exception|Throwable $previous The previous ... | [
"Create",
"a",
"RoutePathCompilationException",
"from",
"a",
"route",
"and",
"an",
"optional",
"previous",
"exception"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Exceptions/RoutePathCompilationException.php#L73-L85 |
klein/klein.php | src/Klein/Route.php | Route.setCallback | public function setCallback($callback)
{
if (!is_callable($callback)) {
throw new InvalidArgumentException('Expected a callable. Got an uncallable '. gettype($callback));
}
$this->callback = $callback;
return $this;
} | php | public function setCallback($callback)
{
if (!is_callable($callback)) {
throw new InvalidArgumentException('Expected a callable. Got an uncallable '. gettype($callback));
}
$this->callback = $callback;
return $this;
} | [
"public",
"function",
"setCallback",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Expected a callable. Got an uncallable '",
".",
"gettype",
"(",
"$",
"call... | Set the callback
@param callable $callback
@throws InvalidArgumentException If the callback isn't a callable
@return Route | [
"Set",
"the",
"callback"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Route.php#L121-L130 |
klein/klein.php | src/Klein/Route.php | Route.setMethod | public function setMethod($method)
{
// Allow null, otherwise expect an array or a string
if (null !== $method && !is_array($method) && !is_string($method)) {
throw new InvalidArgumentException('Expected an array or string. Got a '. gettype($method));
}
$this->method = $... | php | public function setMethod($method)
{
// Allow null, otherwise expect an array or a string
if (null !== $method && !is_array($method) && !is_string($method)) {
throw new InvalidArgumentException('Expected an array or string. Got a '. gettype($method));
}
$this->method = $... | [
"public",
"function",
"setMethod",
"(",
"$",
"method",
")",
"{",
"// Allow null, otherwise expect an array or a string",
"if",
"(",
"null",
"!==",
"$",
"method",
"&&",
"!",
"is_array",
"(",
"$",
"method",
")",
"&&",
"!",
"is_string",
"(",
"$",
"method",
")",
... | Set the method
@param string|array|null $method
@throws InvalidArgumentException If a non-string or non-array type is passed
@return Route | [
"Set",
"the",
"method"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Route.php#L172-L182 |
klein/klein.php | src/Klein/Route.php | Route.setName | public function setName($name)
{
if (null !== $name) {
$this->name = (string) $name;
} else {
$this->name = $name;
}
return $this;
} | php | public function setName($name)
{
if (null !== $name) {
$this->name = (string) $name;
} else {
$this->name = $name;
}
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"(",
"string",
")",
"$",
"name",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"name",
"=",
"$",
"name",
... | Set the name
@param string $name
@return Route | [
"Set",
"the",
"name"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Route.php#L223-L232 |
klein/klein.php | src/Klein/RouteFactory.php | RouteFactory.preprocessPathString | protected function preprocessPathString($path)
{
// If the path is null, make sure to give it our match-all value
$path = (null === $path) ? static::NULL_PATH_VALUE : (string) $path;
// If a custom regular expression (or negated custom regex)
if ($this->namespace &&
(iss... | php | protected function preprocessPathString($path)
{
// If the path is null, make sure to give it our match-all value
$path = (null === $path) ? static::NULL_PATH_VALUE : (string) $path;
// If a custom regular expression (or negated custom regex)
if ($this->namespace &&
(iss... | [
"protected",
"function",
"preprocessPathString",
"(",
"$",
"path",
")",
"{",
"// If the path is null, make sure to give it our match-all value",
"$",
"path",
"=",
"(",
"null",
"===",
"$",
"path",
")",
"?",
"static",
"::",
"NULL_PATH_VALUE",
":",
"(",
"string",
")",
... | Pre-process a path string
This method wraps the path string in a regular expression syntax baesd
on whether the string is a catch-all or custom regular expression.
It also adds the namespace in a specific part, based on the style of expression
@param string $path
@return string | [
"Pre",
"-",
"process",
"a",
"path",
"string"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/RouteFactory.php#L72-L113 |
klein/klein.php | src/Klein/RouteFactory.php | RouteFactory.build | public function build($callback, $path = null, $method = null, $count_match = true, $name = null)
{
return new Route(
$callback,
$this->preprocessPathString($path),
$method,
$this->shouldPathStringCauseRouteMatch($path) // Ignore the $count_match boolean that ... | php | public function build($callback, $path = null, $method = null, $count_match = true, $name = null)
{
return new Route(
$callback,
$this->preprocessPathString($path),
$method,
$this->shouldPathStringCauseRouteMatch($path) // Ignore the $count_match boolean that ... | [
"public",
"function",
"build",
"(",
"$",
"callback",
",",
"$",
"path",
"=",
"null",
",",
"$",
"method",
"=",
"null",
",",
"$",
"count_match",
"=",
"true",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"new",
"Route",
"(",
"$",
"callback",
",",... | Build a Route instance
@param callable $callback Callable callback method to execute on route match
@param string $path Route URI path to match
@param string|array $method HTTP Method to match
@param boolean $count_match Whether or not to count the route as a match when counting total matches
@param stri... | [
"Build",
"a",
"Route",
"instance"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/RouteFactory.php#L125-L133 |
klein/klein.php | src/Klein/ResponseCookie.php | ResponseCookie.setExpire | public function setExpire($expire)
{
if (null !== $expire) {
$this->expire = (int) $expire;
} else {
$this->expire = $expire;
}
return $this;
} | php | public function setExpire($expire)
{
if (null !== $expire) {
$this->expire = (int) $expire;
} else {
$this->expire = $expire;
}
return $this;
} | [
"public",
"function",
"setExpire",
"(",
"$",
"expire",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"expire",
")",
"{",
"$",
"this",
"->",
"expire",
"=",
"(",
"int",
")",
"$",
"expire",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"expire",
"=",
"$",
... | Sets the cookie's expire time
The time should be an integer
representing a Unix timestamp
@param int $expire
@return ResponseCookie | [
"Sets",
"the",
"cookie",
"s",
"expire",
"time"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ResponseCookie.php#L185-L194 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.bind | public function bind(Request $request = null, AbstractResponse $response = null)
{
// Keep references
$this->request = $request ?: $this->request;
$this->response = $response ?: $this->response;
return $this;
} | php | public function bind(Request $request = null, AbstractResponse $response = null)
{
// Keep references
$this->request = $request ?: $this->request;
$this->response = $response ?: $this->response;
return $this;
} | [
"public",
"function",
"bind",
"(",
"Request",
"$",
"request",
"=",
"null",
",",
"AbstractResponse",
"$",
"response",
"=",
"null",
")",
"{",
"// Keep references",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
"?",
":",
"$",
"this",
"->",
"request",
"... | Bind object instances to this service
@param Request $request Object containing all HTTP request data and behaviors
@param AbstractResponse $response Object containing all HTTP response data and behaviors
@return ServiceProvider | [
"Bind",
"object",
"instances",
"to",
"this",
"service"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L98-L105 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.flash | public function flash($msg, $type = 'info', $params = null)
{
$this->startSession();
if (is_array($type)) {
$params = $type;
$type = 'info';
}
if (!isset($_SESSION['__flashes'])) {
$_SESSION['__flashes'] = array($type => array());
} elseif ... | php | public function flash($msg, $type = 'info', $params = null)
{
$this->startSession();
if (is_array($type)) {
$params = $type;
$type = 'info';
}
if (!isset($_SESSION['__flashes'])) {
$_SESSION['__flashes'] = array($type => array());
} elseif ... | [
"public",
"function",
"flash",
"(",
"$",
"msg",
",",
"$",
"type",
"=",
"'info'",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"startSession",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"type",
")",
")",
"{",
"$",
"params",
... | Stores a flash message of $type
@param string $msg The message to flash
@param string $type The flash message type
@param array $params Optional params to be parsed by markdown
@return void | [
"Stores",
"a",
"flash",
"message",
"of",
"$type"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L144-L157 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.flashes | public function flashes($type = null)
{
$this->startSession();
if (!isset($_SESSION['__flashes'])) {
return array();
}
if (null === $type) {
$flashes = $_SESSION['__flashes'];
unset($_SESSION['__flashes']);
} else {
$flashes =... | php | public function flashes($type = null)
{
$this->startSession();
if (!isset($_SESSION['__flashes'])) {
return array();
}
if (null === $type) {
$flashes = $_SESSION['__flashes'];
unset($_SESSION['__flashes']);
} else {
$flashes =... | [
"public",
"function",
"flashes",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"startSession",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"'__flashes'",
"]",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"... | Returns and clears all flashes of optional $type
@param string $type The name of the flash message type
@return array | [
"Returns",
"and",
"clears",
"all",
"flashes",
"of",
"optional",
"$type"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L165-L185 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.markdown | public static function markdown($str, $args = null)
{
// Create our markdown parse/conversion regex's
$md = array(
'/\[([^\]]++)\]\(([^\)]++)\)/' => '<a href="$2">$1</a>',
'/\*\*([^\*]++)\*\*/' => '<strong>$1</strong>',
'/\*([^\*]++)\*/' => '... | php | public static function markdown($str, $args = null)
{
// Create our markdown parse/conversion regex's
$md = array(
'/\[([^\]]++)\]\(([^\)]++)\)/' => '<a href="$2">$1</a>',
'/\*\*([^\*]++)\*\*/' => '<strong>$1</strong>',
'/\*([^\*]++)\*/' => '... | [
"public",
"static",
"function",
"markdown",
"(",
"$",
"str",
",",
"$",
"args",
"=",
"null",
")",
"{",
"// Create our markdown parse/conversion regex's",
"$",
"md",
"=",
"array",
"(",
"'/\\[([^\\]]++)\\]\\(([^\\)]++)\\)/'",
"=>",
"'<a href=\"$2\">$1</a>'",
",",
"'/\\*\... | Render a text string as markdown
Supports basic markdown syntax
Also, this method takes in EITHER an array of optional arguments (as the second parameter)
... OR this method will simply take a variable number of arguments (after the initial str arg)
@param string $str The text string to parse
@param array $args ... | [
"Render",
"a",
"text",
"string",
"as",
"markdown"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L199-L226 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.back | public function back()
{
$referer = $this->request->server()->get('HTTP_REFERER');
if (null !== $referer) {
$this->response->redirect($referer);
} else {
$this->refresh();
}
return $this;
} | php | public function back()
{
$referer = $this->request->server()->get('HTTP_REFERER');
if (null !== $referer) {
$this->response->redirect($referer);
} else {
$this->refresh();
}
return $this;
} | [
"public",
"function",
"back",
"(",
")",
"{",
"$",
"referer",
"=",
"$",
"this",
"->",
"request",
"->",
"server",
"(",
")",
"->",
"get",
"(",
"'HTTP_REFERER'",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"referer",
")",
"{",
"$",
"this",
"->",
"response... | Redirects the request back to the referrer
@return ServiceProvider | [
"Redirects",
"the",
"request",
"back",
"to",
"the",
"referrer"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L263-L274 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.layout | public function layout($layout = null)
{
if (null !== $layout) {
$this->layout = $layout;
return $this;
}
return $this->layout;
} | php | public function layout($layout = null)
{
if (null !== $layout) {
$this->layout = $layout;
return $this;
}
return $this->layout;
} | [
"public",
"function",
"layout",
"(",
"$",
"layout",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"layout",
")",
"{",
"$",
"this",
"->",
"layout",
"=",
"$",
"layout",
";",
"return",
"$",
"this",
";",
"}",
"return",
"$",
"this",
"->",
"lay... | Get (or set) the view's layout
Simply calling this method without any arguments returns the current layout.
Calling with an argument, however, sets the layout to what was provided by the argument.
@param string $layout The layout of the view
@return string|ServiceProvider | [
"Get",
"(",
"or",
"set",
")",
"the",
"view",
"s",
"layout"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L285-L294 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.render | public function render($view, array $data = array())
{
$original_view = $this->view;
if (!empty($data)) {
$this->shared_data->merge($data);
}
$this->view = $view;
if (null === $this->layout) {
$this->yieldView();
} else {
require... | php | public function render($view, array $data = array())
{
$original_view = $this->view;
if (!empty($data)) {
$this->shared_data->merge($data);
}
$this->view = $view;
if (null === $this->layout) {
$this->yieldView();
} else {
require... | [
"public",
"function",
"render",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"original_view",
"=",
"$",
"this",
"->",
"view",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->... | Renders a view + optional layout
@param string $view The view to render
@param array $data The data to render in the view
@return void | [
"Renders",
"a",
"view",
"+",
"optional",
"layout"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L313-L335 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.partial | public function partial($view, array $data = array())
{
$layout = $this->layout;
$this->layout = null;
$this->render($view, $data);
$this->layout = $layout;
} | php | public function partial($view, array $data = array())
{
$layout = $this->layout;
$this->layout = null;
$this->render($view, $data);
$this->layout = $layout;
} | [
"public",
"function",
"partial",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"layout",
";",
"$",
"this",
"->",
"layout",
"=",
"null",
";",
"$",
"this",
"->",
"render",
"(",... | Renders a view without a layout
@param string $view The view to render
@param array $data The data to render in the view
@return void | [
"Renders",
"a",
"view",
"without",
"a",
"layout"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L344-L350 |
klein/klein.php | src/Klein/ServiceProvider.php | ServiceProvider.validateParam | public function validateParam($param, $err = null)
{
return $this->validate($this->request->param($param), $err);
} | php | public function validateParam($param, $err = null)
{
return $this->validate($this->request->param($param), $err);
} | [
"public",
"function",
"validateParam",
"(",
"$",
"param",
",",
"$",
"err",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"validate",
"(",
"$",
"this",
"->",
"request",
"->",
"param",
"(",
"$",
"param",
")",
",",
"$",
"err",
")",
";",
"}"
] | Start a validator chain for the specified parameter
@param string $param The name of the parameter to validate
@param string $err The custom exception message to throw
@return Validator | [
"Start",
"a",
"validator",
"chain",
"for",
"the",
"specified",
"parameter"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/ServiceProvider.php#L383-L386 |
klein/klein.php | src/Klein/DataCollection/DataCollection.php | DataCollection.keys | public function keys($mask = null, $fill_with_nulls = true)
{
if (null !== $mask) {
// Support a more "magical" call
if (!is_array($mask)) {
$mask = func_get_args();
}
/*
* Make sure that the returned array has at least the values... | php | public function keys($mask = null, $fill_with_nulls = true)
{
if (null !== $mask) {
// Support a more "magical" call
if (!is_array($mask)) {
$mask = func_get_args();
}
/*
* Make sure that the returned array has at least the values... | [
"public",
"function",
"keys",
"(",
"$",
"mask",
"=",
"null",
",",
"$",
"fill_with_nulls",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"mask",
")",
"{",
"// Support a more \"magical\" call",
"if",
"(",
"!",
"is_array",
"(",
"$",
"mask",
")",
"... | Returns all of the key names in the collection
If an optional mask array is passed, this only
returns the keys that match the mask
@param array $mask The parameter mask array
@param boolean $fill_with_nulls Whether or not to fill the returned array with
values to match the given mask, even if they don'... | [
"Returns",
"all",
"of",
"the",
"key",
"names",
"in",
"the",
"collection"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/DataCollection.php#L68-L97 |
klein/klein.php | src/Klein/DataCollection/DataCollection.php | DataCollection.all | public function all($mask = null, $fill_with_nulls = true)
{
if (null !== $mask) {
// Support a more "magical" call
if (!is_array($mask)) {
$mask = func_get_args();
}
/*
* Make sure that each key in the mask has at least a
... | php | public function all($mask = null, $fill_with_nulls = true)
{
if (null !== $mask) {
// Support a more "magical" call
if (!is_array($mask)) {
$mask = func_get_args();
}
/*
* Make sure that each key in the mask has at least a
... | [
"public",
"function",
"all",
"(",
"$",
"mask",
"=",
"null",
",",
"$",
"fill_with_nulls",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"mask",
")",
"{",
"// Support a more \"magical\" call",
"if",
"(",
"!",
"is_array",
"(",
"$",
"mask",
")",
")... | Returns all of the attributes in the collection
If an optional mask array is passed, this only
returns the keys that match the mask
@param array $mask The parameter mask array
@param boolean $fill_with_nulls Whether or not to fill the returned array with
values to match the given mask, even if they don... | [
"Returns",
"all",
"of",
"the",
"attributes",
"in",
"the",
"collection"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/DataCollection.php#L110-L139 |
klein/klein.php | src/Klein/DataCollection/DataCollection.php | DataCollection.merge | public function merge(array $attributes = array(), $hard = false)
{
// Don't waste our time with an "array_merge" call if the array is empty
if (!empty($attributes)) {
// Hard merge?
if ($hard) {
$this->attributes = array_replace(
$this->at... | php | public function merge(array $attributes = array(), $hard = false)
{
// Don't waste our time with an "array_merge" call if the array is empty
if (!empty($attributes)) {
// Hard merge?
if ($hard) {
$this->attributes = array_replace(
$this->at... | [
"public",
"function",
"merge",
"(",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"hard",
"=",
"false",
")",
"{",
"// Don't waste our time with an \"array_merge\" call if the array is empty",
"if",
"(",
"!",
"empty",
"(",
"$",
"attributes",
")",
... | Merge attributes with the collection's attributes
Optionally allows a second boolean parameter to merge the attributes
into the collection in a "hard" manner, using the "array_replace"
method instead of the usual "array_merge" method
@param array $attributes The attributes to merge into the collection
@param boolean ... | [
"Merge",
"attributes",
"with",
"the",
"collection",
"s",
"attributes"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/DataCollection.php#L197-L216 |
klein/klein.php | src/Klein/DataCollection/HeaderDataCollection.php | HeaderDataCollection.get | public function get($key, $default_val = null)
{
$key = $this->normalizeKey($key);
return parent::get($key, $default_val);
} | php | public function get($key, $default_val = null)
{
$key = $this->normalizeKey($key);
return parent::get($key, $default_val);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default_val",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"normalizeKey",
"(",
"$",
"key",
")",
";",
"return",
"parent",
"::",
"get",
"(",
"$",
"key",
",",
"$",
"default_val",
... | Get a header
{@inheritdoc}
@see DataCollection::get()
@param string $key The key of the header to return
@param mixed $default_val The default value of the header if it contains no value
@return mixed | [
"Get",
"a",
"header"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/HeaderDataCollection.php#L147-L152 |
klein/klein.php | src/Klein/DataCollection/HeaderDataCollection.php | HeaderDataCollection.normalizeKey | protected function normalizeKey($key)
{
if ($this->normalization & static::NORMALIZE_TRIM) {
$key = trim($key);
}
if ($this->normalization & static::NORMALIZE_DELIMITERS) {
$key = static::normalizeKeyDelimiters($key);
}
if ($this->normalization & sta... | php | protected function normalizeKey($key)
{
if ($this->normalization & static::NORMALIZE_TRIM) {
$key = trim($key);
}
if ($this->normalization & static::NORMALIZE_DELIMITERS) {
$key = static::normalizeKeyDelimiters($key);
}
if ($this->normalization & sta... | [
"protected",
"function",
"normalizeKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"normalization",
"&",
"static",
"::",
"NORMALIZE_TRIM",
")",
"{",
"$",
"key",
"=",
"trim",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->... | Normalize a header key based on our set normalization style
@param string $key The ("field") key of the header
@return string | [
"Normalize",
"a",
"header",
"key",
"based",
"on",
"our",
"set",
"normalization",
"style"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/HeaderDataCollection.php#L209-L228 |
klein/klein.php | src/Klein/DataCollection/HeaderDataCollection.php | HeaderDataCollection.canonicalizeKey | public static function canonicalizeKey($key)
{
$words = explode('-', strtolower($key));
foreach ($words as &$word) {
$word = ucfirst($word);
}
return implode('-', $words);
} | php | public static function canonicalizeKey($key)
{
$words = explode('-', strtolower($key));
foreach ($words as &$word) {
$word = ucfirst($word);
}
return implode('-', $words);
} | [
"public",
"static",
"function",
"canonicalizeKey",
"(",
"$",
"key",
")",
"{",
"$",
"words",
"=",
"explode",
"(",
"'-'",
",",
"strtolower",
"(",
"$",
"key",
")",
")",
";",
"foreach",
"(",
"$",
"words",
"as",
"&",
"$",
"word",
")",
"{",
"$",
"word",
... | Canonicalize a header key
The canonical format is all lower case except for
the first letter of "words" separated by a hyphen
@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
@param string $key The ("field") key of the header
@return string | [
"Canonicalize",
"a",
"header",
"key"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/HeaderDataCollection.php#L254-L263 |
klein/klein.php | src/Klein/DataCollection/HeaderDataCollection.php | HeaderDataCollection.normalizeName | public static function normalizeName($name, $make_lowercase = true)
{
// Warn user of deprecation
trigger_error(
'Use the normalization options and the other normalization methods instead.',
E_USER_DEPRECATED
);
/**
* Lowercasing header names allows ... | php | public static function normalizeName($name, $make_lowercase = true)
{
// Warn user of deprecation
trigger_error(
'Use the normalization options and the other normalization methods instead.',
E_USER_DEPRECATED
);
/**
* Lowercasing header names allows ... | [
"public",
"static",
"function",
"normalizeName",
"(",
"$",
"name",
",",
"$",
"make_lowercase",
"=",
"true",
")",
"{",
"// Warn user of deprecation",
"trigger_error",
"(",
"'Use the normalization options and the other normalization methods instead.'",
",",
"E_USER_DEPRECATED",
... | Normalize a header name by formatting it in a standard way
This is useful since PHP automatically capitalizes and underscore
separates the words of headers
@todo Possibly remove in future, here for backwards compatibility
@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
@param string $name ... | [
"Normalize",
"a",
"header",
"name",
"by",
"formatting",
"it",
"in",
"a",
"standard",
"way"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/DataCollection/HeaderDataCollection.php#L278-L300 |
klein/klein.php | src/Klein/Validator.php | Validator.addDefault | public static function addDefault()
{
static::$methods['null'] = function ($str) {
return $str === null || $str === '';
};
static::$methods['len'] = function ($str, $min, $max = null) {
$len = strlen($str);
return null === $max ? $len === $min : $len >= $m... | php | public static function addDefault()
{
static::$methods['null'] = function ($str) {
return $str === null || $str === '';
};
static::$methods['len'] = function ($str, $min, $max = null) {
$len = strlen($str);
return null === $max ? $len === $min : $len >= $m... | [
"public",
"static",
"function",
"addDefault",
"(",
")",
"{",
"static",
"::",
"$",
"methods",
"[",
"'null'",
"]",
"=",
"function",
"(",
"$",
"str",
")",
"{",
"return",
"$",
"str",
"===",
"null",
"||",
"$",
"str",
"===",
"''",
";",
"}",
";",
"static"... | Adds default validators on first use
@return void | [
"Adds",
"default",
"validators",
"on",
"first",
"use"
] | train | https://github.com/klein/klein.php/blob/43d6725370929ba1c2cf1b0fbb94aab83b84f961/src/Klein/Validator.php#L81-L125 |
jasongrimes/php-paginator | src/JasonGrimes/Paginator.php | Paginator.toHtml | public function toHtml()
{
if ($this->numPages <= 1) {
return '';
}
$html = '<ul class="pagination">';
if ($this->getPrevUrl()) {
$html .= '<li><a href="' . htmlspecialchars($this->getPrevUrl()) . '">« '. $this->previousText .'</a></li>';
}
... | php | public function toHtml()
{
if ($this->numPages <= 1) {
return '';
}
$html = '<ul class="pagination">';
if ($this->getPrevUrl()) {
$html .= '<li><a href="' . htmlspecialchars($this->getPrevUrl()) . '">« '. $this->previousText .'</a></li>';
}
... | [
"public",
"function",
"toHtml",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"numPages",
"<=",
"1",
")",
"{",
"return",
"''",
";",
"}",
"$",
"html",
"=",
"'<ul class=\"pagination\">'",
";",
"if",
"(",
"$",
"this",
"->",
"getPrevUrl",
"(",
")",
")",
... | Render an HTML pagination control.
@return string | [
"Render",
"an",
"HTML",
"pagination",
"control",
"."
] | train | https://github.com/jasongrimes/php-paginator/blob/3411e3cd0c6479a0b514f26e4358f0273552f221/src/JasonGrimes/Paginator.php#L276-L301 |
duzun/hQuery.php | src/hQuery/Node.php | Node.attr | public function attr($attr = null, $to_str = false)
{
$k = key($this->ids);
if (null === $k) {
reset($this->ids);
$k = key($this->ids);
}
return isset($k) ? $this->doc()->get_attr_byId($k, $attr, $to_str) : null;
} | php | public function attr($attr = null, $to_str = false)
{
$k = key($this->ids);
if (null === $k) {
reset($this->ids);
$k = key($this->ids);
}
return isset($k) ? $this->doc()->get_attr_byId($k, $attr, $to_str) : null;
} | [
"public",
"function",
"attr",
"(",
"$",
"attr",
"=",
"null",
",",
"$",
"to_str",
"=",
"false",
")",
"{",
"$",
"k",
"=",
"key",
"(",
"$",
"this",
"->",
"ids",
")",
";",
"if",
"(",
"null",
"===",
"$",
"k",
")",
"{",
"reset",
"(",
"$",
"this",
... | Get and attribute or all attributes of first element in the collection.
@param string $attr attribute name, or NULL to get all
@param boolean $to_str When $attr is NULL, if true, get the list of attributes as string
@return array|string If no $attr, return a list of attributes, or attribute's value othe... | [
"Get",
"and",
"attribute",
"or",
"all",
"attributes",
"of",
"first",
"element",
"in",
"the",
"collection",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L129-L137 |
duzun/hQuery.php | src/hQuery/Node.php | Node.find | public function find($sel, $attr = null)
{
return $this->doc()->find($sel, $attr, $this);
} | php | public function find($sel, $attr = null)
{
return $this->doc()->find($sel, $attr, $this);
} | [
"public",
"function",
"find",
"(",
"$",
"sel",
",",
"$",
"attr",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"doc",
"(",
")",
"->",
"find",
"(",
"$",
"sel",
",",
"$",
"attr",
",",
"$",
"this",
")",
";",
"}"
] | Finds a collection of nodes inside current document/context (similar to jQuery.fn.find()).
@param string $sel A valid CSS selector (some pseudo-selectors supported).
@param array|string $attr OPTIONAL attributes as string or key-value pairs.
@return hQuery_Element collection of matched elements ... | [
"Finds",
"a",
"collection",
"of",
"nodes",
"inside",
"current",
"document",
"/",
"context",
"(",
"similar",
"to",
"jQuery",
".",
"fn",
".",
"find",
"()",
")",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L183-L186 |
duzun/hQuery.php | src/hQuery/Node.php | Node.dl | public function dl($dt_sel = 'dt', $dd_sel = 'dd', $dw = null, $key = null)
{
$oneKey = isset($key);
$dl = $oneKey ? null : array();
if ($dw) {
$l = $this->find($dw);
if ($l) {
foreach ($l as $i => $w) {
if ($dt_sel) {
... | php | public function dl($dt_sel = 'dt', $dd_sel = 'dd', $dw = null, $key = null)
{
$oneKey = isset($key);
$dl = $oneKey ? null : array();
if ($dw) {
$l = $this->find($dw);
if ($l) {
foreach ($l as $i => $w) {
if ($dt_sel) {
... | [
"public",
"function",
"dl",
"(",
"$",
"dt_sel",
"=",
"'dt'",
",",
"$",
"dd_sel",
"=",
"'dd'",
",",
"$",
"dw",
"=",
"null",
",",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"oneKey",
"=",
"isset",
"(",
"$",
"key",
")",
";",
"$",
"dl",
"=",
"$",
... | Definition list parser
@param $ $dl dl element
@param String|RegExp|Function $key search for one specific key
@param String $dt_sel dt selector (default "dt")
@param String $dd_sel dd selector (default "dd")
@param String $dw definiti... | [
"Definition",
"list",
"parser"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L330-L397 |
duzun/hQuery.php | src/hQuery/Node.php | Node.pos | public function pos($restore = true)
{
$k = key($this->ids);
if (null === $k) {
reset($this->ids);
$k = key($this->ids);
if (null !== $k && $restore) {
end($this->ids);
next($this->ids);
}
}
return $k;
... | php | public function pos($restore = true)
{
$k = key($this->ids);
if (null === $k) {
reset($this->ids);
$k = key($this->ids);
if (null !== $k && $restore) {
end($this->ids);
next($this->ids);
}
}
return $k;
... | [
"public",
"function",
"pos",
"(",
"$",
"restore",
"=",
"true",
")",
"{",
"$",
"k",
"=",
"key",
"(",
"$",
"this",
"->",
"ids",
")",
";",
"if",
"(",
"null",
"===",
"$",
"k",
")",
"{",
"reset",
"(",
"$",
"this",
"->",
"ids",
")",
";",
"$",
"k"... | Get string offset of the first/current element
in the source HTML document.
<div class="test"> Contents <span>of</span> #test </div>
|
pos()
@param boolean $restore - if true, restore internal pointer to previous position
@return int | [
"Get",
"string",
"offset",
"of",
"the",
"first",
"/",
"current",
"element",
"in",
"the",
"source",
"HTML",
"document",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L460-L472 |
duzun/hQuery.php | src/hQuery/Node.php | Node._ctx_ids | protected function _ctx_ids($ids = null)
{
$m = -1;
$exc = $this->exc;
if (!isset($ids)) {
$ids = $this->ids;
} elseif (is_int($ids)) {
$ids = isset($this->ids[$ids]) ? array($ids => $this->ids[$ids]) : self::$_fl_;
} else {
foreach ($ids... | php | protected function _ctx_ids($ids = null)
{
$m = -1;
$exc = $this->exc;
if (!isset($ids)) {
$ids = $this->ids;
} elseif (is_int($ids)) {
$ids = isset($this->ids[$ids]) ? array($ids => $this->ids[$ids]) : self::$_fl_;
} else {
foreach ($ids... | [
"protected",
"function",
"_ctx_ids",
"(",
"$",
"ids",
"=",
"null",
")",
"{",
"$",
"m",
"=",
"-",
"1",
";",
"$",
"exc",
"=",
"$",
"this",
"->",
"exc",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"ids",
")",
")",
"{",
"$",
"ids",
"=",
"$",
"this"... | Make a context array of ids:
if x in $ids && exists y in $ids such that x in y then del x from $ids
@return array ids | [
"Make",
"a",
"context",
"array",
"of",
"ids",
":",
"if",
"x",
"in",
"$ids",
"&&",
"exists",
"y",
"in",
"$ids",
"such",
"that",
"x",
"in",
"y",
"then",
"del",
"x",
"from",
"$ids"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L481-L500 |
duzun/hQuery.php | src/hQuery/Node.php | Node._sub_ids | protected function _sub_ids($eq = false)
{
$ret = array();
$ce = reset($this->ids);
$cb = key($this->ids);
$doc = $this->doc();
foreach ($doc->ids as $b => $e) {
if ($b < $cb || !$eq && $b == $cb) {
continue;
}
if ($b < $... | php | protected function _sub_ids($eq = false)
{
$ret = array();
$ce = reset($this->ids);
$cb = key($this->ids);
$doc = $this->doc();
foreach ($doc->ids as $b => $e) {
if ($b < $cb || !$eq && $b == $cb) {
continue;
}
if ($b < $... | [
"protected",
"function",
"_sub_ids",
"(",
"$",
"eq",
"=",
"false",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"ce",
"=",
"reset",
"(",
"$",
"this",
"->",
"ids",
")",
";",
"$",
"cb",
"=",
"key",
"(",
"$",
"this",
"->",
"ids",
")",... | Get all ids from inside of this element
@return array ids | [
"Get",
"all",
"ids",
"from",
"inside",
"of",
"this",
"element"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L507-L530 |
duzun/hQuery.php | src/hQuery/Node.php | Node._doc_ids | protected function _doc_ids($el, $force_array = true)
{
if ($el instanceof self) {
$el = $el->ids;
}
if ($force_array) {
if (is_int($el)) {
$el = array($el => $this->doc()->ids[$el]);
}
if (!is_array($el)) {
th... | php | protected function _doc_ids($el, $force_array = true)
{
if ($el instanceof self) {
$el = $el->ids;
}
if ($force_array) {
if (is_int($el)) {
$el = array($el => $this->doc()->ids[$el]);
}
if (!is_array($el)) {
th... | [
"protected",
"function",
"_doc_ids",
"(",
"$",
"el",
",",
"$",
"force_array",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"el",
"instanceof",
"self",
")",
"{",
"$",
"el",
"=",
"$",
"el",
"->",
"ids",
";",
"}",
"if",
"(",
"$",
"force_array",
")",
"{",
... | Get and Normalize ids of $el
@return array ids | [
"Get",
"and",
"Normalize",
"ids",
"of",
"$el"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L537-L554 |
duzun/hQuery.php | src/hQuery/Node.php | Node._has | public function _has($el, $eq = false)
{
if (is_int($el)) {
$e = end($this->ids);
if ($el >= $e) {
return self::$_fl_;
}
foreach ($this->ids as $b => $e) {
if ($el < $b) {
return self::$_fl_;
... | php | public function _has($el, $eq = false)
{
if (is_int($el)) {
$e = end($this->ids);
if ($el >= $e) {
return self::$_fl_;
}
foreach ($this->ids as $b => $e) {
if ($el < $b) {
return self::$_fl_;
... | [
"public",
"function",
"_has",
"(",
"$",
"el",
",",
"$",
"eq",
"=",
"false",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"el",
")",
")",
"{",
"$",
"e",
"=",
"end",
"(",
"$",
"this",
"->",
"ids",
")",
";",
"if",
"(",
"$",
"el",
">=",
"$",
"e",... | $el < $this, with $eq == true -> $el <= $this
@param $el
@param $eq
@return mixed | [
"$el",
"<",
"$this",
"with",
"$eq",
"==",
"true",
"-",
">",
"$el",
"<",
"=",
"$this"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L984-L1024 |
duzun/hQuery.php | src/hQuery/Node.php | Node._filter_contains | public function _filter_contains($el, $eq = false)
{
if ($el instanceof self) {
$o = $el;
}
$el = $this->_doc_ids($el);
$ret = self::$_ar_;
$lb = $le = -1; // last parent
$ie = reset($el); // current child
$ib = key($el);
foreach ($thi... | php | public function _filter_contains($el, $eq = false)
{
if ($el instanceof self) {
$o = $el;
}
$el = $this->_doc_ids($el);
$ret = self::$_ar_;
$lb = $le = -1; // last parent
$ie = reset($el); // current child
$ib = key($el);
foreach ($thi... | [
"public",
"function",
"_filter_contains",
"(",
"$",
"el",
",",
"$",
"eq",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"el",
"instanceof",
"self",
")",
"{",
"$",
"o",
"=",
"$",
"el",
";",
"}",
"$",
"el",
"=",
"$",
"this",
"->",
"_doc_ids",
"(",
"$",... | Filter all ids of $el that are contained in(side) $this->ids
@param hQuery_Node|array $el A node or list of ids
@param boolean $eq if false, filter strict contents, otherwise $el might be in $this->ids
@return hQuery_Node|array same type as $el | [
"Filter",
"all",
"ids",
"of",
"$el",
"that",
"are",
"contained",
"in",
"(",
"side",
")",
"$this",
"-",
">",
"ids"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L1033-L1070 |
duzun/hQuery.php | src/hQuery/Node.php | Node.current | public function current()
{
$k = key($this->ids);
if (null === $k) {
return false;
}
return array($k => $this->ids[$k]);
} | php | public function current()
{
$k = key($this->ids);
if (null === $k) {
return false;
}
return array($k => $this->ids[$k]);
} | [
"public",
"function",
"current",
"(",
")",
"{",
"$",
"k",
"=",
"key",
"(",
"$",
"this",
"->",
"ids",
")",
";",
"if",
"(",
"null",
"===",
"$",
"k",
")",
"{",
"return",
"false",
";",
"}",
"return",
"array",
"(",
"$",
"k",
"=>",
"$",
"this",
"->... | Iterable: | [
"Iterable",
":"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L1125-L1133 |
duzun/hQuery.php | src/hQuery/Node.php | Node.text_parse_dl | public static function text_parse_dl($dl, $sep = ':', $key = null)
{
// Get the textContents of $dl
if ($dl instanceof self) {
if (count($dl) > 1) {
$ln = array();
foreach ($dl as $o) {
$ln[] = $o->text();
}
... | php | public static function text_parse_dl($dl, $sep = ':', $key = null)
{
// Get the textContents of $dl
if ($dl instanceof self) {
if (count($dl) > 1) {
$ln = array();
foreach ($dl as $o) {
$ln[] = $o->text();
}
... | [
"public",
"static",
"function",
"text_parse_dl",
"(",
"$",
"dl",
",",
"$",
"sep",
"=",
"':'",
",",
"$",
"key",
"=",
"null",
")",
"{",
"// Get the textContents of $dl",
"if",
"(",
"$",
"dl",
"instanceof",
"self",
")",
"{",
"if",
"(",
"count",
"(",
"$",
... | Textual definition list parser
@param $|string $dl text or Element containing definition list text
@param string $sep key-value separator (default ":")
@param string|Closure $key search for one specific key
@return array|mixed the value for $key or list of key-value if no $key | [
"Textual",
"definition",
"list",
"parser"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L1175-L1223 |
duzun/hQuery.php | src/hQuery/Node.php | Node.html_normal_pseudoClass | public static function html_normal_pseudoClass($p)
{
if (is_int($p)) {
return $p;
}
$i = (int) $p;
if ((string) $i === $p) {
return $i;
}
/**
* @var array
*/
static $map = array(
'lt' => '<',
... | php | public static function html_normal_pseudoClass($p)
{
if (is_int($p)) {
return $p;
}
$i = (int) $p;
if ((string) $i === $p) {
return $i;
}
/**
* @var array
*/
static $map = array(
'lt' => '<',
... | [
"public",
"static",
"function",
"html_normal_pseudoClass",
"(",
"$",
"p",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"p",
")",
")",
"{",
"return",
"$",
"p",
";",
"}",
"$",
"i",
"=",
"(",
"int",
")",
"$",
"p",
";",
"if",
"(",
"(",
"string",
")",
... | Normalize a CSS selector pseudo-class string.
( int, string or array(name => value) )
@internal
@return int|array | [
"Normalize",
"a",
"CSS",
"selector",
"pseudo",
"-",
"class",
"string",
".",
"(",
"int",
"string",
"or",
"array",
"(",
"name",
"=",
">",
"value",
")",
")"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L1233-L1276 |
duzun/hQuery.php | src/hQuery/Node.php | Node.html_selector2struc | public static function html_selector2struc($sel)
{
$sc = '#.:';
$n = null;
$a = array();
$def = array('n' => $n, 'i' => $n, 'c' => $a, 'p' => $a);
$sel = rtrim(trim(preg_replace('/\\s*(>|,)\\s*/', '$1', $sel), " \t\n\r,>"), $sc);
$sel = explode(',', $sel);
... | php | public static function html_selector2struc($sel)
{
$sc = '#.:';
$n = null;
$a = array();
$def = array('n' => $n, 'i' => $n, 'c' => $a, 'p' => $a);
$sel = rtrim(trim(preg_replace('/\\s*(>|,)\\s*/', '$1', $sel), " \t\n\r,>"), $sc);
$sel = explode(',', $sel);
... | [
"public",
"static",
"function",
"html_selector2struc",
"(",
"$",
"sel",
")",
"{",
"$",
"sc",
"=",
"'#.:'",
";",
"$",
"n",
"=",
"null",
";",
"$",
"a",
"=",
"array",
"(",
")",
";",
"$",
"def",
"=",
"array",
"(",
"'n'",
"=>",
"$",
"n",
",",
"'i'",... | Parse a selector string into an array structure.
tn1#id1 .cl1.cl2:first tn2:5 , tn3.cl3 tn4#id2:eq(-1) > tn5:last-child > tn6:lt(3)
-->
[
[
[{ n: "tn1", i: "id1", c: [], p: [] }],
[{ n: NULL, i: NULL, c: ["cl1","cl2"], p: [0] }],
[{ n: "tn2", i: NULL, c: [], p: [5] }]
]
, [
[{ n: "tn3", i: NU... | [
"Parse",
"a",
"selector",
"string",
"into",
"an",
"array",
"structure",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Node.php#L1303-L1353 |
duzun/hQuery.php | src/hQuery/Context.php | Context.intersect | public function intersect($el, $eq = true)
{
if ($el instanceof self) {
if ($el === $this) {
if ($eq) {
return $this;
} else {
$el = array();
}
} else {
$el = $el->ids;
... | php | public function intersect($el, $eq = true)
{
if ($el instanceof self) {
if ($el === $this) {
if ($eq) {
return $this;
} else {
$el = array();
}
} else {
$el = $el->ids;
... | [
"public",
"function",
"intersect",
"(",
"$",
"el",
",",
"$",
"eq",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"el",
"instanceof",
"self",
")",
"{",
"if",
"(",
"$",
"el",
"===",
"$",
"this",
")",
"{",
"if",
"(",
"$",
"eq",
")",
"{",
"return",
"$",... | ctx($el) * $this
@return duzun\hQuery\Context ctx | [
"ctx",
"(",
"$el",
")",
"*",
"$this"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Context.php#L42-L67 |
duzun/hQuery.php | src/hQuery/Element.php | Element.current | public function current()
{
$k = key($this->ids);
if (null === $k) {
return false;
}
if (count($this->ids) == 1) {
return $this;
}
if (!isset($this->_ich[$k])) {
$this->_ich[$k] = new self($this->doc, array($k => $this->ids[$k]));... | php | public function current()
{
$k = key($this->ids);
if (null === $k) {
return false;
}
if (count($this->ids) == 1) {
return $this;
}
if (!isset($this->_ich[$k])) {
$this->_ich[$k] = new self($this->doc, array($k => $this->ids[$k]));... | [
"public",
"function",
"current",
"(",
")",
"{",
"$",
"k",
"=",
"key",
"(",
"$",
"this",
"->",
"ids",
")",
";",
"if",
"(",
"null",
"===",
"$",
"k",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"ids",
")",
... | Override current() for iterations.
@return hQuery_Element | [
"Override",
"current",
"()",
"for",
"iterations",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L163-L179 |
duzun/hQuery.php | src/hQuery/Element.php | Element.val | public function val()
{
$el = count($this) > 1 ? $this->get(0) : $this;
switch (strtoupper($el->nodeName(false))) {
case 'TEXTAREA':
return $el->html();
case 'INPUT':
switch (strtoupper($el->attr('type'))) {
case 'CHECKBOX':... | php | public function val()
{
$el = count($this) > 1 ? $this->get(0) : $this;
switch (strtoupper($el->nodeName(false))) {
case 'TEXTAREA':
return $el->html();
case 'INPUT':
switch (strtoupper($el->attr('type'))) {
case 'CHECKBOX':... | [
"public",
"function",
"val",
"(",
")",
"{",
"$",
"el",
"=",
"count",
"(",
"$",
"this",
")",
">",
"1",
"?",
"$",
"this",
"->",
"get",
"(",
"0",
")",
":",
"$",
"this",
";",
"switch",
"(",
"strtoupper",
"(",
"$",
"el",
"->",
"nodeName",
"(",
"fa... | Get value of an :input element.
@return mixed value of the first element in the collection. | [
"Get",
"value",
"of",
"an",
":",
"input",
"element",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L187-L206 |
duzun/hQuery.php | src/hQuery/Element.php | Element.hasClass | public function hasClass($className)
{
$ret = $this->doc()->hasClass($this, $className);
if (!is_array($ret)) {
return $ret;
}
if (count($this) < 2) {
return reset($ret);
}
return max($ret);
} | php | public function hasClass($className)
{
$ret = $this->doc()->hasClass($this, $className);
if (!is_array($ret)) {
return $ret;
}
if (count($this) < 2) {
return reset($ret);
}
return max($ret);
} | [
"public",
"function",
"hasClass",
"(",
"$",
"className",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"doc",
"(",
")",
"->",
"hasClass",
"(",
"$",
"this",
",",
"$",
"className",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ret",
")",
")",
... | Checks whether $this element/collection has a(ll) class(es).
@param string|array $cl - class(es) to check
@return true - has class, false - no class, - doesn't have any class, | [
"Checks",
"whether",
"$this",
"element",
"/",
"collection",
"has",
"a",
"(",
"ll",
")",
"class",
"(",
"es",
")",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L214-L226 |
duzun/hQuery.php | src/hQuery/Element.php | Element.get | public function get($idx)
{
$i = array_slice($this->ids, $idx, 1, true);
if (!$i) {
return null;
}
// Try read cache first
$k = key($i);
if (isset($this->_ich[$k])) {
return $this->_ich[$k];
}
// Create wraper instance for $i
... | php | public function get($idx)
{
$i = array_slice($this->ids, $idx, 1, true);
if (!$i) {
return null;
}
// Try read cache first
$k = key($i);
if (isset($this->_ich[$k])) {
return $this->_ich[$k];
}
// Create wraper instance for $i
... | [
"public",
"function",
"get",
"(",
"$",
"idx",
")",
"{",
"$",
"i",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"ids",
",",
"$",
"idx",
",",
"1",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"i",
")",
"{",
"return",
"null",
";",
"}",
"// Try rea... | Get the node at $idx position in the set, using cache
@param int $idx - index of an element, starts with 0.
@return hQuery_Element | [
"Get",
"the",
"node",
"at",
"$idx",
"position",
"in",
"the",
"set",
"using",
"cache"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L234-L254 |
duzun/hQuery.php | src/hQuery/Element.php | Element.eq | public function eq($idx)
{
$i = array_slice($this->ids, $idx, 1, true) or
$i = array();
// Create wraper instance for $i
$o = new self($this->doc, $i);
return $o;
} | php | public function eq($idx)
{
$i = array_slice($this->ids, $idx, 1, true) or
$i = array();
// Create wraper instance for $i
$o = new self($this->doc, $i);
return $o;
} | [
"public",
"function",
"eq",
"(",
"$",
"idx",
")",
"{",
"$",
"i",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"ids",
",",
"$",
"idx",
",",
"1",
",",
"true",
")",
"or",
"$",
"i",
"=",
"array",
"(",
")",
";",
"// Create wraper instance for $i",
"$",
... | Get the node at $idx position in the set, no cache, each call creates new instance.
@param int $idx - index of an element, starts with 0.
@return hQuery_Element | [
"Get",
"the",
"node",
"at",
"$idx",
"position",
"in",
"the",
"set",
"no",
"cache",
"each",
"call",
"creates",
"new",
"instance",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L262-L269 |
duzun/hQuery.php | src/hQuery/Element.php | Element.slice | public function slice($idx, $len = null)
{
$c = $this->count();
if ($idx < $c) {
$ids = array();
} elseif (isset($len)) {
if (0 == $idx && $len == $c) {
return $this; // ???
$ids = $this->ids;
}
$ids = array_slic... | php | public function slice($idx, $len = null)
{
$c = $this->count();
if ($idx < $c) {
$ids = array();
} elseif (isset($len)) {
if (0 == $idx && $len == $c) {
return $this; // ???
$ids = $this->ids;
}
$ids = array_slic... | [
"public",
"function",
"slice",
"(",
"$",
"idx",
",",
"$",
"len",
"=",
"null",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"idx",
"<",
"$",
"c",
")",
"{",
"$",
"ids",
"=",
"array",
"(",
")",
";",
"}"... | Get a slice of current node collection.
@param int $idx - start index of an element, starts with 0.
@param int $len - OPTIONAL number of element to slice. Defaults to all starting at $idx
@return hQuery_Element | [
"Get",
"a",
"slice",
"of",
"current",
"node",
"collection",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L296-L317 |
duzun/hQuery.php | src/hQuery/Element.php | Element.parent | public function parent()
{
$p = $this->_parent();
return $p ? new self($this->doc, $p) : null;
} | php | public function parent()
{
$p = $this->_parent();
return $p ? new self($this->doc, $p) : null;
} | [
"public",
"function",
"parent",
"(",
")",
"{",
"$",
"p",
"=",
"$",
"this",
"->",
"_parent",
"(",
")",
";",
"return",
"$",
"p",
"?",
"new",
"self",
"(",
"$",
"this",
"->",
"doc",
",",
"$",
"p",
")",
":",
"null",
";",
"}"
] | Get parent nodes for this collection of nodes.
@return hQuery_Element parent | [
"Get",
"parent",
"nodes",
"for",
"this",
"collection",
"of",
"nodes",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L324-L328 |
duzun/hQuery.php | src/hQuery/Element.php | Element.children | public function children()
{
$p = $this->_children();
return $p ? new self($this->doc, $p) : null;
} | php | public function children()
{
$p = $this->_children();
return $p ? new self($this->doc, $p) : null;
} | [
"public",
"function",
"children",
"(",
")",
"{",
"$",
"p",
"=",
"$",
"this",
"->",
"_children",
"(",
")",
";",
"return",
"$",
"p",
"?",
"new",
"self",
"(",
"$",
"this",
"->",
"doc",
",",
"$",
"p",
")",
":",
"null",
";",
"}"
] | Get child nodes for this collection of nodes.
@return hQuery_Element children | [
"Get",
"child",
"nodes",
"for",
"this",
"collection",
"of",
"nodes",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L335-L339 |
duzun/hQuery.php | src/hQuery/Element.php | Element.previousElementSibling | public function previousElementSibling()
{
$p = $this->_prev();
return $p ? new self($this->doc, $p) : null;
} | php | public function previousElementSibling()
{
$p = $this->_prev();
return $p ? new self($this->doc, $p) : null;
} | [
"public",
"function",
"previousElementSibling",
"(",
")",
"{",
"$",
"p",
"=",
"$",
"this",
"->",
"_prev",
"(",
")",
";",
"return",
"$",
"p",
"?",
"new",
"self",
"(",
"$",
"this",
"->",
"doc",
",",
"$",
"p",
")",
":",
"null",
";",
"}"
] | Get previous element siblings for each of the elements of this collection
@return hQuery_Element previousElementSibling | [
"Get",
"previous",
"element",
"siblings",
"for",
"each",
"of",
"the",
"elements",
"of",
"this",
"collection"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L346-L350 |
duzun/hQuery.php | src/hQuery/Element.php | Element.nextElementSibling | public function nextElementSibling()
{
$p = $this->_next();
return $p ? new self($this->doc, $p) : null;
} | php | public function nextElementSibling()
{
$p = $this->_next();
return $p ? new self($this->doc, $p) : null;
} | [
"public",
"function",
"nextElementSibling",
"(",
")",
"{",
"$",
"p",
"=",
"$",
"this",
"->",
"_next",
"(",
")",
";",
"return",
"$",
"p",
"?",
"new",
"self",
"(",
"$",
"this",
"->",
"doc",
",",
"$",
"p",
")",
":",
"null",
";",
"}"
] | Get next element siblings for each of the elements of this collection
@return hQuery_Element nextElementSibling | [
"Get",
"next",
"element",
"siblings",
"for",
"each",
"of",
"the",
"elements",
"of",
"this",
"collection"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/Element.php#L357-L361 |
duzun/hQuery.php | src/hQuery/HTML_Parser.php | HTML_Parser.baseURI | public function baseURI($href = null)
{
if (func_num_args() < 1) {
$href = @$this->_prop['baseURI'];
} else {
if ($href) {
$t = self::get_url_base($href, true);
if (!$t) {
return false;
}
lis... | php | public function baseURI($href = null)
{
if (func_num_args() < 1) {
$href = @$this->_prop['baseURI'];
} else {
if ($href) {
$t = self::get_url_base($href, true);
if (!$t) {
return false;
}
lis... | [
"public",
"function",
"baseURI",
"(",
"$",
"href",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"<",
"1",
")",
"{",
"$",
"href",
"=",
"@",
"$",
"this",
"->",
"_prop",
"[",
"'baseURI'",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"$",... | get/set baseURI
@param string $href
@return string | [
"get",
"/",
"set",
"baseURI"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/HTML_Parser.php#L211-L232 |
duzun/hQuery.php | src/hQuery/HTML_Parser.php | HTML_Parser.is_abs_path | public static function is_abs_path($path)
{
$ds = array('\\' => 1, '/' => 2);
if (isset($ds[substr($path, 0, 1)]) ||
substr($path, 1, 1) == ':' && isset($ds[substr($path, 2, 1)])
) {
return true;
}
if (($l = strpos($path, '://')) && $l < 32) {
... | php | public static function is_abs_path($path)
{
$ds = array('\\' => 1, '/' => 2);
if (isset($ds[substr($path, 0, 1)]) ||
substr($path, 1, 1) == ':' && isset($ds[substr($path, 2, 1)])
) {
return true;
}
if (($l = strpos($path, '://')) && $l < 32) {
... | [
"public",
"static",
"function",
"is_abs_path",
"(",
"$",
"path",
")",
"{",
"$",
"ds",
"=",
"array",
"(",
"'\\\\'",
"=>",
"1",
",",
"'/'",
"=>",
"2",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"ds",
"[",
"substr",
"(",
"$",
"path",
",",
"0",
",",
... | Check whether $path is an absolute path.
@param string $path - a path to check
@return bool TRUE if $path is an absolute path, FALSE otherwise | [
"Check",
"whether",
"$path",
"is",
"an",
"absolute",
"path",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/HTML_Parser.php#L358-L371 |
duzun/hQuery.php | src/hQuery/HTML_Parser.php | HTML_Parser.abs_url | public static function abs_url($url, $base)
{
if (!self::is_url_path($url)) {
$t = is_array($base) ? $base : parse_url($base);
if (strncmp($url, '//', 2) == 0) {
if (!empty($t['scheme'])) {
$url = $t['scheme'] . ':' . $url;
}
... | php | public static function abs_url($url, $base)
{
if (!self::is_url_path($url)) {
$t = is_array($base) ? $base : parse_url($base);
if (strncmp($url, '//', 2) == 0) {
if (!empty($t['scheme'])) {
$url = $t['scheme'] . ':' . $url;
}
... | [
"public",
"static",
"function",
"abs_url",
"(",
"$",
"url",
",",
"$",
"base",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"is_url_path",
"(",
"$",
"url",
")",
")",
"{",
"$",
"t",
"=",
"is_array",
"(",
"$",
"base",
")",
"?",
"$",
"base",
":",
"parse... | Given a $url (relative or absolute) and a $base url, returns absolute url for $url.
@param string $url - relative or absolute URL
@param string $base - Base URL for $url
@return string absolute URL for $url | [
"Given",
"a",
"$url",
"(",
"relative",
"or",
"absolute",
")",
"and",
"a",
"$base",
"url",
"returns",
"absolute",
"url",
"for",
"$url",
"."
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/HTML_Parser.php#L380-L409 |
duzun/hQuery.php | src/hQuery/HTML_Parser.php | HTML_Parser._info | public function _info()
{
$inf = array();
$ar = array();
foreach ($this->attribs as $i => $a) {
$ar[$i] = self::html_attr2str($a);
}
$inf['attribs'] = $ar;
$inf['attrs'] = $this->attrs;
$inf['idx_attr'] = $this->idx_attr;
$inf['tag... | php | public function _info()
{
$inf = array();
$ar = array();
foreach ($this->attribs as $i => $a) {
$ar[$i] = self::html_attr2str($a);
}
$inf['attribs'] = $ar;
$inf['attrs'] = $this->attrs;
$inf['idx_attr'] = $this->idx_attr;
$inf['tag... | [
"public",
"function",
"_info",
"(",
")",
"{",
"$",
"inf",
"=",
"array",
"(",
")",
";",
"$",
"ar",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"attribs",
"as",
"$",
"i",
"=>",
"$",
"a",
")",
"{",
"$",
"ar",
"[",
"$",
"i",... | This method is for debugging only ( __debugInfo()??? )
@return array | [
"This",
"method",
"is",
"for",
"debugging",
"only",
"(",
"__debugInfo",
"()",
"???",
")"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/HTML_Parser.php#L477-L518 |
duzun/hQuery.php | src/hQuery/HTML_Parser.php | HTML_Parser._index_comments_html | protected function _index_comments_html($o)
{
if (!isset($o->l)) {
$o->l = strlen($o->h);
}
$o->tg = self::$_ar_;
$i = $o->i;
while ($i < $o->l) {
$i = strpos($o->h, '<!--', $i);
if (false === $i) {
break;
}... | php | protected function _index_comments_html($o)
{
if (!isset($o->l)) {
$o->l = strlen($o->h);
}
$o->tg = self::$_ar_;
$i = $o->i;
while ($i < $o->l) {
$i = strpos($o->h, '<!--', $i);
if (false === $i) {
break;
}... | [
"protected",
"function",
"_index_comments_html",
"(",
"$",
"o",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"o",
"->",
"l",
")",
")",
"{",
"$",
"o",
"->",
"l",
"=",
"strlen",
"(",
"$",
"o",
"->",
"h",
")",
";",
"}",
"$",
"o",
"->",
"tg",
"... | Index comment tags position in source HTML
@param stdClass $o
@return stdClass $o | [
"Index",
"comment",
"tags",
"position",
"in",
"source",
"HTML"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/HTML_Parser.php#L526-L552 |
duzun/hQuery.php | src/hQuery/HTML_Parser.php | HTML_Parser._index_tags | private function _index_tags()
{
$s = $nix = $ix = self::$_ar_;
$ids = $this->ids;
foreach ($this->tags as $id => $n) {
// if(!isset($ix[$n])) $ix[$n] = array();
$ix[$n][$id] = $ids[$id];
}
foreach ($ix as $n => $v) {
foreach ($v as $... | php | private function _index_tags()
{
$s = $nix = $ix = self::$_ar_;
$ids = $this->ids;
foreach ($this->tags as $id => $n) {
// if(!isset($ix[$n])) $ix[$n] = array();
$ix[$n][$id] = $ids[$id];
}
foreach ($ix as $n => $v) {
foreach ($v as $... | [
"private",
"function",
"_index_tags",
"(",
")",
"{",
"$",
"s",
"=",
"$",
"nix",
"=",
"$",
"ix",
"=",
"self",
"::",
"$",
"_ar_",
";",
"$",
"ids",
"=",
"$",
"this",
"->",
"ids",
";",
"foreach",
"(",
"$",
"this",
"->",
"tags",
"as",
"$",
"id",
"... | index all tags by tagname at ids
@return array | [
"index",
"all",
"tags",
"by",
"tagname",
"at",
"ids"
] | train | https://github.com/duzun/hQuery.php/blob/3489e999f36879f69ef5e526b759b21ac5b65e44/src/hQuery/HTML_Parser.php#L559-L592 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.