repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
wp-cli/wp-cli | php/WP_CLI/SynopsisValidator.php | SynopsisValidator.query_spec | private function query_spec( $args, $operator = 'AND' ) {
$operator = strtoupper( $operator );
$count = count( $args );
$filtered = array();
foreach ( $this->spec as $key => $to_match ) {
$matched = 0;
foreach ( $args as $m_key => $m_value ) {
if ( array_key_exists( $m_key, $to_match ) && $m_value... | php | private function query_spec( $args, $operator = 'AND' ) {
$operator = strtoupper( $operator );
$count = count( $args );
$filtered = array();
foreach ( $this->spec as $key => $to_match ) {
$matched = 0;
foreach ( $args as $m_key => $m_value ) {
if ( array_key_exists( $m_key, $to_match ) && $m_value... | [
"private",
"function",
"query_spec",
"(",
"$",
"args",
",",
"$",
"operator",
"=",
"'AND'",
")",
"{",
"$",
"operator",
"=",
"strtoupper",
"(",
"$",
"operator",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"args",
")",
";",
"$",
"filtered",
"=",
"... | Filters a list of associative arrays, based on a set of key => value arguments.
@param array $args An array of key => value arguments to match against
@param string $operator
@return array | [
"Filters",
"a",
"list",
"of",
"associative",
"arrays",
"based",
"on",
"a",
"set",
"of",
"key",
"=",
">",
"value",
"arguments",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/SynopsisValidator.php#L159-L180 | train |
wp-cli/wp-cli | php/WP_CLI/Autoloader.php | Autoloader.add_namespace | public function add_namespace(
$root,
$base_dir,
$prefix = '',
$suffix = '.php',
$lowercase = false,
$underscores = false
) {
$this->namespaces[] = array(
'root' => $this->normalize_root( (string) $root ),
'base_dir' => $this->add_trailing_slash( (string) $base_dir ),
'prefix' => ... | php | public function add_namespace(
$root,
$base_dir,
$prefix = '',
$suffix = '.php',
$lowercase = false,
$underscores = false
) {
$this->namespaces[] = array(
'root' => $this->normalize_root( (string) $root ),
'base_dir' => $this->add_trailing_slash( (string) $base_dir ),
'prefix' => ... | [
"public",
"function",
"add_namespace",
"(",
"$",
"root",
",",
"$",
"base_dir",
",",
"$",
"prefix",
"=",
"''",
",",
"$",
"suffix",
"=",
"'.php'",
",",
"$",
"lowercase",
"=",
"false",
",",
"$",
"underscores",
"=",
"false",
")",
"{",
"$",
"this",
"->",
... | Add a specific namespace structure with our custom autoloader.
@param string $root Root namespace name.
@param string $base_dir Directory containing the class files.
@param string $prefix Prefix to be added before the class.
@param string $suffix Suffix to be added after the class.
@param boole... | [
"Add",
"a",
"specific",
"namespace",
"structure",
"with",
"our",
"custom",
"autoloader",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Autoloader.php#L63-L81 | train |
wp-cli/wp-cli | php/WP_CLI/Autoloader.php | Autoloader.autoload | public function autoload( $class ) {
// Iterate over namespaces to find a match.
foreach ( $this->namespaces as $namespace ) {
// Move on if the object does not belong to the current namespace.
if ( 0 !== strpos( $class, $namespace['root'] ) ) {
continue;
}
// Remove namespace root level to corre... | php | public function autoload( $class ) {
// Iterate over namespaces to find a match.
foreach ( $this->namespaces as $namespace ) {
// Move on if the object does not belong to the current namespace.
if ( 0 !== strpos( $class, $namespace['root'] ) ) {
continue;
}
// Remove namespace root level to corre... | [
"public",
"function",
"autoload",
"(",
"$",
"class",
")",
"{",
"// Iterate over namespaces to find a match.",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"// Move on if the object does not belong to the current namespace.",
"if",
"("... | The autoload function that gets registered with the SPL Autoloader
system.
@param string $class The class that got requested by the spl_autoloader. | [
"The",
"autoload",
"function",
"that",
"gets",
"registered",
"with",
"the",
"SPL",
"Autoloader",
"system",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Autoloader.php#L89-L131 | train |
wp-cli/wp-cli | php/WP_CLI/WpHttpCacheManager.php | WpHttpCacheManager.filter_pre_http_request | public function filter_pre_http_request( $response, $args, $url ) {
// check if whitelisted
if ( ! isset( $this->whitelist[ $url ] ) ) {
return $response;
}
// check if downloading
if ( 'GET' !== $args['method'] || empty( $args['filename'] ) ) {
return $response;
}
// check cache and export to desig... | php | public function filter_pre_http_request( $response, $args, $url ) {
// check if whitelisted
if ( ! isset( $this->whitelist[ $url ] ) ) {
return $response;
}
// check if downloading
if ( 'GET' !== $args['method'] || empty( $args['filename'] ) ) {
return $response;
}
// check cache and export to desig... | [
"public",
"function",
"filter_pre_http_request",
"(",
"$",
"response",
",",
"$",
"args",
",",
"$",
"url",
")",
"{",
"// check if whitelisted",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"whitelist",
"[",
"$",
"url",
"]",
")",
")",
"{",
"return",
... | short circuit wp http api with cached file | [
"short",
"circuit",
"wp",
"http",
"api",
"with",
"cached",
"file"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/WpHttpCacheManager.php#L40-L67 | train |
wp-cli/wp-cli | php/WP_CLI/WpHttpCacheManager.php | WpHttpCacheManager.filter_http_response | public function filter_http_response( $response, $args, $url ) {
// check if whitelisted
if ( ! isset( $this->whitelist[ $url ] ) ) {
return $response;
}
// check if downloading
if ( 'GET' !== $args['method'] || empty( $args['filename'] ) ) {
return $response;
}
// check if download was successful
... | php | public function filter_http_response( $response, $args, $url ) {
// check if whitelisted
if ( ! isset( $this->whitelist[ $url ] ) ) {
return $response;
}
// check if downloading
if ( 'GET' !== $args['method'] || empty( $args['filename'] ) ) {
return $response;
}
// check if download was successful
... | [
"public",
"function",
"filter_http_response",
"(",
"$",
"response",
",",
"$",
"args",
",",
"$",
"url",
")",
"{",
"// check if whitelisted",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"whitelist",
"[",
"$",
"url",
"]",
")",
")",
"{",
"return",
"$"... | cache wp http api downloads
@param array $response
@param array $args
@param string $url | [
"cache",
"wp",
"http",
"api",
"downloads"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/WpHttpCacheManager.php#L77-L93 | train |
wp-cli/wp-cli | php/WP_CLI/WpHttpCacheManager.php | WpHttpCacheManager.whitelist_package | public function whitelist_package( $url, $group, $slug, $version, $ttl = null ) {
$ext = pathinfo( Utils\parse_url( $url, PHP_URL_PATH ), PATHINFO_EXTENSION );
$key = "$group/$slug-$version.$ext";
$this->whitelist_url( $url, $key, $ttl );
wp_update_plugins();
} | php | public function whitelist_package( $url, $group, $slug, $version, $ttl = null ) {
$ext = pathinfo( Utils\parse_url( $url, PHP_URL_PATH ), PATHINFO_EXTENSION );
$key = "$group/$slug-$version.$ext";
$this->whitelist_url( $url, $key, $ttl );
wp_update_plugins();
} | [
"public",
"function",
"whitelist_package",
"(",
"$",
"url",
",",
"$",
"group",
",",
"$",
"slug",
",",
"$",
"version",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"ext",
"=",
"pathinfo",
"(",
"Utils",
"\\",
"parse_url",
"(",
"$",
"url",
",",
"PHP_U... | whitelist a package url
@param string $url
@param string $group package group (themes, plugins, ...)
@param string $slug package slug
@param string $version package version
@param int $ttl | [
"whitelist",
"a",
"package",
"url"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/WpHttpCacheManager.php#L104-L109 | train |
wp-cli/wp-cli | php/WP_CLI/WpHttpCacheManager.php | WpHttpCacheManager.whitelist_url | public function whitelist_url( $url, $key = null, $ttl = null ) {
$key = $key ? : $url;
$this->whitelist[ $url ] = compact( 'key', 'ttl' );
} | php | public function whitelist_url( $url, $key = null, $ttl = null ) {
$key = $key ? : $url;
$this->whitelist[ $url ] = compact( 'key', 'ttl' );
} | [
"public",
"function",
"whitelist_url",
"(",
"$",
"url",
",",
"$",
"key",
"=",
"null",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"?",
":",
"$",
"url",
";",
"$",
"this",
"->",
"whitelist",
"[",
"$",
"url",
"]",
"=",
"... | whitelist a url
@param string $url
@param string $key
@param int $ttl | [
"whitelist",
"a",
"url"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/WpHttpCacheManager.php#L118-L121 | train |
wp-cli/wp-cli | php/WP_CLI/Bootstrap/AutoloaderStep.php | AutoloaderStep.get_custom_vendor_folder | protected function get_custom_vendor_folder() {
$maybe_composer_json = WP_CLI_ROOT . '/../../../composer.json';
if ( ! is_readable( $maybe_composer_json ) ) {
return false;
}
$composer = json_decode( file_get_contents( $maybe_composer_json ) );
if ( ! empty( $composer->config )
&& ! empty( $composer->... | php | protected function get_custom_vendor_folder() {
$maybe_composer_json = WP_CLI_ROOT . '/../../../composer.json';
if ( ! is_readable( $maybe_composer_json ) ) {
return false;
}
$composer = json_decode( file_get_contents( $maybe_composer_json ) );
if ( ! empty( $composer->config )
&& ! empty( $composer->... | [
"protected",
"function",
"get_custom_vendor_folder",
"(",
")",
"{",
"$",
"maybe_composer_json",
"=",
"WP_CLI_ROOT",
".",
"'/../../../composer.json'",
";",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"maybe_composer_json",
")",
")",
"{",
"return",
"false",
";",
"}",
... | Get the name of the custom vendor folder as set in `composer.json`.
@return string|false Name of the custom vendor folder or false if none. | [
"Get",
"the",
"name",
"of",
"the",
"custom",
"vendor",
"folder",
"as",
"set",
"in",
"composer",
".",
"json",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Bootstrap/AutoloaderStep.php#L72-L87 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/Subcommand.php | Subcommand.get_parameters | private function get_parameters( $spec = array() ) {
$local_parameters = array_column( $spec, 'name' );
$global_parameters = array_column(
WP_CLI\SynopsisParser::parse( $this->get_global_params() ),
'name'
);
return array_unique( array_merge( $local_parameters, $global_parameters ) );
} | php | private function get_parameters( $spec = array() ) {
$local_parameters = array_column( $spec, 'name' );
$global_parameters = array_column(
WP_CLI\SynopsisParser::parse( $this->get_global_params() ),
'name'
);
return array_unique( array_merge( $local_parameters, $global_parameters ) );
} | [
"private",
"function",
"get_parameters",
"(",
"$",
"spec",
"=",
"array",
"(",
")",
")",
"{",
"$",
"local_parameters",
"=",
"array_column",
"(",
"$",
"spec",
",",
"'name'",
")",
";",
"$",
"global_parameters",
"=",
"array_column",
"(",
"WP_CLI",
"\\",
"Synop... | Get an array of parameter names, by merging the command-specific and the
global parameters.
@param array $spec Optional. Specification of the current command.
@return array Array of parameter names | [
"Get",
"an",
"array",
"of",
"parameter",
"names",
"by",
"merging",
"the",
"command",
"-",
"specific",
"and",
"the",
"global",
"parameters",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/Subcommand.php#L467-L475 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.register_early_invoke | public function register_early_invoke( $when, $command ) {
$this->early_invoke[ $when ][] = array_slice( Dispatcher\get_path( $command ), 1 );
} | php | public function register_early_invoke( $when, $command ) {
$this->early_invoke[ $when ][] = array_slice( Dispatcher\get_path( $command ), 1 );
} | [
"public",
"function",
"register_early_invoke",
"(",
"$",
"when",
",",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"early_invoke",
"[",
"$",
"when",
"]",
"[",
"]",
"=",
"array_slice",
"(",
"Dispatcher",
"\\",
"get_path",
"(",
"$",
"command",
")",
",",
... | Register a command for early invocation, generally before WordPress loads.
@param string $when Named execution hook
@param WP_CLI\Dispatcher\Subcommand $command | [
"Register",
"a",
"command",
"for",
"early",
"invocation",
"generally",
"before",
"WordPress",
"loads",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L55-L57 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.do_early_invoke | private function do_early_invoke( $when ) {
if ( ! isset( $this->early_invoke[ $when ] ) ) {
return;
}
// Search the value of @when from the command method.
$real_when = '';
$r = $this->find_command_to_run( $this->arguments );
if ( is_array( $r ) ) {
list( $command, $final_args, $cmd_path ) =... | php | private function do_early_invoke( $when ) {
if ( ! isset( $this->early_invoke[ $when ] ) ) {
return;
}
// Search the value of @when from the command method.
$real_when = '';
$r = $this->find_command_to_run( $this->arguments );
if ( is_array( $r ) ) {
list( $command, $final_args, $cmd_path ) =... | [
"private",
"function",
"do_early_invoke",
"(",
"$",
"when",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"early_invoke",
"[",
"$",
"when",
"]",
")",
")",
"{",
"return",
";",
"}",
"// Search the value of @when from the command method.",
"$",
"re... | Perform the early invocation of a command.
@param string $when Named execution hook | [
"Perform",
"the",
"early",
"invocation",
"of",
"a",
"command",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L64-L91 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.get_global_config_path | public function get_global_config_path() {
if ( getenv( 'WP_CLI_CONFIG_PATH' ) ) {
$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
$this->global_config_path_debug = 'Using global config from WP_CLI_CONFIG_PATH env var: ' . $config_path;
} else {
$config_path = Utils\ge... | php | public function get_global_config_path() {
if ( getenv( 'WP_CLI_CONFIG_PATH' ) ) {
$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
$this->global_config_path_debug = 'Using global config from WP_CLI_CONFIG_PATH env var: ' . $config_path;
} else {
$config_path = Utils\ge... | [
"public",
"function",
"get_global_config_path",
"(",
")",
"{",
"if",
"(",
"getenv",
"(",
"'WP_CLI_CONFIG_PATH'",
")",
")",
"{",
"$",
"config_path",
"=",
"getenv",
"(",
"'WP_CLI_CONFIG_PATH'",
")",
";",
"$",
"this",
"->",
"global_config_path_debug",
"=",
"'Using ... | Get the path to the global configuration YAML file.
@return string|false | [
"Get",
"the",
"path",
"to",
"the",
"global",
"configuration",
"YAML",
"file",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L98-L115 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.get_project_config_path | public function get_project_config_path() {
$config_files = array(
'wp-cli.local.yml',
'wp-cli.yml',
);
// Stop looking upward when we find we have emerged from a subdirectory
// installation into a parent installation
$project_config_path = Utils\find_file_upward(
$config_files,
getcwd(),
fun... | php | public function get_project_config_path() {
$config_files = array(
'wp-cli.local.yml',
'wp-cli.yml',
);
// Stop looking upward when we find we have emerged from a subdirectory
// installation into a parent installation
$project_config_path = Utils\find_file_upward(
$config_files,
getcwd(),
fun... | [
"public",
"function",
"get_project_config_path",
"(",
")",
"{",
"$",
"config_files",
"=",
"array",
"(",
"'wp-cli.local.yml'",
",",
"'wp-cli.yml'",
",",
")",
";",
"// Stop looking upward when we find we have emerged from a subdirectory",
"// installation into a parent installation... | Get the path to the project-specific configuration
YAML file.
wp-cli.local.yml takes priority over wp-cli.yml.
@return string|false | [
"Get",
"the",
"path",
"to",
"the",
"project",
"-",
"specific",
"configuration",
"YAML",
"file",
".",
"wp",
"-",
"cli",
".",
"local",
".",
"yml",
"takes",
"priority",
"over",
"wp",
"-",
"cli",
".",
"yml",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L124-L152 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.get_packages_dir_path | public function get_packages_dir_path() {
if ( getenv( 'WP_CLI_PACKAGES_DIR' ) ) {
$packages_dir = Utils\trailingslashit( getenv( 'WP_CLI_PACKAGES_DIR' ) );
} else {
$packages_dir = Utils\get_home_dir() . '/.wp-cli/packages/';
}
return $packages_dir;
} | php | public function get_packages_dir_path() {
if ( getenv( 'WP_CLI_PACKAGES_DIR' ) ) {
$packages_dir = Utils\trailingslashit( getenv( 'WP_CLI_PACKAGES_DIR' ) );
} else {
$packages_dir = Utils\get_home_dir() . '/.wp-cli/packages/';
}
return $packages_dir;
} | [
"public",
"function",
"get_packages_dir_path",
"(",
")",
"{",
"if",
"(",
"getenv",
"(",
"'WP_CLI_PACKAGES_DIR'",
")",
")",
"{",
"$",
"packages_dir",
"=",
"Utils",
"\\",
"trailingslashit",
"(",
"getenv",
"(",
"'WP_CLI_PACKAGES_DIR'",
")",
")",
";",
"}",
"else",... | Get the path to the packages directory
@return string | [
"Get",
"the",
"path",
"to",
"the",
"packages",
"directory"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L159-L166 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.extract_subdir_path | private static function extract_subdir_path( $index_path ) {
$index_code = file_get_contents( $index_path );
if ( ! preg_match( '|^\s*require\s*\(?\s*(.+?)/wp-blog-header\.php([\'"])|m', $index_code, $matches ) ) {
return false;
}
$wp_path_src = $matches[1] . $matches[2];
$wp_path_src = Utils\replace_pat... | php | private static function extract_subdir_path( $index_path ) {
$index_code = file_get_contents( $index_path );
if ( ! preg_match( '|^\s*require\s*\(?\s*(.+?)/wp-blog-header\.php([\'"])|m', $index_code, $matches ) ) {
return false;
}
$wp_path_src = $matches[1] . $matches[2];
$wp_path_src = Utils\replace_pat... | [
"private",
"static",
"function",
"extract_subdir_path",
"(",
"$",
"index_path",
")",
"{",
"$",
"index_code",
"=",
"file_get_contents",
"(",
"$",
"index_path",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'|^\\s*require\\s*\\(?\\s*(.+?)/wp-blog-header\\.php([\\'\"])|m'"... | Attempts to find the path to the WP installation inside index.php
@param string $index_path
@return string|false | [
"Attempts",
"to",
"find",
"the",
"path",
"to",
"the",
"WP",
"installation",
"inside",
"index",
".",
"php"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L174-L191 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.find_wp_root | private function find_wp_root() {
if ( ! empty( $this->config['path'] ) ) {
$path = $this->config['path'];
if ( ! Utils\is_path_absolute( $path ) ) {
$path = getcwd() . '/' . $path;
}
return $path;
}
if ( $this->cmd_starts_with( array( 'core', 'download' ) ) ) {
return getcwd();
}
$dir =... | php | private function find_wp_root() {
if ( ! empty( $this->config['path'] ) ) {
$path = $this->config['path'];
if ( ! Utils\is_path_absolute( $path ) ) {
$path = getcwd() . '/' . $path;
}
return $path;
}
if ( $this->cmd_starts_with( array( 'core', 'download' ) ) ) {
return getcwd();
}
$dir =... | [
"private",
"function",
"find_wp_root",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"config",
"[",
"'path'",
"]",
";",
"if",
"(",
"!",
"Utils",
... | Find the directory that contains the WordPress files.
Defaults to the current working dir.
@return string An absolute path | [
"Find",
"the",
"directory",
"that",
"contains",
"the",
"WordPress",
"files",
".",
"Defaults",
"to",
"the",
"current",
"working",
"dir",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L199-L233 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.set_wp_root | private static function set_wp_root( $path ) {
if ( ! defined( 'ABSPATH' ) ) {
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Declaring a WP native constant.
define( 'ABSPATH', Utils\normalize_path( Utils\trailingslashit( $path ) ) );
} elseif ( ! is_null( $path ) ) {... | php | private static function set_wp_root( $path ) {
if ( ! defined( 'ABSPATH' ) ) {
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Declaring a WP native constant.
define( 'ABSPATH', Utils\normalize_path( Utils\trailingslashit( $path ) ) );
} elseif ( ! is_null( $path ) ) {... | [
"private",
"static",
"function",
"set_wp_root",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'ABSPATH'",
")",
")",
"{",
"// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Declaring a WP native constant.",
"define",
"(",
... | Set WordPress root as a given path.
@param string $path | [
"Set",
"WordPress",
"root",
"as",
"a",
"given",
"path",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L240-L255 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.guess_url | private static function guess_url( $assoc_args ) {
if ( isset( $assoc_args['blog'] ) ) {
$assoc_args['url'] = $assoc_args['blog'];
}
if ( isset( $assoc_args['url'] ) ) {
$url = $assoc_args['url'];
if ( true === $url ) {
WP_CLI::warning( 'The --url parameter expects a value.' );
}
}
if ( isse... | php | private static function guess_url( $assoc_args ) {
if ( isset( $assoc_args['blog'] ) ) {
$assoc_args['url'] = $assoc_args['blog'];
}
if ( isset( $assoc_args['url'] ) ) {
$url = $assoc_args['url'];
if ( true === $url ) {
WP_CLI::warning( 'The --url parameter expects a value.' );
}
}
if ( isse... | [
"private",
"static",
"function",
"guess_url",
"(",
"$",
"assoc_args",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"assoc_args",
"[",
"'blog'",
"]",
")",
")",
"{",
"$",
"assoc_args",
"[",
"'url'",
"]",
"=",
"$",
"assoc_args",
"[",
"'blog'",
"]",
";",
"}",... | Guess which URL context WP-CLI has been invoked under.
@param array $assoc_args
@return string|false | [
"Guess",
"which",
"URL",
"context",
"WP",
"-",
"CLI",
"has",
"been",
"invoked",
"under",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L263-L280 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.find_command_to_run | public function find_command_to_run( $args ) {
$command = \WP_CLI::get_root_command();
WP_CLI::do_hook( 'find_command_to_run_pre' );
$cmd_path = array();
while ( ! empty( $args ) && $command->can_have_subcommands() ) {
$cmd_path[] = $args[0];
$full_name = implode( ' ', $cmd_path );
$subcommand = $... | php | public function find_command_to_run( $args ) {
$command = \WP_CLI::get_root_command();
WP_CLI::do_hook( 'find_command_to_run_pre' );
$cmd_path = array();
while ( ! empty( $args ) && $command->can_have_subcommands() ) {
$cmd_path[] = $args[0];
$full_name = implode( ' ', $cmd_path );
$subcommand = $... | [
"public",
"function",
"find_command_to_run",
"(",
"$",
"args",
")",
"{",
"$",
"command",
"=",
"\\",
"WP_CLI",
"::",
"get_root_command",
"(",
")",
";",
"WP_CLI",
"::",
"do_hook",
"(",
"'find_command_to_run_pre'",
")",
";",
"$",
"cmd_path",
"=",
"array",
"(",
... | Given positional arguments, find the command to execute.
@param array $args
@return array|string Command, args, and path on success; error message on failure | [
"Given",
"positional",
"arguments",
"find",
"the",
"command",
"to",
"execute",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L292-L339 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.run_command | public function run_command( $args, $assoc_args = array(), $options = array() ) {
WP_CLI::do_hook( 'before_run_command' );
if ( ! empty( $options['back_compat_conversions'] ) ) {
list( $args, $assoc_args ) = self::back_compat_conversions( $args, $assoc_args );
}
$r = $this->find_command_to_run( $args );
i... | php | public function run_command( $args, $assoc_args = array(), $options = array() ) {
WP_CLI::do_hook( 'before_run_command' );
if ( ! empty( $options['back_compat_conversions'] ) ) {
list( $args, $assoc_args ) = self::back_compat_conversions( $args, $assoc_args );
}
$r = $this->find_command_to_run( $args );
i... | [
"public",
"function",
"run_command",
"(",
"$",
"args",
",",
"$",
"assoc_args",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"WP_CLI",
"::",
"do_hook",
"(",
"'before_run_command'",
")",
";",
"if",
"(",
"!",
"empty",
"... | Find the WP-CLI command to run given arguments, and invoke it.
@param array $args Positional arguments including command name
@param array $assoc_args Associative arguments for the command.
@param array $options Configuration options for the function. | [
"Find",
"the",
"WP",
"-",
"CLI",
"command",
"to",
"run",
"given",
"arguments",
"and",
"invoke",
"it",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L348-L375 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.show_synopsis_if_composite_command | public function show_synopsis_if_composite_command() {
$r = $this->find_command_to_run( $this->arguments );
if ( is_array( $r ) ) {
list( $command ) = $r;
if ( $command->can_have_subcommands() ) {
$command->show_usage();
exit;
}
}
} | php | public function show_synopsis_if_composite_command() {
$r = $this->find_command_to_run( $this->arguments );
if ( is_array( $r ) ) {
list( $command ) = $r;
if ( $command->can_have_subcommands() ) {
$command->show_usage();
exit;
}
}
} | [
"public",
"function",
"show_synopsis_if_composite_command",
"(",
")",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"find_command_to_run",
"(",
"$",
"this",
"->",
"arguments",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"r",
")",
")",
"{",
"list",
"(",
"$",
"c... | Show synopsis if the called command is a composite command | [
"Show",
"synopsis",
"if",
"the",
"called",
"command",
"is",
"a",
"composite",
"command"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L380-L390 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.generate_ssh_command | private function generate_ssh_command( $bits, $wp_command ) {
$escaped_command = '';
// Set default values.
foreach ( array( 'scheme', 'user', 'host', 'port', 'path' ) as $bit ) {
if ( ! isset( $bits[ $bit ] ) ) {
$bits[ $bit ] = null;
}
WP_CLI::debug( 'SSH ' . $bit . ': ' . $bits[ $bit ], 'bootstr... | php | private function generate_ssh_command( $bits, $wp_command ) {
$escaped_command = '';
// Set default values.
foreach ( array( 'scheme', 'user', 'host', 'port', 'path' ) as $bit ) {
if ( ! isset( $bits[ $bit ] ) ) {
$bits[ $bit ] = null;
}
WP_CLI::debug( 'SSH ' . $bit . ': ' . $bits[ $bit ], 'bootstr... | [
"private",
"function",
"generate_ssh_command",
"(",
"$",
"bits",
",",
"$",
"wp_command",
")",
"{",
"$",
"escaped_command",
"=",
"''",
";",
"// Set default values.",
"foreach",
"(",
"array",
"(",
"'scheme'",
",",
"'user'",
",",
"'host'",
",",
"'port'",
",",
"... | Generate a shell command from the parsed connection string.
@param array $bits Parsed connection string.
@param string $wp_command WP-CLI command to run.
@return string | [
"Generate",
"a",
"shell",
"command",
"from",
"the",
"parsed",
"connection",
"string",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L486-L555 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.is_command_disabled | public function is_command_disabled( $command ) {
$path = implode( ' ', array_slice( \WP_CLI\Dispatcher\get_path( $command ), 1 ) );
return in_array( $path, $this->config['disabled_commands'], true );
} | php | public function is_command_disabled( $command ) {
$path = implode( ' ', array_slice( \WP_CLI\Dispatcher\get_path( $command ), 1 ) );
return in_array( $path, $this->config['disabled_commands'], true );
} | [
"public",
"function",
"is_command_disabled",
"(",
"$",
"command",
")",
"{",
"$",
"path",
"=",
"implode",
"(",
"' '",
",",
"array_slice",
"(",
"\\",
"WP_CLI",
"\\",
"Dispatcher",
"\\",
"get_path",
"(",
"$",
"command",
")",
",",
"1",
")",
")",
";",
"retu... | Check whether a given command is disabled by the config
@return bool | [
"Check",
"whether",
"a",
"given",
"command",
"is",
"disabled",
"by",
"the",
"config"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L562-L565 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.get_wp_config_code | public function get_wp_config_code() {
$wp_config_path = Utils\locate_wp_config();
$wp_config_code = explode( "\n", file_get_contents( $wp_config_path ) );
$found_wp_settings = false;
$lines_to_run = array();
foreach ( $wp_config_code as $line ) {
if ( preg_match( '/^\s*require.+wp-settings\.php/', $li... | php | public function get_wp_config_code() {
$wp_config_path = Utils\locate_wp_config();
$wp_config_code = explode( "\n", file_get_contents( $wp_config_path ) );
$found_wp_settings = false;
$lines_to_run = array();
foreach ( $wp_config_code as $line ) {
if ( preg_match( '/^\s*require.+wp-settings\.php/', $li... | [
"public",
"function",
"get_wp_config_code",
"(",
")",
"{",
"$",
"wp_config_path",
"=",
"Utils",
"\\",
"locate_wp_config",
"(",
")",
";",
"$",
"wp_config_code",
"=",
"explode",
"(",
"\"\\n\"",
",",
"file_get_contents",
"(",
"$",
"wp_config_path",
")",
")",
";",... | Returns wp-config.php code, skipping the loading of wp-settings.php
@return string | [
"Returns",
"wp",
"-",
"config",
".",
"php",
"code",
"skipping",
"the",
"loading",
"of",
"wp",
"-",
"settings",
".",
"php"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L572-L597 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.load_wordpress | public function load_wordpress() {
static $wp_cli_is_loaded;
// Globals not explicitly globalized in WordPress
global $site_id, $wpdb, $public, $current_site, $current_blog, $path, $shortcode_tags;
if ( ! empty( $wp_cli_is_loaded ) ) {
return;
}
$wp_cli_is_loaded = true;
WP_CLI::debug( 'Begin WordPr... | php | public function load_wordpress() {
static $wp_cli_is_loaded;
// Globals not explicitly globalized in WordPress
global $site_id, $wpdb, $public, $current_site, $current_blog, $path, $shortcode_tags;
if ( ! empty( $wp_cli_is_loaded ) ) {
return;
}
$wp_cli_is_loaded = true;
WP_CLI::debug( 'Begin WordPr... | [
"public",
"function",
"load_wordpress",
"(",
")",
"{",
"static",
"$",
"wp_cli_is_loaded",
";",
"// Globals not explicitly globalized in WordPress",
"global",
"$",
"site_id",
",",
"$",
"wpdb",
",",
"$",
"public",
",",
"$",
"current_site",
",",
"$",
"current_blog",
... | Load WordPress, if it hasn't already been loaded | [
"Load",
"WordPress",
"if",
"it",
"hasn",
"t",
"already",
"been",
"loaded"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L1139-L1237 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.setup_skip_plugins_filters | private function setup_skip_plugins_filters() {
$wp_cli_filter_active_plugins = function( $plugins ) {
$skipped_plugins = WP_CLI::get_runner()->config['skip-plugins'];
if ( true === $skipped_plugins ) {
return array();
}
if ( ! is_array( $plugins ) ) {
return $plugins;
}
foreach ( $plugins a... | php | private function setup_skip_plugins_filters() {
$wp_cli_filter_active_plugins = function( $plugins ) {
$skipped_plugins = WP_CLI::get_runner()->config['skip-plugins'];
if ( true === $skipped_plugins ) {
return array();
}
if ( ! is_array( $plugins ) ) {
return $plugins;
}
foreach ( $plugins a... | [
"private",
"function",
"setup_skip_plugins_filters",
"(",
")",
"{",
"$",
"wp_cli_filter_active_plugins",
"=",
"function",
"(",
"$",
"plugins",
")",
"{",
"$",
"skipped_plugins",
"=",
"WP_CLI",
"::",
"get_runner",
"(",
")",
"->",
"config",
"[",
"'skip-plugins'",
"... | Set up the filters to skip the loaded plugins | [
"Set",
"up",
"the",
"filters",
"to",
"skip",
"the",
"loaded",
"plugins"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L1535-L1578 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.action_setup_theme_wp_cli_skip_themes | public function action_setup_theme_wp_cli_skip_themes() {
$wp_cli_filter_active_theme = function( $value ) {
$skipped_themes = WP_CLI::get_runner()->config['skip-themes'];
if ( true === $skipped_themes ) {
return '';
}
if ( ! is_array( $skipped_themes ) ) {
$skipped_themes = explode( ',', $skipped... | php | public function action_setup_theme_wp_cli_skip_themes() {
$wp_cli_filter_active_theme = function( $value ) {
$skipped_themes = WP_CLI::get_runner()->config['skip-themes'];
if ( true === $skipped_themes ) {
return '';
}
if ( ! is_array( $skipped_themes ) ) {
$skipped_themes = explode( ',', $skipped... | [
"public",
"function",
"action_setup_theme_wp_cli_skip_themes",
"(",
")",
"{",
"$",
"wp_cli_filter_active_theme",
"=",
"function",
"(",
"$",
"value",
")",
"{",
"$",
"skipped_themes",
"=",
"WP_CLI",
"::",
"get_runner",
"(",
")",
"->",
"config",
"[",
"'skip-themes'",... | Set up the filters to skip the loaded theme | [
"Set",
"up",
"the",
"filters",
"to",
"skip",
"the",
"loaded",
"theme"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L1583-L1624 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.auto_check_update | private function auto_check_update() {
// `wp cli update` only works with Phars at this time.
if ( ! Utils\inside_phar() ) {
return;
}
$existing_phar = realpath( $_SERVER['argv'][0] );
// Phar needs to be writable to be easily updateable.
if ( ! is_writable( $existing_phar ) || ! is_writable( dirname( ... | php | private function auto_check_update() {
// `wp cli update` only works with Phars at this time.
if ( ! Utils\inside_phar() ) {
return;
}
$existing_phar = realpath( $_SERVER['argv'][0] );
// Phar needs to be writable to be easily updateable.
if ( ! is_writable( $existing_phar ) || ! is_writable( dirname( ... | [
"private",
"function",
"auto_check_update",
"(",
")",
"{",
"// `wp cli update` only works with Phars at this time.",
"if",
"(",
"!",
"Utils",
"\\",
"inside_phar",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"existing_phar",
"=",
"realpath",
"(",
"$",
"_SERVER",
... | Check whether there's a WP-CLI update available, and suggest update if so. | [
"Check",
"whether",
"there",
"s",
"a",
"WP",
"-",
"CLI",
"update",
"available",
"and",
"suggest",
"update",
"if",
"so",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L1660-L1723 | train |
wp-cli/wp-cli | php/WP_CLI/Runner.php | Runner.enumerate_commands | private function enumerate_commands( CompositeCommand $command, array &$list, $parent = '' ) {
foreach ( $command->get_subcommands() as $subcommand ) {
/** @var CompositeCommand $subcommand */
$command_string = empty( $parent )
? $subcommand->get_name()
: "{$parent} {$subcommand->get_name()}";
$list... | php | private function enumerate_commands( CompositeCommand $command, array &$list, $parent = '' ) {
foreach ( $command->get_subcommands() as $subcommand ) {
/** @var CompositeCommand $subcommand */
$command_string = empty( $parent )
? $subcommand->get_name()
: "{$parent} {$subcommand->get_name()}";
$list... | [
"private",
"function",
"enumerate_commands",
"(",
"CompositeCommand",
"$",
"command",
",",
"array",
"&",
"$",
"list",
",",
"$",
"parent",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"command",
"->",
"get_subcommands",
"(",
")",
"as",
"$",
"subcommand",
")",
... | Recursive method to enumerate all known commands.
@param CompositeCommand $command Composite command to recurse over.
@param array $list Reference to list accumulating results.
@param string $parent Parent command to use as prefix. | [
"Recursive",
"method",
"to",
"enumerate",
"all",
"known",
"commands",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Runner.php#L1750-L1761 | train |
wp-cli/wp-cli | php/WP_CLI/Extractor.php | Extractor.extract | public static function extract( $tarball_or_zip, $dest ) {
if ( preg_match( '/\.zip$/', $tarball_or_zip ) ) {
return self::extract_zip( $tarball_or_zip, $dest );
}
if ( preg_match( '/\.tar\.gz$/', $tarball_or_zip ) ) {
return self::extract_tarball( $tarball_or_zip, $dest );
}
throw new \Exception( "Ext... | php | public static function extract( $tarball_or_zip, $dest ) {
if ( preg_match( '/\.zip$/', $tarball_or_zip ) ) {
return self::extract_zip( $tarball_or_zip, $dest );
}
if ( preg_match( '/\.tar\.gz$/', $tarball_or_zip ) ) {
return self::extract_tarball( $tarball_or_zip, $dest );
}
throw new \Exception( "Ext... | [
"public",
"static",
"function",
"extract",
"(",
"$",
"tarball_or_zip",
",",
"$",
"dest",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/\\.zip$/'",
",",
"$",
"tarball_or_zip",
")",
")",
"{",
"return",
"self",
"::",
"extract_zip",
"(",
"$",
"tarball_or_zip",
",... | Extract the archive file to a specific destination.
@param string $dest | [
"Extract",
"the",
"archive",
"file",
"to",
"a",
"specific",
"destination",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Extractor.php#L23-L32 | train |
wp-cli/wp-cli | php/WP_CLI/Extractor.php | Extractor.extract_zip | private static function extract_zip( $zipfile, $dest ) {
if ( ! class_exists( 'ZipArchive' ) ) {
throw new \Exception( 'Extracting a zip file requires ZipArchive.' );
}
$zip = new ZipArchive();
$res = $zip->open( $zipfile );
if ( true === $res ) {
$tempdir = implode(
DIRECTORY_SEPARATOR,
array(
... | php | private static function extract_zip( $zipfile, $dest ) {
if ( ! class_exists( 'ZipArchive' ) ) {
throw new \Exception( 'Extracting a zip file requires ZipArchive.' );
}
$zip = new ZipArchive();
$res = $zip->open( $zipfile );
if ( true === $res ) {
$tempdir = implode(
DIRECTORY_SEPARATOR,
array(
... | [
"private",
"static",
"function",
"extract_zip",
"(",
"$",
"zipfile",
",",
"$",
"dest",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'ZipArchive'",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Extracting a zip file requires ZipArchive.'",
")",
";... | Extract a ZIP file to a specific destination.
@param string $zipfile
@param string $dest | [
"Extract",
"a",
"ZIP",
"file",
"to",
"a",
"specific",
"destination",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Extractor.php#L40-L64 | train |
wp-cli/wp-cli | php/WP_CLI/Extractor.php | Extractor.extract_tarball | private static function extract_tarball( $tarball, $dest ) {
if ( class_exists( 'PharData' ) ) {
try {
$phar = new PharData( $tarball );
$tempdir = implode(
DIRECTORY_SEPARATOR,
array(
dirname( $tarball ),
Utils\basename( $tarball, '.tar.gz' ),
$phar->getFilename(),
)
... | php | private static function extract_tarball( $tarball, $dest ) {
if ( class_exists( 'PharData' ) ) {
try {
$phar = new PharData( $tarball );
$tempdir = implode(
DIRECTORY_SEPARATOR,
array(
dirname( $tarball ),
Utils\basename( $tarball, '.tar.gz' ),
$phar->getFilename(),
)
... | [
"private",
"static",
"function",
"extract_tarball",
"(",
"$",
"tarball",
",",
"$",
"dest",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'PharData'",
")",
")",
"{",
"try",
"{",
"$",
"phar",
"=",
"new",
"PharData",
"(",
"$",
"tarball",
")",
";",
"$",
"te... | Extract a tarball to a specific destination.
@param string $tarball
@param string $dest | [
"Extract",
"a",
"tarball",
"to",
"a",
"specific",
"destination",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Extractor.php#L72-L103 | train |
wp-cli/wp-cli | php/WP_CLI/Extractor.php | Extractor.copy_overwrite_files | public static function copy_overwrite_files( $source, $dest ) {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $source, RecursiveDirectoryIterator::SKIP_DOTS ),
RecursiveIteratorIterator::SELF_FIRST
);
$error = 0;
if ( ! is_dir( $dest ) ) {
mkdir( $dest, 0777, true );
}
... | php | public static function copy_overwrite_files( $source, $dest ) {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $source, RecursiveDirectoryIterator::SKIP_DOTS ),
RecursiveIteratorIterator::SELF_FIRST
);
$error = 0;
if ( ! is_dir( $dest ) ) {
mkdir( $dest, 0777, true );
}
... | [
"public",
"static",
"function",
"copy_overwrite_files",
"(",
"$",
"source",
",",
"$",
"dest",
")",
"{",
"$",
"iterator",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"source",
",",
"RecursiveDirectoryIterator",
"::",
... | Copy files from source directory to destination directory. Source directory must exist.
@param string $source
@param string $dest | [
"Copy",
"files",
"from",
"source",
"directory",
"to",
"destination",
"directory",
".",
"Source",
"directory",
"must",
"exist",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Extractor.php#L111-L146 | train |
wp-cli/wp-cli | php/WP_CLI/Extractor.php | Extractor.rmdir | public static function rmdir( $dir ) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ( $files as $fileinfo ) {
$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
$todo( $fileinfo->... | php | public static function rmdir( $dir ) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ( $files as $fileinfo ) {
$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
$todo( $fileinfo->... | [
"public",
"static",
"function",
"rmdir",
"(",
"$",
"dir",
")",
"{",
"$",
"files",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"dir",
",",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
",",
"RecursiveIterator... | Delete all files and directories recursively from directory. Directory must exist.
@param string $dir | [
"Delete",
"all",
"files",
"and",
"directories",
"recursively",
"from",
"directory",
".",
"Directory",
"must",
"exist",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Extractor.php#L153-L164 | train |
wp-cli/wp-cli | php/WP_CLI/Extractor.php | Extractor.zip_error_msg | public static function zip_error_msg( $error_code ) {
// From https://github.com/php/php-src/blob/php-5.3.0/ext/zip/php_zip.c#L2623-L2646
static $zip_err_msgs = array(
ZipArchive::ER_OK => 'No error',
ZipArchive::ER_MULTIDISK => 'Multi-disk zip archives not supported',
ZipArchive::ER_RENAME ... | php | public static function zip_error_msg( $error_code ) {
// From https://github.com/php/php-src/blob/php-5.3.0/ext/zip/php_zip.c#L2623-L2646
static $zip_err_msgs = array(
ZipArchive::ER_OK => 'No error',
ZipArchive::ER_MULTIDISK => 'Multi-disk zip archives not supported',
ZipArchive::ER_RENAME ... | [
"public",
"static",
"function",
"zip_error_msg",
"(",
"$",
"error_code",
")",
"{",
"// From https://github.com/php/php-src/blob/php-5.3.0/ext/zip/php_zip.c#L2623-L2646",
"static",
"$",
"zip_err_msgs",
"=",
"array",
"(",
"ZipArchive",
"::",
"ER_OK",
"=>",
"'No error'",
",",
... | Return formatted ZipArchive error message from error code.
@param int $error_code
@return string|int The error message corresponding to the specified code, if found;
Other wise the same error code, unmodified. | [
"Return",
"formatted",
"ZipArchive",
"error",
"message",
"from",
"error",
"code",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Extractor.php#L173-L206 | train |
wp-cli/wp-cli | php/WP_CLI/Extractor.php | Extractor.tar_error_msg | public static function tar_error_msg( $process_run ) {
$stderr = trim( $process_run->stderr );
$nl_pos = strpos( $stderr, "\n" );
if ( false !== $nl_pos ) {
$stderr = trim( substr( $stderr, 0, $nl_pos ) );
}
if ( $stderr ) {
return sprintf( '%s (%d)', $stderr, $process_run->return_code );
}
return $... | php | public static function tar_error_msg( $process_run ) {
$stderr = trim( $process_run->stderr );
$nl_pos = strpos( $stderr, "\n" );
if ( false !== $nl_pos ) {
$stderr = trim( substr( $stderr, 0, $nl_pos ) );
}
if ( $stderr ) {
return sprintf( '%s (%d)', $stderr, $process_run->return_code );
}
return $... | [
"public",
"static",
"function",
"tar_error_msg",
"(",
"$",
"process_run",
")",
"{",
"$",
"stderr",
"=",
"trim",
"(",
"$",
"process_run",
"->",
"stderr",
")",
";",
"$",
"nl_pos",
"=",
"strpos",
"(",
"$",
"stderr",
",",
"\"\\n\"",
")",
";",
"if",
"(",
... | Return formatted error message from ProcessRun of tar command.
@param Processrun $process_run
@return string|int The error message of the process, if available;
otherwise the return code. | [
"Return",
"formatted",
"error",
"message",
"from",
"ProcessRun",
"of",
"tar",
"command",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Extractor.php#L215-L225 | train |
wp-cli/wp-cli | php/WP_CLI/Loggers/Base.php | Base._line | protected function _line( $message, $label, $color, $handle = STDOUT ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- Used in third party extensions.
if ( class_exists( 'cli\Colors' ) ) {
$label = \cli\Colors::colorize( "$color$label:%n", $this->in_color );
} else {
$label = "$label:";
}
$... | php | protected function _line( $message, $label, $color, $handle = STDOUT ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- Used in third party extensions.
if ( class_exists( 'cli\Colors' ) ) {
$label = \cli\Colors::colorize( "$color$label:%n", $this->in_color );
} else {
$label = "$label:";
}
$... | [
"protected",
"function",
"_line",
"(",
"$",
"message",
",",
"$",
"label",
",",
"$",
"color",
",",
"$",
"handle",
"=",
"STDOUT",
")",
"{",
"// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- Used in third party extensions.",
"if",
"(",
"class_exists",
"(",
"'... | Output one line of message to a resource.
@param string $message Message to write.
@param string $label Prefix message with a label.
@param string $color Colorize label with a given color.
@param resource $handle Resource to write to. Defaults to STDOUT. | [
"Output",
"one",
"line",
"of",
"message",
"to",
"a",
"resource",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Loggers/Base.php#L75-L82 | train |
wp-cli/wp-cli | php/WP_CLI/Bootstrap/InitializeLogger.php | InitializeLogger.declare_loggers | private function declare_loggers() {
$logger_dir = WP_CLI_ROOT . '/php/WP_CLI/Loggers';
$iterator = new \DirectoryIterator( $logger_dir );
// Make sure the base class is declared first.
include_once "$logger_dir/Base.php";
foreach ( $iterator as $filename ) {
if ( '.php' !== substr( $filename, - 4 ) ) ... | php | private function declare_loggers() {
$logger_dir = WP_CLI_ROOT . '/php/WP_CLI/Loggers';
$iterator = new \DirectoryIterator( $logger_dir );
// Make sure the base class is declared first.
include_once "$logger_dir/Base.php";
foreach ( $iterator as $filename ) {
if ( '.php' !== substr( $filename, - 4 ) ) ... | [
"private",
"function",
"declare_loggers",
"(",
")",
"{",
"$",
"logger_dir",
"=",
"WP_CLI_ROOT",
".",
"'/php/WP_CLI/Loggers'",
";",
"$",
"iterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"logger_dir",
")",
";",
"// Make sure the base class is declared first.... | Load the class declarations for the loggers. | [
"Load",
"the",
"class",
"declarations",
"for",
"the",
"loggers",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Bootstrap/InitializeLogger.php#L32-L46 | train |
wp-cli/wp-cli | php/commands/src/CLI_Cache_Command.php | CLI_Cache_Command.cache_clear | public function cache_clear() {
$cache = WP_CLI::get_cache();
if ( ! $cache->is_enabled() ) {
WP_CLI::error( 'Cache directory does not exist.' );
}
$cache->clear();
WP_CLI::success( 'Cache cleared.' );
} | php | public function cache_clear() {
$cache = WP_CLI::get_cache();
if ( ! $cache->is_enabled() ) {
WP_CLI::error( 'Cache directory does not exist.' );
}
$cache->clear();
WP_CLI::success( 'Cache cleared.' );
} | [
"public",
"function",
"cache_clear",
"(",
")",
"{",
"$",
"cache",
"=",
"WP_CLI",
"::",
"get_cache",
"(",
")",
";",
"if",
"(",
"!",
"$",
"cache",
"->",
"is_enabled",
"(",
")",
")",
"{",
"WP_CLI",
"::",
"error",
"(",
"'Cache directory does not exist.'",
")... | Clear the internal cache.
## EXAMPLES
$ wp cli cache clear
Success: Cache cleared.
@subcommand clear | [
"Clear",
"the",
"internal",
"cache",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Cache_Command.php#L30-L40 | train |
wp-cli/wp-cli | php/commands/src/CLI_Cache_Command.php | CLI_Cache_Command.cache_prune | public function cache_prune() {
$cache = WP_CLI::get_cache();
if ( ! $cache->is_enabled() ) {
WP_CLI::error( 'Cache directory does not exist.' );
}
$cache->prune();
WP_CLI::success( 'Cache pruned.' );
} | php | public function cache_prune() {
$cache = WP_CLI::get_cache();
if ( ! $cache->is_enabled() ) {
WP_CLI::error( 'Cache directory does not exist.' );
}
$cache->prune();
WP_CLI::success( 'Cache pruned.' );
} | [
"public",
"function",
"cache_prune",
"(",
")",
"{",
"$",
"cache",
"=",
"WP_CLI",
"::",
"get_cache",
"(",
")",
";",
"if",
"(",
"!",
"$",
"cache",
"->",
"is_enabled",
"(",
")",
")",
"{",
"WP_CLI",
"::",
"error",
"(",
"'Cache directory does not exist.'",
")... | Prune the internal cache.
Removes all cached files except for the newest version of each one.
## EXAMPLES
$ wp cli cache prune
Success: Cache pruned.
@subcommand prune | [
"Prune",
"the",
"internal",
"cache",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Cache_Command.php#L54-L64 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/RootCommand.php | RootCommand.find_subcommand | public function find_subcommand( &$args ) {
$command = array_shift( $args );
Utils\load_command( $command );
if ( ! isset( $this->subcommands[ $command ] ) ) {
return false;
}
return $this->subcommands[ $command ];
} | php | public function find_subcommand( &$args ) {
$command = array_shift( $args );
Utils\load_command( $command );
if ( ! isset( $this->subcommands[ $command ] ) ) {
return false;
}
return $this->subcommands[ $command ];
} | [
"public",
"function",
"find_subcommand",
"(",
"&",
"$",
"args",
")",
"{",
"$",
"command",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"Utils",
"\\",
"load_command",
"(",
"$",
"command",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
... | Find a subcommand registered on the root
command.
@param array $args
@return \WP_CLI\Dispatcher\Subcommand|false | [
"Find",
"a",
"subcommand",
"registered",
"on",
"the",
"root",
"command",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/RootCommand.php#L38-L48 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/CommandFactory.php | CommandFactory.create_subcommand | private static function create_subcommand( $parent, $name, $callable, $reflection ) {
$doc_comment = self::get_doc_comment( $reflection );
$docparser = new \WP_CLI\DocParser( $doc_comment );
if ( is_array( $callable ) ) {
if ( ! $name ) {
$name = $docparser->get_tag( 'subcommand' );
}
if ( ! $nam... | php | private static function create_subcommand( $parent, $name, $callable, $reflection ) {
$doc_comment = self::get_doc_comment( $reflection );
$docparser = new \WP_CLI\DocParser( $doc_comment );
if ( is_array( $callable ) ) {
if ( ! $name ) {
$name = $docparser->get_tag( 'subcommand' );
}
if ( ! $nam... | [
"private",
"static",
"function",
"create_subcommand",
"(",
"$",
"parent",
",",
"$",
"name",
",",
"$",
"callable",
",",
"$",
"reflection",
")",
"{",
"$",
"doc_comment",
"=",
"self",
"::",
"get_doc_comment",
"(",
"$",
"reflection",
")",
";",
"$",
"docparser"... | Create a new Subcommand instance.
@param mixed $parent The new command's parent Composite command
@param string|bool $name Represents how the command should be invoked.
If false, will be determined from the documented subject, represented by `$reflection`.
@param mixed $callable A callable function or closure, or clas... | [
"Create",
"a",
"new",
"Subcommand",
"instance",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/CommandFactory.php#L78-L105 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/CommandFactory.php | CommandFactory.create_composite_command | private static function create_composite_command( $parent, $name, $callable ) {
$reflection = new ReflectionClass( $callable );
$doc_comment = self::get_doc_comment( $reflection );
if ( ! $doc_comment ) {
\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$... | php | private static function create_composite_command( $parent, $name, $callable ) {
$reflection = new ReflectionClass( $callable );
$doc_comment = self::get_doc_comment( $reflection );
if ( ! $doc_comment ) {
\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$... | [
"private",
"static",
"function",
"create_composite_command",
"(",
"$",
"parent",
",",
"$",
"name",
",",
"$",
"callable",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"callable",
")",
";",
"$",
"doc_comment",
"=",
"self",
"::",
"get... | Create a new Composite command instance.
@param mixed $parent The new command's parent Root or Composite command
@param string $name Represents how the command should be invoked
@param mixed $callable | [
"Create",
"a",
"new",
"Composite",
"command",
"instance",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/CommandFactory.php#L114-L138 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/CommandFactory.php | CommandFactory.create_namespace | private static function create_namespace( $parent, $name, $callable ) {
$reflection = new ReflectionClass( $callable );
$doc_comment = self::get_doc_comment( $reflection );
if ( ! $doc_comment ) {
\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.",... | php | private static function create_namespace( $parent, $name, $callable ) {
$reflection = new ReflectionClass( $callable );
$doc_comment = self::get_doc_comment( $reflection );
if ( ! $doc_comment ) {
\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.",... | [
"private",
"static",
"function",
"create_namespace",
"(",
"$",
"parent",
",",
"$",
"name",
",",
"$",
"callable",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"callable",
")",
";",
"$",
"doc_comment",
"=",
"self",
"::",
"get_doc_com... | Create a new command namespace instance.
@param mixed $parent The new namespace's parent Root or Composite command.
@param string $name Represents how the command should be invoked
@param mixed $callable | [
"Create",
"a",
"new",
"command",
"namespace",
"instance",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/CommandFactory.php#L147-L156 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/CommandFactory.php | CommandFactory.get_doc_comment | private static function get_doc_comment( $reflection ) {
$doc_comment = $reflection->getDocComment();
if ( false !== $doc_comment || ! ( ini_get( 'opcache.enable_cli' ) && ! ini_get( 'opcache.save_comments' ) ) ) {
// Either have doc comment, or no doc comment and save comments enabled - standard situation.
... | php | private static function get_doc_comment( $reflection ) {
$doc_comment = $reflection->getDocComment();
if ( false !== $doc_comment || ! ( ini_get( 'opcache.enable_cli' ) && ! ini_get( 'opcache.save_comments' ) ) ) {
// Either have doc comment, or no doc comment and save comments enabled - standard situation.
... | [
"private",
"static",
"function",
"get_doc_comment",
"(",
"$",
"reflection",
")",
"{",
"$",
"doc_comment",
"=",
"$",
"reflection",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"doc_comment",
"||",
"!",
"(",
"ini_get",
"(",
"'opcache... | Gets the document comment. Caters for PHP directive `opcache.save comments` being disabled.
@param ReflectionMethod|ReflectionClass|ReflectionFunction $reflection Reflection instance.
@return string|false|null Doc comment string if any, false if none (same as `Reflection*::getDocComment()`), null if error. | [
"Gets",
"the",
"document",
"comment",
".",
"Caters",
"for",
"PHP",
"directive",
"opcache",
".",
"save",
"comments",
"being",
"disabled",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/CommandFactory.php#L174-L202 | train |
wp-cli/wp-cli | php/WP_CLI/Formatter.php | Formatter.display_item | public function display_item( $item, $ascii_pre_colorized = false ) {
if ( isset( $this->args['field'] ) ) {
$item = (object) $item;
$key = $this->find_item_key( $item, $this->args['field'] );
$value = $item->$key;
if ( in_array( $this->args['format'], array( 'table', 'csv' ), true ) && ( is_object( $v... | php | public function display_item( $item, $ascii_pre_colorized = false ) {
if ( isset( $this->args['field'] ) ) {
$item = (object) $item;
$key = $this->find_item_key( $item, $this->args['field'] );
$value = $item->$key;
if ( in_array( $this->args['format'], array( 'table', 'csv' ), true ) && ( is_object( $v... | [
"public",
"function",
"display_item",
"(",
"$",
"item",
",",
"$",
"ascii_pre_colorized",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"args",
"[",
"'field'",
"]",
")",
")",
"{",
"$",
"item",
"=",
"(",
"object",
")",
"$",
"ite... | Display a single item according to the output arguments.
@param mixed $item
@param bool|array $ascii_pre_colorized Optional. A boolean or an array of booleans to pass to `show_multiple_fields()` if the item in the table is pre-colorized. Default false. | [
"Display",
"a",
"single",
"item",
"according",
"to",
"the",
"output",
"arguments",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Formatter.php#L100-L117 | train |
wp-cli/wp-cli | php/WP_CLI/Formatter.php | Formatter.format | private function format( $items, $ascii_pre_colorized = false ) {
$fields = $this->args['fields'];
switch ( $this->args['format'] ) {
case 'count':
if ( ! is_array( $items ) ) {
$items = iterator_to_array( $items );
}
echo count( $items );
break;
case 'ids':
if ( ! is_array( $items ... | php | private function format( $items, $ascii_pre_colorized = false ) {
$fields = $this->args['fields'];
switch ( $this->args['format'] ) {
case 'count':
if ( ! is_array( $items ) ) {
$items = iterator_to_array( $items );
}
echo count( $items );
break;
case 'ids':
if ( ! is_array( $items ... | [
"private",
"function",
"format",
"(",
"$",
"items",
",",
"$",
"ascii_pre_colorized",
"=",
"false",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"args",
"[",
"'fields'",
"]",
";",
"switch",
"(",
"$",
"this",
"->",
"args",
"[",
"'format'",
"]",
")"... | Format items according to arguments.
@param array $items
@param bool|array $ascii_pre_colorized Optional. A boolean or an array of booleans to pass to `show_table()` if items in the table are pre-colorized. Default false. | [
"Format",
"items",
"according",
"to",
"arguments",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Formatter.php#L125-L173 | train |
wp-cli/wp-cli | php/WP_CLI/Formatter.php | Formatter.show_single_field | private function show_single_field( $items, $field ) {
$key = null;
$values = array();
foreach ( $items as $item ) {
$item = (object) $item;
if ( null === $key ) {
$key = $this->find_item_key( $item, $field );
}
if ( 'json' === $this->args['format'] ) {
$values[] = $item->$key;
} else... | php | private function show_single_field( $items, $field ) {
$key = null;
$values = array();
foreach ( $items as $item ) {
$item = (object) $item;
if ( null === $key ) {
$key = $this->find_item_key( $item, $field );
}
if ( 'json' === $this->args['format'] ) {
$values[] = $item->$key;
} else... | [
"private",
"function",
"show_single_field",
"(",
"$",
"items",
",",
"$",
"field",
")",
"{",
"$",
"key",
"=",
"null",
";",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"item",
"=",
"("... | Show a single field from a list of items.
@param array Array of objects to show fields from
@param string The field to show | [
"Show",
"a",
"single",
"field",
"from",
"a",
"list",
"of",
"items",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Formatter.php#L181-L207 | train |
wp-cli/wp-cli | php/WP_CLI/Formatter.php | Formatter.show_multiple_fields | private function show_multiple_fields( $data, $format, $ascii_pre_colorized = false ) {
$true_fields = array();
foreach ( $this->args['fields'] as $field ) {
$true_fields[] = $this->find_item_key( $data, $field );
}
foreach ( $data as $key => $value ) {
if ( ! in_array( $key, $true_fields, true ) ) {
... | php | private function show_multiple_fields( $data, $format, $ascii_pre_colorized = false ) {
$true_fields = array();
foreach ( $this->args['fields'] as $field ) {
$true_fields[] = $this->find_item_key( $data, $field );
}
foreach ( $data as $key => $value ) {
if ( ! in_array( $key, $true_fields, true ) ) {
... | [
"private",
"function",
"show_multiple_fields",
"(",
"$",
"data",
",",
"$",
"format",
",",
"$",
"ascii_pre_colorized",
"=",
"false",
")",
"{",
"$",
"true_fields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"args",
"[",
"'fields'",
"]"... | Show multiple fields of an object.
@param object|array $data Data to display
@param string $format Format to display the data in
@param bool|array $ascii_pre_colorized Optional. A boolean or an array of booleans to pass to `show_table()` if the item in the table is pre-colorized. De... | [
"Show",
"multiple",
"fields",
"of",
"an",
"object",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Formatter.php#L239-L285 | train |
wp-cli/wp-cli | php/WP_CLI/Formatter.php | Formatter.assoc_array_to_rows | private function assoc_array_to_rows( $fields ) {
$rows = array();
foreach ( $fields as $field => $value ) {
if ( ! is_string( $value ) ) {
$value = json_encode( $value );
}
$rows[] = (object) array(
'Field' => $field,
'Value' => $value,
);
}
return $rows;
} | php | private function assoc_array_to_rows( $fields ) {
$rows = array();
foreach ( $fields as $field => $value ) {
if ( ! is_string( $value ) ) {
$value = json_encode( $value );
}
$rows[] = (object) array(
'Field' => $field,
'Value' => $value,
);
}
return $rows;
} | [
"private",
"function",
"assoc_array_to_rows",
"(",
"$",
"fields",
")",
"{",
"$",
"rows",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
"... | Format an associative array as a table.
@param array $fields Fields and values to format
@return array $rows | [
"Format",
"an",
"associative",
"array",
"as",
"a",
"table",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Formatter.php#L324-L340 | train |
wp-cli/wp-cli | php/WP_CLI/Formatter.php | Formatter.transform_item_values_to_json | public function transform_item_values_to_json( $item ) {
foreach ( $this->args['fields'] as $field ) {
$true_field = $this->find_item_key( $item, $field );
$value = is_object( $item ) ? $item->$true_field : $item[ $true_field ];
if ( is_array( $value ) || is_object( $value ) ) {
if ( is_object( $ite... | php | public function transform_item_values_to_json( $item ) {
foreach ( $this->args['fields'] as $field ) {
$true_field = $this->find_item_key( $item, $field );
$value = is_object( $item ) ? $item->$true_field : $item[ $true_field ];
if ( is_array( $value ) || is_object( $value ) ) {
if ( is_object( $ite... | [
"public",
"function",
"transform_item_values_to_json",
"(",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"args",
"[",
"'fields'",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"true_field",
"=",
"$",
"this",
"->",
"find_item_key",
"(",
"$",
"item"... | Transforms objects and arrays to JSON as necessary
@param mixed $item
@return mixed | [
"Transforms",
"objects",
"and",
"arrays",
"to",
"JSON",
"as",
"necessary"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Formatter.php#L348-L361 | train |
wp-cli/wp-cli | php/commands/src/Help_Command.php | Help_Command.parse_reference_links | private static function parse_reference_links( $longdesc ) {
$description = '';
foreach ( explode( "\n", $longdesc ) as $line ) {
if ( 0 === strpos( $line, '#' ) ) {
break;
}
$description .= $line . "\n";
}
// Fires if it has description text at the head of `$longdesc`.
if ( $description ) {
... | php | private static function parse_reference_links( $longdesc ) {
$description = '';
foreach ( explode( "\n", $longdesc ) as $line ) {
if ( 0 === strpos( $line, '#' ) ) {
break;
}
$description .= $line . "\n";
}
// Fires if it has description text at the head of `$longdesc`.
if ( $description ) {
... | [
"private",
"static",
"function",
"parse_reference_links",
"(",
"$",
"longdesc",
")",
"{",
"$",
"description",
"=",
"''",
";",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"longdesc",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"0",
"===",
"str... | Parse reference links from longdescription.
@param string $longdesc The longdescription from the `$command->get_longdesc()`.
@return string The longdescription which has links as footnote. | [
"Parse",
"reference",
"links",
"from",
"longdescription",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/Help_Command.php#L206-L244 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/CompositeCommand.php | CompositeCommand.show_usage | public function show_usage() {
$methods = $this->get_subcommands();
$i = 0;
foreach ( $methods as $name => $subcommand ) {
$prefix = ( 0 === $i ) ? 'usage: ' : ' or: ';
$i++;
if ( \WP_CLI::get_runner()->is_command_disabled( $subcommand ) ) {
continue;
}
\WP_CLI::line( $subcommand->get_usa... | php | public function show_usage() {
$methods = $this->get_subcommands();
$i = 0;
foreach ( $methods as $name => $subcommand ) {
$prefix = ( 0 === $i ) ? 'usage: ' : ' or: ';
$i++;
if ( \WP_CLI::get_runner()->is_command_disabled( $subcommand ) ) {
continue;
}
\WP_CLI::line( $subcommand->get_usa... | [
"public",
"function",
"show_usage",
"(",
")",
"{",
"$",
"methods",
"=",
"$",
"this",
"->",
"get_subcommands",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"name",
"=>",
"$",
"subcommand",
")",
"{",
"$",
"prefix... | Show the usage for all subcommands contained
by the composite command. | [
"Show",
"the",
"usage",
"for",
"all",
"subcommands",
"contained",
"by",
"the",
"composite",
"command",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/CompositeCommand.php#L176-L196 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/CompositeCommand.php | CompositeCommand.find_subcommand | public function find_subcommand( &$args ) {
$name = array_shift( $args );
$subcommands = $this->get_subcommands();
if ( ! isset( $subcommands[ $name ] ) ) {
$aliases = self::get_aliases( $subcommands );
if ( isset( $aliases[ $name ] ) ) {
$name = $aliases[ $name ];
}
}
if ( ! isset( $subcomma... | php | public function find_subcommand( &$args ) {
$name = array_shift( $args );
$subcommands = $this->get_subcommands();
if ( ! isset( $subcommands[ $name ] ) ) {
$aliases = self::get_aliases( $subcommands );
if ( isset( $aliases[ $name ] ) ) {
$name = $aliases[ $name ];
}
}
if ( ! isset( $subcomma... | [
"public",
"function",
"find_subcommand",
"(",
"&",
"$",
"args",
")",
"{",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"subcommands",
"=",
"$",
"this",
"->",
"get_subcommands",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
... | Given supplied arguments, find a contained
subcommand
@param array $args
@return \WP_CLI\Dispatcher\Subcommand|false | [
"Given",
"supplied",
"arguments",
"find",
"a",
"contained",
"subcommand"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/CompositeCommand.php#L217-L235 | train |
wp-cli/wp-cli | php/WP_CLI/Dispatcher/CompositeCommand.php | CompositeCommand.get_aliases | private static function get_aliases( $subcommands ) {
$aliases = array();
foreach ( $subcommands as $name => $subcommand ) {
$alias = $subcommand->get_alias();
if ( $alias ) {
$aliases[ $alias ] = $name;
}
}
return $aliases;
} | php | private static function get_aliases( $subcommands ) {
$aliases = array();
foreach ( $subcommands as $name => $subcommand ) {
$alias = $subcommand->get_alias();
if ( $alias ) {
$aliases[ $alias ] = $name;
}
}
return $aliases;
} | [
"private",
"static",
"function",
"get_aliases",
"(",
"$",
"subcommands",
")",
"{",
"$",
"aliases",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"subcommands",
"as",
"$",
"name",
"=>",
"$",
"subcommand",
")",
"{",
"$",
"alias",
"=",
"$",
"subcomman... | Get any registered aliases for this composite command's
subcommands.
@param array $subcommands
@return array | [
"Get",
"any",
"registered",
"aliases",
"for",
"this",
"composite",
"command",
"s",
"subcommands",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Dispatcher/CompositeCommand.php#L244-L255 | train |
wp-cli/wp-cli | php/commands/src/CLI_Command.php | CLI_Command.info | public function info( $_, $assoc_args ) {
$php_bin = Utils\get_php_binary();
// php_uname() $mode argument was only added with PHP 7.0+. Fall back to
// entire string for older versions.
$system_os = PHP_MAJOR_VERSION < 7
? php_uname()
: sprintf(
'%s %s %s %s',
php_uname( 's' ),
php_uname( 'r... | php | public function info( $_, $assoc_args ) {
$php_bin = Utils\get_php_binary();
// php_uname() $mode argument was only added with PHP 7.0+. Fall back to
// entire string for older versions.
$system_os = PHP_MAJOR_VERSION < 7
? php_uname()
: sprintf(
'%s %s %s %s',
php_uname( 's' ),
php_uname( 'r... | [
"public",
"function",
"info",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"$",
"php_bin",
"=",
"Utils",
"\\",
"get_php_binary",
"(",
")",
";",
"// php_uname() $mode argument was only added with PHP 7.0+. Fall back to",
"// entire string for older versions.",
"$",
"... | Print various details about the WP-CLI environment.
Helpful for diagnostic purposes, this command shares:
* OS information.
* Shell information.
* PHP binary used.
* PHP binary version.
* php.ini configuration file used (which is typically different than web).
* WP-CLI root dir: where WP-CLI is installed (if non-Phar... | [
"Print",
"various",
"details",
"about",
"the",
"WP",
"-",
"CLI",
"environment",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Command.php#L109-L162 | train |
wp-cli/wp-cli | php/commands/src/CLI_Command.php | CLI_Command.check_update | public function check_update( $_, $assoc_args ) {
$updates = $this->get_updates( $assoc_args );
if ( $updates ) {
$formatter = new \WP_CLI\Formatter(
$assoc_args,
array( 'version', 'update_type', 'package_url' )
);
$formatter->display_items( $updates );
} elseif ( empty( $assoc_args['format'] ) ... | php | public function check_update( $_, $assoc_args ) {
$updates = $this->get_updates( $assoc_args );
if ( $updates ) {
$formatter = new \WP_CLI\Formatter(
$assoc_args,
array( 'version', 'update_type', 'package_url' )
);
$formatter->display_items( $updates );
} elseif ( empty( $assoc_args['format'] ) ... | [
"public",
"function",
"check_update",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"$",
"updates",
"=",
"$",
"this",
"->",
"get_updates",
"(",
"$",
"assoc_args",
")",
";",
"if",
"(",
"$",
"updates",
")",
"{",
"$",
"formatter",
"=",
"new",
"\\",
... | Check to see if there is a newer version of WP-CLI available.
Queries the Github releases API. Returns available versions if there are
updates available, or success message if using the latest release.
## OPTIONS
[--patch]
: Only list patch updates.
[--minor]
: Only list minor updates.
[--major]
: Only list major ... | [
"Check",
"to",
"see",
"if",
"there",
"is",
"a",
"newer",
"version",
"of",
"WP",
"-",
"CLI",
"available",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Command.php#L215-L228 | train |
wp-cli/wp-cli | php/commands/src/CLI_Command.php | CLI_Command.param_dump | public function param_dump( $_, $assoc_args ) {
$spec = \WP_CLI::get_configurator()->get_spec();
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'with-values' ) ) {
$config = \WP_CLI::get_configurator()->to_array();
// Copy current config values to $spec
foreach ( $spec as $key => $value ) {
$current ... | php | public function param_dump( $_, $assoc_args ) {
$spec = \WP_CLI::get_configurator()->get_spec();
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'with-values' ) ) {
$config = \WP_CLI::get_configurator()->to_array();
// Copy current config values to $spec
foreach ( $spec as $key => $value ) {
$current ... | [
"public",
"function",
"param_dump",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"$",
"spec",
"=",
"\\",
"WP_CLI",
"::",
"get_configurator",
"(",
")",
"->",
"get_spec",
"(",
")",
";",
"if",
"(",
"\\",
"WP_CLI",
"\\",
"Utils",
"\\",
"get_flag_value"... | Dump the list of global parameters, as JSON or in var_export format.
## OPTIONS
[--with-values]
: Display current values also.
[--format=<format>]
: Render output in a particular format.
---
default: json
options:
- var_export
- json
---
## EXAMPLES
# Dump the list of global parameters.
$ wp cli param-dump --forma... | [
"Dump",
"the",
"list",
"of",
"global",
"parameters",
"as",
"JSON",
"or",
"in",
"var_export",
"format",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Command.php#L498-L518 | train |
wp-cli/wp-cli | php/commands/src/CLI_Command.php | CLI_Command.completions | public function completions( $_, $assoc_args ) {
$line = substr( $assoc_args['line'], 0, $assoc_args['point'] );
$compl = new \WP_CLI\Completions( $line );
$compl->render();
} | php | public function completions( $_, $assoc_args ) {
$line = substr( $assoc_args['line'], 0, $assoc_args['point'] );
$compl = new \WP_CLI\Completions( $line );
$compl->render();
} | [
"public",
"function",
"completions",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"$",
"line",
"=",
"substr",
"(",
"$",
"assoc_args",
"[",
"'line'",
"]",
",",
"0",
",",
"$",
"assoc_args",
"[",
"'point'",
"]",
")",
";",
"$",
"compl",
"=",
"new",... | Generate tab completion strings.
## OPTIONS
--line=<line>
: The current command line to be executed.
--point=<point>
: The index to the current cursor position relative to the beginning of the command.
## EXAMPLES
# Generate tab completion strings.
$ wp cli completions --line='wp eva' --point=100
eval
eval-file | [
"Generate",
"tab",
"completion",
"strings",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Command.php#L553-L557 | train |
wp-cli/wp-cli | php/commands/src/CLI_Command.php | CLI_Command.get_update_type_str | private function get_update_type_str( $assoc_args ) {
$update_type = ' ';
foreach ( array( 'major', 'minor', 'patch' ) as $type ) {
if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, $type ) ) {
$update_type = ' ' . $type . ' ';
break;
}
}
return $update_type;
} | php | private function get_update_type_str( $assoc_args ) {
$update_type = ' ';
foreach ( array( 'major', 'minor', 'patch' ) as $type ) {
if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, $type ) ) {
$update_type = ' ' . $type . ' ';
break;
}
}
return $update_type;
} | [
"private",
"function",
"get_update_type_str",
"(",
"$",
"assoc_args",
")",
"{",
"$",
"update_type",
"=",
"' '",
";",
"foreach",
"(",
"array",
"(",
"'major'",
",",
"'minor'",
",",
"'patch'",
")",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"true",
"===",
"\... | Get a string representing the type of update being checked for. | [
"Get",
"a",
"string",
"representing",
"the",
"type",
"of",
"update",
"being",
"checked",
"for",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Command.php#L562-L571 | train |
wp-cli/wp-cli | php/commands/src/CLI_Command.php | CLI_Command.has_command | public function has_command( $_, $assoc_args ) {
// If command is input as a string, then explode it into array.
$command = explode( ' ', implode( ' ', $_ ) );
WP_CLI::halt( is_array( WP_CLI::get_runner()->find_command_to_run( $command ) ) ? 0 : 1 );
} | php | public function has_command( $_, $assoc_args ) {
// If command is input as a string, then explode it into array.
$command = explode( ' ', implode( ' ', $_ ) );
WP_CLI::halt( is_array( WP_CLI::get_runner()->find_command_to_run( $command ) ) ? 0 : 1 );
} | [
"public",
"function",
"has_command",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"// If command is input as a string, then explode it into array.",
"$",
"command",
"=",
"explode",
"(",
"' '",
",",
"implode",
"(",
"' '",
",",
"$",
"_",
")",
")",
";",
"WP_C... | Detects if a command exists
This commands checks if a command is registered with WP-CLI.
If the command is found then it returns with exit status 0.
If the command doesn't exist, then it will exit with status 1.
## OPTIONS
<command_name>...
: The command
## EXAMPLES
# The "site delete" command is registered.
$ wp c... | [
"Detects",
"if",
"a",
"command",
"exists"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Command.php#L600-L606 | train |
wp-cli/wp-cli | php/commands/src/CLI_Alias_Command.php | CLI_Alias_Command.get | public function get( $args, $assoc_args ) {
list( $alias ) = $args;
$aliases = WP_CLI::get_runner()->aliases;
if ( empty( $aliases[ $alias ] ) ) {
WP_CLI::error( "No alias found with key '{$alias}'." );
}
foreach ( $aliases[ $alias ] as $key => $value ) {
WP_CLI::log( "{$key}: {$value}" );
}
} | php | public function get( $args, $assoc_args ) {
list( $alias ) = $args;
$aliases = WP_CLI::get_runner()->aliases;
if ( empty( $aliases[ $alias ] ) ) {
WP_CLI::error( "No alias found with key '{$alias}'." );
}
foreach ( $aliases[ $alias ] as $key => $value ) {
WP_CLI::log( "{$key}: {$value}" );
}
} | [
"public",
"function",
"get",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"list",
"(",
"$",
"alias",
")",
"=",
"$",
"args",
";",
"$",
"aliases",
"=",
"WP_CLI",
"::",
"get_runner",
"(",
")",
"->",
"aliases",
";",
"if",
"(",
"empty",
"(",
"$... | Gets the value for an alias.
## OPTIONS
<key>
: Key for the alias.
## EXAMPLES
# Get alias.
$ wp cli alias get @prod
ssh: dev@somedeve.env:12345/home/dev/ | [
"Gets",
"the",
"value",
"for",
"an",
"alias",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Alias_Command.php#L97-L109 | train |
wp-cli/wp-cli | php/commands/src/CLI_Alias_Command.php | CLI_Alias_Command.delete | public function delete( $args, $assoc_args ) {
list( $alias ) = $args;
$config = ( ! empty( $assoc_args['config'] ) ? $assoc_args['config'] : '' );
list( $config_path, $aliases ) = $this->get_aliases_data( $config, $alias );
$this->validate_config_file( $config_path );
if ( empty( $aliases[ $alias ] ) ) ... | php | public function delete( $args, $assoc_args ) {
list( $alias ) = $args;
$config = ( ! empty( $assoc_args['config'] ) ? $assoc_args['config'] : '' );
list( $config_path, $aliases ) = $this->get_aliases_data( $config, $alias );
$this->validate_config_file( $config_path );
if ( empty( $aliases[ $alias ] ) ) ... | [
"public",
"function",
"delete",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"list",
"(",
"$",
"alias",
")",
"=",
"$",
"args",
";",
"$",
"config",
"=",
"(",
"!",
"empty",
"(",
"$",
"assoc_args",
"[",
"'config'",
"]",
")",
"?",
"$",
"assoc_... | Deletes an alias.
## OPTIONS
<key>
: Key for the alias.
[--config=<config>]
: Config file to be considered for operations.
---
options:
- global
- project
---
## EXAMPLES
# Delete alias.
$ wp cli alias delete @prod
Success: Deleted '@prod' alias.
# Delete project alias.
$ wp cli alias delete @prod --config=projec... | [
"Deletes",
"an",
"alias",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Alias_Command.php#L212-L229 | train |
wp-cli/wp-cli | php/commands/src/CLI_Alias_Command.php | CLI_Alias_Command.get_aliases_data | private function get_aliases_data( $config, $alias ) {
$global_config_path = WP_CLI::get_runner()->get_global_config_path();
$global_aliases = Spyc::YAMLLoad( $global_config_path );
$project_config_path = WP_CLI::get_runner()->get_project_config_path();
$project_aliases = Spyc::YAMLLoad( $project_conf... | php | private function get_aliases_data( $config, $alias ) {
$global_config_path = WP_CLI::get_runner()->get_global_config_path();
$global_aliases = Spyc::YAMLLoad( $global_config_path );
$project_config_path = WP_CLI::get_runner()->get_project_config_path();
$project_aliases = Spyc::YAMLLoad( $project_conf... | [
"private",
"function",
"get_aliases_data",
"(",
"$",
"config",
",",
"$",
"alias",
")",
"{",
"$",
"global_config_path",
"=",
"WP_CLI",
"::",
"get_runner",
"(",
")",
"->",
"get_global_config_path",
"(",
")",
";",
"$",
"global_aliases",
"=",
"Spyc",
"::",
"YAML... | Get config path and aliases data based on config type.
@param string $config Type of config to get data from.
@param string $alias Alias to be used for Add/Update/Delete.
@return array Config Path and Aliases in it. | [
"Get",
"config",
"path",
"and",
"aliases",
"data",
"based",
"on",
"config",
"type",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Alias_Command.php#L308-L340 | train |
wp-cli/wp-cli | php/commands/src/CLI_Alias_Command.php | CLI_Alias_Command.build_aliases | private function build_aliases( $aliases, $alias, $assoc_args, $is_grouping, $grouping = '', $is_update = false ) {
if ( $is_grouping ) {
$valid_assoc_args = array( 'config', 'grouping' );
$invalid_args = array_diff( array_keys( $assoc_args ), $valid_assoc_args );
// Check for invalid args.
if ( ! e... | php | private function build_aliases( $aliases, $alias, $assoc_args, $is_grouping, $grouping = '', $is_update = false ) {
if ( $is_grouping ) {
$valid_assoc_args = array( 'config', 'grouping' );
$invalid_args = array_diff( array_keys( $assoc_args ), $valid_assoc_args );
// Check for invalid args.
if ( ! e... | [
"private",
"function",
"build_aliases",
"(",
"$",
"aliases",
",",
"$",
"alias",
",",
"$",
"assoc_args",
",",
"$",
"is_grouping",
",",
"$",
"grouping",
"=",
"''",
",",
"$",
"is_update",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"is_grouping",
")",
"{",
... | Return aliases array.
@param array $aliases Current aliases data.
@param string $alias Name of alias.
@param array $key_args Associative arguments.
@param bool $is_grouping Check if its a grouping operation.
@param string $grouping Grouping value.
@param bool $is_update Is this an update operat... | [
"Return",
"aliases",
"array",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Alias_Command.php#L367-L409 | train |
wp-cli/wp-cli | php/commands/src/CLI_Alias_Command.php | CLI_Alias_Command.validate_input | private function validate_input( $assoc_args, $grouping ) {
// Check if valid arguments were passed.
$arg_match = preg_grep( '/^set-(\w+)/i', array_keys( $assoc_args ) );
// Verify passed-arguments.
if ( empty( $grouping ) && empty( $arg_match ) ) {
WP_CLI::error( 'No valid arguments passed.' );
}
// C... | php | private function validate_input( $assoc_args, $grouping ) {
// Check if valid arguments were passed.
$arg_match = preg_grep( '/^set-(\w+)/i', array_keys( $assoc_args ) );
// Verify passed-arguments.
if ( empty( $grouping ) && empty( $arg_match ) ) {
WP_CLI::error( 'No valid arguments passed.' );
}
// C... | [
"private",
"function",
"validate_input",
"(",
"$",
"assoc_args",
",",
"$",
"grouping",
")",
"{",
"// Check if valid arguments were passed.",
"$",
"arg_match",
"=",
"preg_grep",
"(",
"'/^set-(\\w+)/i'",
",",
"array_keys",
"(",
"$",
"assoc_args",
")",
")",
";",
"// ... | Validate input of passed arguments.
@param array $assoc_args Arguments array.
@param string $grouping Grouping argument value.
@throws WP_CLI\ExitException | [
"Validate",
"input",
"of",
"passed",
"arguments",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Alias_Command.php#L419-L434 | train |
wp-cli/wp-cli | php/commands/src/CLI_Alias_Command.php | CLI_Alias_Command.validate_alias_type | private function validate_alias_type( $aliases, $alias, $assoc_args, $grouping ) {
$alias_data = $aliases[ $alias ];
$group_aliases_match = preg_grep( '/^@(\w+)/i', $alias_data );
$arg_match = preg_grep( '/^set-(\w+)/i', array_keys( $assoc_args ) );
if ( ! empty( $group_aliases_match ) && ! empty( ... | php | private function validate_alias_type( $aliases, $alias, $assoc_args, $grouping ) {
$alias_data = $aliases[ $alias ];
$group_aliases_match = preg_grep( '/^@(\w+)/i', $alias_data );
$arg_match = preg_grep( '/^set-(\w+)/i', array_keys( $assoc_args ) );
if ( ! empty( $group_aliases_match ) && ! empty( ... | [
"private",
"function",
"validate_alias_type",
"(",
"$",
"aliases",
",",
"$",
"alias",
",",
"$",
"assoc_args",
",",
"$",
"grouping",
")",
"{",
"$",
"alias_data",
"=",
"$",
"aliases",
"[",
"$",
"alias",
"]",
";",
"$",
"group_aliases_match",
"=",
"preg_grep",... | Validate alias type before update.
@param array $aliases Existing aliases data.
@param string $alias Alias Name.
@param array $assoc_args Arguments array.
@param string $grouping Grouping argument value.
@throws WP_CLI\ExitException | [
"Validate",
"alias",
"type",
"before",
"update",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Alias_Command.php#L446-L458 | train |
wp-cli/wp-cli | php/commands/src/CLI_Alias_Command.php | CLI_Alias_Command.process_aliases | private function process_aliases( $aliases, $alias, $config_path, $operation = '' ) {
// Convert data to YAML string.
$yaml_data = Spyc::YAMLDump( $aliases );
// Add data in config file.
if ( file_put_contents( $config_path, $yaml_data ) ) {
WP_CLI::success( "$operation '{$alias}' alias." );
}
} | php | private function process_aliases( $aliases, $alias, $config_path, $operation = '' ) {
// Convert data to YAML string.
$yaml_data = Spyc::YAMLDump( $aliases );
// Add data in config file.
if ( file_put_contents( $config_path, $yaml_data ) ) {
WP_CLI::success( "$operation '{$alias}' alias." );
}
} | [
"private",
"function",
"process_aliases",
"(",
"$",
"aliases",
",",
"$",
"alias",
",",
"$",
"config_path",
",",
"$",
"operation",
"=",
"''",
")",
"{",
"// Convert data to YAML string.",
"$",
"yaml_data",
"=",
"Spyc",
"::",
"YAMLDump",
"(",
"$",
"aliases",
")... | Save aliases data to config file.
@param array $aliases Current aliases data.
@param string $alias Name of alias.
@param string $config_path Path to config file.
@param string $operation Current operation string fro message. | [
"Save",
"aliases",
"data",
"to",
"config",
"file",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/commands/src/CLI_Alias_Command.php#L468-L476 | train |
wp-cli/wp-cli | php/WP_CLI/DocParser.php | DocParser.remove_decorations | private static function remove_decorations( $comment ) {
$comment = preg_replace( '|^/\*\*[\r\n]+|', '', $comment );
$comment = preg_replace( '|\n[\t ]*\*/$|', '', $comment );
$comment = preg_replace( '|^[\t ]*\* ?|m', '', $comment );
return $comment;
} | php | private static function remove_decorations( $comment ) {
$comment = preg_replace( '|^/\*\*[\r\n]+|', '', $comment );
$comment = preg_replace( '|\n[\t ]*\*/$|', '', $comment );
$comment = preg_replace( '|^[\t ]*\* ?|m', '', $comment );
return $comment;
} | [
"private",
"static",
"function",
"remove_decorations",
"(",
"$",
"comment",
")",
"{",
"$",
"comment",
"=",
"preg_replace",
"(",
"'|^/\\*\\*[\\r\\n]+|'",
",",
"''",
",",
"$",
"comment",
")",
";",
"$",
"comment",
"=",
"preg_replace",
"(",
"'|\\n[\\t ]*\\*/$|'",
... | Remove unused cruft from PHPdoc comment.
@param string $comment PHPdoc comment.
@return string | [
"Remove",
"unused",
"cruft",
"from",
"PHPdoc",
"comment",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/DocParser.php#L33-L39 | train |
wp-cli/wp-cli | php/WP_CLI/DocParser.php | DocParser.get_longdesc | public function get_longdesc() {
$shortdesc = $this->get_shortdesc();
if ( ! $shortdesc ) {
return '';
}
$longdesc = substr( $this->doc_comment, strlen( $shortdesc ) );
$lines = array();
foreach ( explode( "\n", $longdesc ) as $line ) {
if ( 0 === strpos( $line, '@' ) ) {
break;
}
$lines[... | php | public function get_longdesc() {
$shortdesc = $this->get_shortdesc();
if ( ! $shortdesc ) {
return '';
}
$longdesc = substr( $this->doc_comment, strlen( $shortdesc ) );
$lines = array();
foreach ( explode( "\n", $longdesc ) as $line ) {
if ( 0 === strpos( $line, '@' ) ) {
break;
}
$lines[... | [
"public",
"function",
"get_longdesc",
"(",
")",
"{",
"$",
"shortdesc",
"=",
"$",
"this",
"->",
"get_shortdesc",
"(",
")",
";",
"if",
"(",
"!",
"$",
"shortdesc",
")",
"{",
"return",
"''",
";",
"}",
"$",
"longdesc",
"=",
"substr",
"(",
"$",
"this",
"... | Get the command's full description
@return string | [
"Get",
"the",
"command",
"s",
"full",
"description"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/DocParser.php#L59-L78 | train |
wp-cli/wp-cli | php/WP_CLI/DocParser.php | DocParser.get_arg_or_param_args | private function get_arg_or_param_args( $regex ) {
$bits = explode( "\n", $this->doc_comment );
$within_arg = false;
$within_doc = false;
$document = array();
foreach ( $bits as $bit ) {
if ( preg_match( $regex, $bit ) ) {
$within_arg = true;
}
if ( $within_arg && $within_doc && '---' ==... | php | private function get_arg_or_param_args( $regex ) {
$bits = explode( "\n", $this->doc_comment );
$within_arg = false;
$within_doc = false;
$document = array();
foreach ( $bits as $bit ) {
if ( preg_match( $regex, $bit ) ) {
$within_arg = true;
}
if ( $within_arg && $within_doc && '---' ==... | [
"private",
"function",
"get_arg_or_param_args",
"(",
"$",
"regex",
")",
"{",
"$",
"bits",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"doc_comment",
")",
";",
"$",
"within_arg",
"=",
"false",
";",
"$",
"within_doc",
"=",
"false",
";",
"$",
... | Get the args for an arg or param
@param string $regex Pattern to match against
@return array|null Interpreted YAML document, or null. | [
"Get",
"the",
"args",
"for",
"an",
"arg",
"or",
"param"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/DocParser.php#L164-L196 | train |
wp-cli/wp-cli | php/WP_CLI/Bootstrap/RegisterDeferredCommands.php | RegisterDeferredCommands.add_deferred_commands | public function add_deferred_commands() {
$deferred_additions = \WP_CLI::get_deferred_additions();
foreach ( $deferred_additions as $name => $addition ) {
\WP_CLI::debug(
sprintf(
'Adding deferred command: %s => %s',
$name,
json_encode( $addition )
),
'bootstrap'
);
\WP_CLI::ad... | php | public function add_deferred_commands() {
$deferred_additions = \WP_CLI::get_deferred_additions();
foreach ( $deferred_additions as $name => $addition ) {
\WP_CLI::debug(
sprintf(
'Adding deferred command: %s => %s',
$name,
json_encode( $addition )
),
'bootstrap'
);
\WP_CLI::ad... | [
"public",
"function",
"add_deferred_commands",
"(",
")",
"{",
"$",
"deferred_additions",
"=",
"\\",
"WP_CLI",
"::",
"get_deferred_additions",
"(",
")",
";",
"foreach",
"(",
"$",
"deferred_additions",
"as",
"$",
"name",
"=>",
"$",
"addition",
")",
"{",
"\\",
... | Add deferred commands that are still waiting to be processed. | [
"Add",
"deferred",
"commands",
"that",
"are",
"still",
"waiting",
"to",
"be",
"processed",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Bootstrap/RegisterDeferredCommands.php#L41-L60 | train |
wp-cli/wp-cli | utils/contrib-list.php | Contrib_List_Command.get_project_milestones | private static function get_project_milestones( $project, $args = array() ) {
$request_url = sprintf( 'https://api.github.com/repos/%s/milestones', $project );
list( $body, $headers ) = self::make_github_api_request( $request_url, $args );
return $body;
} | php | private static function get_project_milestones( $project, $args = array() ) {
$request_url = sprintf( 'https://api.github.com/repos/%s/milestones', $project );
list( $body, $headers ) = self::make_github_api_request( $request_url, $args );
return $body;
} | [
"private",
"static",
"function",
"get_project_milestones",
"(",
"$",
"project",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request_url",
"=",
"sprintf",
"(",
"'https://api.github.com/repos/%s/milestones'",
",",
"$",
"project",
")",
";",
"list",
... | Get the milestones for a given project
@param string $project
@return array | [
"Get",
"the",
"milestones",
"for",
"a",
"given",
"project"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/utils/contrib-list.php#L121-L125 | train |
wp-cli/wp-cli | utils/contrib-list.php | Contrib_List_Command.parse_contributors_from_pull_requests | private static function parse_contributors_from_pull_requests( $pull_requests ) {
$contributors = array();
foreach ( $pull_requests as $pull_request ) {
if ( ! empty( $pull_request->user ) ) {
$contributors[ $pull_request->user->html_url ] = $pull_request->user->login;
}
}
return $contributors;
} | php | private static function parse_contributors_from_pull_requests( $pull_requests ) {
$contributors = array();
foreach ( $pull_requests as $pull_request ) {
if ( ! empty( $pull_request->user ) ) {
$contributors[ $pull_request->user->html_url ] = $pull_request->user->login;
}
}
return $contributors;
} | [
"private",
"static",
"function",
"parse_contributors_from_pull_requests",
"(",
"$",
"pull_requests",
")",
"{",
"$",
"contributors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pull_requests",
"as",
"$",
"pull_request",
")",
"{",
"if",
"(",
"!",
"empty",... | Parse the contributors from pull request objects
@param array $pull_requests
@return array | [
"Parse",
"the",
"contributors",
"from",
"pull",
"request",
"objects"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/utils/contrib-list.php#L171-L179 | train |
wp-cli/wp-cli | utils/contrib-list.php | Contrib_List_Command.make_github_api_request | private static function make_github_api_request( $url, $args = array() ) {
$headers = array(
'Accept' => 'application/vnd.github.v3+json',
'User-Agent' => 'WP-CLI',
);
$token = getenv( 'GITHUB_TOKEN' );
if ( false !== $token ) {
$headers['Authorization'] = 'token ' . $token;
}
$response = Uti... | php | private static function make_github_api_request( $url, $args = array() ) {
$headers = array(
'Accept' => 'application/vnd.github.v3+json',
'User-Agent' => 'WP-CLI',
);
$token = getenv( 'GITHUB_TOKEN' );
if ( false !== $token ) {
$headers['Authorization'] = 'token ' . $token;
}
$response = Uti... | [
"private",
"static",
"function",
"make_github_api_request",
"(",
"$",
"url",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
"'Accept'",
"=>",
"'application/vnd.github.v3+json'",
",",
"'User-Agent'",
"=>",
"'WP-CLI'",
","... | Make a request to the GitHub API
@param string $url
@param string $args
@return array | [
"Make",
"a",
"request",
"to",
"the",
"GitHub",
"API"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/utils/contrib-list.php#L188-L202 | train |
wp-cli/wp-cli | php/WP_CLI/Iterators/Query.php | Query.adjust_offset_for_shrinking_result_set | private function adjust_offset_for_shrinking_result_set() {
if ( empty( $this->count_query ) ) {
return;
}
$row_count = $this->db->get_var( $this->count_query );
if ( $row_count < $this->row_count ) {
$this->offset -= $this->row_count - $row_count;
}
$this->row_count = $row_count;
} | php | private function adjust_offset_for_shrinking_result_set() {
if ( empty( $this->count_query ) ) {
return;
}
$row_count = $this->db->get_var( $this->count_query );
if ( $row_count < $this->row_count ) {
$this->offset -= $this->row_count - $row_count;
}
$this->row_count = $row_count;
} | [
"private",
"function",
"adjust_offset_for_shrinking_result_set",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"count_query",
")",
")",
"{",
"return",
";",
"}",
"$",
"row_count",
"=",
"$",
"this",
"->",
"db",
"->",
"get_var",
"(",
"$",
"this... | Reduces the offset when the query row count shrinks
In cases where the iterated rows are being updated such that they will no
longer be returned by the original query, the offset must be reduced to
iterate over all remaining rows. | [
"Reduces",
"the",
"offset",
"when",
"the",
"query",
"row",
"count",
"shrinks"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Iterators/Query.php#L57-L69 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.get_aliases | public function get_aliases() {
$runtime_alias = getenv( 'WP_CLI_RUNTIME_ALIAS' );
if ( false !== $runtime_alias ) {
$returned_aliases = array();
foreach ( json_decode( $runtime_alias, true ) as $key => $value ) {
if ( preg_match( '#' . self::ALIAS_REGEX . '#', $key ) ) {
$returned_aliases[ $key ] = ... | php | public function get_aliases() {
$runtime_alias = getenv( 'WP_CLI_RUNTIME_ALIAS' );
if ( false !== $runtime_alias ) {
$returned_aliases = array();
foreach ( json_decode( $runtime_alias, true ) as $key => $value ) {
if ( preg_match( '#' . self::ALIAS_REGEX . '#', $key ) ) {
$returned_aliases[ $key ] = ... | [
"public",
"function",
"get_aliases",
"(",
")",
"{",
"$",
"runtime_alias",
"=",
"getenv",
"(",
"'WP_CLI_RUNTIME_ALIAS'",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"runtime_alias",
")",
"{",
"$",
"returned_aliases",
"=",
"array",
"(",
")",
";",
"foreach",
"(... | Get any aliases defined in config files.
@return array | [
"Get",
"any",
"aliases",
"defined",
"in",
"config",
"files",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L94-L112 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.parse_args | public function parse_args( $arguments ) {
list( $positional_args, $mixed_args, $global_assoc, $local_assoc ) = self::extract_assoc( $arguments );
list( $assoc_args, $runtime_config ) = $this->unmix_assoc_args( $mixed_args, $global_assoc, $local_assoc );
return array( $positional_arg... | php | public function parse_args( $arguments ) {
list( $positional_args, $mixed_args, $global_assoc, $local_assoc ) = self::extract_assoc( $arguments );
list( $assoc_args, $runtime_config ) = $this->unmix_assoc_args( $mixed_args, $global_assoc, $local_assoc );
return array( $positional_arg... | [
"public",
"function",
"parse_args",
"(",
"$",
"arguments",
")",
"{",
"list",
"(",
"$",
"positional_args",
",",
"$",
"mixed_args",
",",
"$",
"global_assoc",
",",
"$",
"local_assoc",
")",
"=",
"self",
"::",
"extract_assoc",
"(",
"$",
"arguments",
")",
";",
... | Splits a list of arguments into positional, associative and config.
@param array(string)
@return array(array) | [
"Splits",
"a",
"list",
"of",
"arguments",
"into",
"positional",
"associative",
"and",
"config",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L120-L124 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.extract_assoc | public static function extract_assoc( $arguments ) {
$positional_args = array();
$assoc_args = array();
$global_assoc = array();
$local_assoc = array();
foreach ( $arguments as $arg ) {
$positional_arg = null;
$assoc_arg = null;
if ( preg_match( '|^--no-([^=]+)$|', $arg, $matches )... | php | public static function extract_assoc( $arguments ) {
$positional_args = array();
$assoc_args = array();
$global_assoc = array();
$local_assoc = array();
foreach ( $arguments as $arg ) {
$positional_arg = null;
$assoc_arg = null;
if ( preg_match( '|^--no-([^=]+)$|', $arg, $matches )... | [
"public",
"static",
"function",
"extract_assoc",
"(",
"$",
"arguments",
")",
"{",
"$",
"positional_args",
"=",
"array",
"(",
")",
";",
"$",
"assoc_args",
"=",
"array",
"(",
")",
";",
"$",
"global_assoc",
"=",
"array",
"(",
")",
";",
"$",
"local_assoc",
... | Splits positional args from associative args.
@param array
@return array(array) | [
"Splits",
"positional",
"args",
"from",
"associative",
"args",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L132-L165 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.unmix_assoc_args | private function unmix_assoc_args( $mixed_args, $global_assoc = array(), $local_assoc = array() ) {
$assoc_args = array();
$runtime_config = array();
if ( getenv( 'WP_CLI_STRICT_ARGS_MODE' ) ) {
foreach ( $global_assoc as $tmp ) {
list( $key, $value ) = $tmp;
if ( isset( $this->spec[ $key ] ) && f... | php | private function unmix_assoc_args( $mixed_args, $global_assoc = array(), $local_assoc = array() ) {
$assoc_args = array();
$runtime_config = array();
if ( getenv( 'WP_CLI_STRICT_ARGS_MODE' ) ) {
foreach ( $global_assoc as $tmp ) {
list( $key, $value ) = $tmp;
if ( isset( $this->spec[ $key ] ) && f... | [
"private",
"function",
"unmix_assoc_args",
"(",
"$",
"mixed_args",
",",
"$",
"global_assoc",
"=",
"array",
"(",
")",
",",
"$",
"local_assoc",
"=",
"array",
"(",
")",
")",
"{",
"$",
"assoc_args",
"=",
"array",
"(",
")",
";",
"$",
"runtime_config",
"=",
... | Separate runtime parameters from command-specific parameters.
@param array $mixed_args
@return array | [
"Separate",
"runtime",
"parameters",
"from",
"command",
"-",
"specific",
"parameters",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L173-L200 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.merge_yml | public function merge_yml( $path, $current_alias = null ) {
$yaml = self::load_yml( $path );
if ( ! empty( $yaml['_']['inherit'] ) ) {
$this->merge_yml( $yaml['_']['inherit'], $current_alias );
}
// Prepare the base path for absolutized alias paths
$yml_file_dir = $path ? dirname( $path ) : false;
foreac... | php | public function merge_yml( $path, $current_alias = null ) {
$yaml = self::load_yml( $path );
if ( ! empty( $yaml['_']['inherit'] ) ) {
$this->merge_yml( $yaml['_']['inherit'], $current_alias );
}
// Prepare the base path for absolutized alias paths
$yml_file_dir = $path ? dirname( $path ) : false;
foreac... | [
"public",
"function",
"merge_yml",
"(",
"$",
"path",
",",
"$",
"current_alias",
"=",
"null",
")",
"{",
"$",
"yaml",
"=",
"self",
"::",
"load_yml",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"yaml",
"[",
"'_'",
"]",
"[",
"'inhe... | Load a YAML file of parameters into scope.
@param string $path Path to YAML file. | [
"Load",
"a",
"YAML",
"file",
"of",
"parameters",
"into",
"scope",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L223-L272 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.merge_array | public function merge_array( $config ) {
foreach ( $this->spec as $key => $details ) {
if ( false !== $details['runtime'] && isset( $config[ $key ] ) ) {
$value = $config[ $key ];
if ( 'require' === $key ) {
$value = \WP_CLI\Utils\expand_globs( $value );
}
if ( $details['multiple'] ) {
... | php | public function merge_array( $config ) {
foreach ( $this->spec as $key => $details ) {
if ( false !== $details['runtime'] && isset( $config[ $key ] ) ) {
$value = $config[ $key ];
if ( 'require' === $key ) {
$value = \WP_CLI\Utils\expand_globs( $value );
}
if ( $details['multiple'] ) {
... | [
"public",
"function",
"merge_array",
"(",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"spec",
"as",
"$",
"key",
"=>",
"$",
"details",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"details",
"[",
"'runtime'",
"]",
"&&",
"isset",
"(",
"$... | Merge an array of values into the configurator config.
@param array $config | [
"Merge",
"an",
"array",
"of",
"values",
"into",
"the",
"configurator",
"config",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L279-L296 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.load_yml | private static function load_yml( $yml_file ) {
if ( ! $yml_file ) {
return array();
}
$config = Spyc::YAMLLoad( $yml_file );
// Make sure config-file-relative paths are made absolute.
$yml_file_dir = dirname( $yml_file );
if ( isset( $config['path'] ) ) {
self::absolutize( $config['path'], $yml_fi... | php | private static function load_yml( $yml_file ) {
if ( ! $yml_file ) {
return array();
}
$config = Spyc::YAMLLoad( $yml_file );
// Make sure config-file-relative paths are made absolute.
$yml_file_dir = dirname( $yml_file );
if ( isset( $config['path'] ) ) {
self::absolutize( $config['path'], $yml_fi... | [
"private",
"static",
"function",
"load_yml",
"(",
"$",
"yml_file",
")",
"{",
"if",
"(",
"!",
"$",
"yml_file",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"config",
"=",
"Spyc",
"::",
"YAMLLoad",
"(",
"$",
"yml_file",
")",
";",
"// Make sure... | Load values from a YAML file.
@param string $yml_file Path to the YAML file
@return array $config Declared configuration values | [
"Load",
"values",
"from",
"a",
"YAML",
"file",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L304-L344 | train |
wp-cli/wp-cli | php/WP_CLI/Configurator.php | Configurator.absolutize | private static function absolutize( &$path, $base ) {
if ( ! empty( $path ) && ! \WP_CLI\Utils\is_path_absolute( $path ) ) {
$path = $base . DIRECTORY_SEPARATOR . $path;
}
} | php | private static function absolutize( &$path, $base ) {
if ( ! empty( $path ) && ! \WP_CLI\Utils\is_path_absolute( $path ) ) {
$path = $base . DIRECTORY_SEPARATOR . $path;
}
} | [
"private",
"static",
"function",
"absolutize",
"(",
"&",
"$",
"path",
",",
"$",
"base",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
"&&",
"!",
"\\",
"WP_CLI",
"\\",
"Utils",
"\\",
"is_path_absolute",
"(",
"$",
"path",
")",
")",
"{",
... | Make a path absolute.
@param string $path Path to file.
@param string $base Base path to prepend. | [
"Make",
"a",
"path",
"absolute",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Configurator.php#L361-L365 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.set_url | public static function set_url( $url ) {
self::debug( 'Set URL: ' . $url, 'bootstrap' );
$url_parts = Utils\parse_url( $url );
self::set_url_params( $url_parts );
} | php | public static function set_url( $url ) {
self::debug( 'Set URL: ' . $url, 'bootstrap' );
$url_parts = Utils\parse_url( $url );
self::set_url_params( $url_parts );
} | [
"public",
"static",
"function",
"set_url",
"(",
"$",
"url",
")",
"{",
"self",
"::",
"debug",
"(",
"'Set URL: '",
".",
"$",
"url",
",",
"'bootstrap'",
")",
";",
"$",
"url_parts",
"=",
"Utils",
"\\",
"parse_url",
"(",
"$",
"url",
")",
";",
"self",
"::"... | Set the context in which WP-CLI should be run | [
"Set",
"the",
"context",
"in",
"which",
"WP",
"-",
"CLI",
"should",
"be",
"run"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L103-L107 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.add_hook | public static function add_hook( $when, $callback ) {
if ( array_key_exists( $when, self::$hooks_passed ) ) {
self::debug(
sprintf(
'Immediately invoking on passed hook "%s": %s',
$when,
Utils\describe_callable( $callback )
),
'hooks'
);
call_user_func_array( $callback, (array) sel... | php | public static function add_hook( $when, $callback ) {
if ( array_key_exists( $when, self::$hooks_passed ) ) {
self::debug(
sprintf(
'Immediately invoking on passed hook "%s": %s',
$when,
Utils\describe_callable( $callback )
),
'hooks'
);
call_user_func_array( $callback, (array) sel... | [
"public",
"static",
"function",
"add_hook",
"(",
"$",
"when",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"when",
",",
"self",
"::",
"$",
"hooks_passed",
")",
")",
"{",
"self",
"::",
"debug",
"(",
"sprintf",
"(",
"'Immediat... | Schedule a callback to be executed at a certain point.
Hooks conceptually are very similar to WordPress actions. WP-CLI hooks
are typically called before WordPress is loaded.
WP-CLI hooks include:
* `before_add_command:<command>` - Before the command is added.
* `after_add_command:<command>` - After the command was ... | [
"Schedule",
"a",
"callback",
"to",
"be",
"executed",
"at",
"a",
"certain",
"point",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L244-L258 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.do_hook | public static function do_hook( $when ) {
$args = func_num_args() > 1
? array_slice( func_get_args(), 1 )
: array();
self::$hooks_passed[ $when ] = $args;
if ( ! isset( self::$hooks[ $when ] ) ) {
return;
}
self::debug(
sprintf(
'Processing hook "%s" with %d callbacks',
$when,
coun... | php | public static function do_hook( $when ) {
$args = func_num_args() > 1
? array_slice( func_get_args(), 1 )
: array();
self::$hooks_passed[ $when ] = $args;
if ( ! isset( self::$hooks[ $when ] ) ) {
return;
}
self::debug(
sprintf(
'Processing hook "%s" with %d callbacks',
$when,
coun... | [
"public",
"static",
"function",
"do_hook",
"(",
"$",
"when",
")",
"{",
"$",
"args",
"=",
"func_num_args",
"(",
")",
">",
"1",
"?",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"1",
")",
":",
"array",
"(",
")",
";",
"self",
"::",
"$",
"hooks_... | Execute callbacks registered to a given hook.
See `WP_CLI::add_hook()` for details on WP-CLI's internal hook system.
Commands can provide and call their own hooks.
@access public
@category Registration
@param string $when Identifier for the hook.
@param mixed ... Optional. Arguments that will be passed onto the
call... | [
"Execute",
"callbacks",
"registered",
"to",
"a",
"given",
"hook",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L274-L306 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.add_wp_hook | public static function add_wp_hook( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
global $wp_filter, $merged_filters;
if ( function_exists( 'add_filter' ) ) {
add_filter( $tag, $function_to_add, $priority, $accepted_args );
} else {
$idx = self::wp_hook_build_unique_id( $tag, $function_to_... | php | public static function add_wp_hook( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
global $wp_filter, $merged_filters;
if ( function_exists( 'add_filter' ) ) {
add_filter( $tag, $function_to_add, $priority, $accepted_args );
} else {
$idx = self::wp_hook_build_unique_id( $tag, $function_to_... | [
"public",
"static",
"function",
"add_wp_hook",
"(",
"$",
"tag",
",",
"$",
"function_to_add",
",",
"$",
"priority",
"=",
"10",
",",
"$",
"accepted_args",
"=",
"1",
")",
"{",
"global",
"$",
"wp_filter",
",",
"$",
"merged_filters",
";",
"if",
"(",
"function... | Add a callback to a WordPress action or filter.
`add_action()` without needing access to `add_action()`. If WordPress is
already loaded though, you should use `add_action()` (and `add_filter()`)
instead.
@access public
@category Registration
@param string $tag Named WordPress action or filter.
@param mixed $function... | [
"Add",
"a",
"callback",
"to",
"a",
"WordPress",
"action",
"or",
"filter",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L324-L341 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.defer_command_addition | private static function defer_command_addition( $name, $parent, $callable, $args = array() ) {
$args['is_deferred'] = true;
self::$deferred_additions[ $name ] = array(
'parent' => $parent,
'callable' => $callable,
'args' => $args,
);
self::add_hook(
"after_add_command:$parent",
... | php | private static function defer_command_addition( $name, $parent, $callable, $args = array() ) {
$args['is_deferred'] = true;
self::$deferred_additions[ $name ] = array(
'parent' => $parent,
'callable' => $callable,
'args' => $args,
);
self::add_hook(
"after_add_command:$parent",
... | [
"private",
"static",
"function",
"defer_command_addition",
"(",
"$",
"name",
",",
"$",
"parent",
",",
"$",
"callable",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"[",
"'is_deferred'",
"]",
"=",
"true",
";",
"self",
"::",
"$",
"d... | Defer command addition for a sub-command if the parent command is not yet
registered.
@param string $name Name for the sub-command.
@param string $parent Name for the parent command.
@param string $callable Command implementation as a class, function or closure.
@param array $args Optional. See `WP_CLI::add... | [
"Defer",
"command",
"addition",
"for",
"a",
"sub",
"-",
"command",
"if",
"the",
"parent",
"command",
"is",
"not",
"yet",
"registered",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L625-L648 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.remove_deferred_addition | public static function remove_deferred_addition( $name ) {
if ( ! array_key_exists( $name, self::$deferred_additions ) ) {
self::warning( "Trying to remove a non-existent command addition '{$name}'." );
}
unset( self::$deferred_additions[ $name ] );
} | php | public static function remove_deferred_addition( $name ) {
if ( ! array_key_exists( $name, self::$deferred_additions ) ) {
self::warning( "Trying to remove a non-existent command addition '{$name}'." );
}
unset( self::$deferred_additions[ $name ] );
} | [
"public",
"static",
"function",
"remove_deferred_addition",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"deferred_additions",
")",
")",
"{",
"self",
"::",
"warning",
"(",
"\"Trying to remove a non-e... | Remove a command addition from the list of outstanding deferred additions. | [
"Remove",
"a",
"command",
"addition",
"from",
"the",
"list",
"of",
"outstanding",
"deferred",
"additions",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L662-L668 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.error_multi_line | public static function error_multi_line( $message_lines ) {
if ( ! isset( self::get_runner()->assoc_args['completions'] ) && is_array( $message_lines ) ) {
self::$logger->error_multi_line( array_map( array( __CLASS__, 'error_to_string' ), $message_lines ) );
}
} | php | public static function error_multi_line( $message_lines ) {
if ( ! isset( self::get_runner()->assoc_args['completions'] ) && is_array( $message_lines ) ) {
self::$logger->error_multi_line( array_map( array( __CLASS__, 'error_to_string' ), $message_lines ) );
}
} | [
"public",
"static",
"function",
"error_multi_line",
"(",
"$",
"message_lines",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"get_runner",
"(",
")",
"->",
"assoc_args",
"[",
"'completions'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"message_lines",
")... | Display a multi-line error message in a red box. Doesn't exit script.
Error message is written to STDERR.
@access public
@category Output
@param array $message Multi-line error message to be displayed. | [
"Display",
"a",
"multi",
"-",
"line",
"error",
"message",
"in",
"a",
"red",
"box",
".",
"Doesn",
"t",
"exit",
"script",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L879-L883 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.confirm | public static function confirm( $question, $assoc_args = array() ) {
if ( ! \WP_CLI\Utils\get_flag_value( $assoc_args, 'yes' ) ) {
fwrite( STDOUT, $question . ' [y/n] ' );
$answer = strtolower( trim( fgets( STDIN ) ) );
if ( 'y' !== $answer ) {
exit;
}
}
} | php | public static function confirm( $question, $assoc_args = array() ) {
if ( ! \WP_CLI\Utils\get_flag_value( $assoc_args, 'yes' ) ) {
fwrite( STDOUT, $question . ' [y/n] ' );
$answer = strtolower( trim( fgets( STDIN ) ) );
if ( 'y' !== $answer ) {
exit;
}
}
} | [
"public",
"static",
"function",
"confirm",
"(",
"$",
"question",
",",
"$",
"assoc_args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"\\",
"WP_CLI",
"\\",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'yes'",
")",
")",
"{",
"fw... | Ask for confirmation before running a destructive operation.
If 'y' is provided to the question, the script execution continues. If
'n' or any other response is provided to the question, script exits.
```
# `wp db drop` asks for confirmation before dropping the database.
WP_CLI::confirm( "Are you sure you want to dr... | [
"Ask",
"for",
"confirmation",
"before",
"running",
"a",
"destructive",
"operation",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L903-L913 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.get_value_from_arg_or_stdin | public static function get_value_from_arg_or_stdin( $args, $index ) {
if ( isset( $args[ $index ] ) ) {
$raw_value = $args[ $index ];
} else {
// We don't use file_get_contents() here because it doesn't handle
// Ctrl-D properly, when typing in the value interactively.
$raw_value = '';
while ( false ... | php | public static function get_value_from_arg_or_stdin( $args, $index ) {
if ( isset( $args[ $index ] ) ) {
$raw_value = $args[ $index ];
} else {
// We don't use file_get_contents() here because it doesn't handle
// Ctrl-D properly, when typing in the value interactively.
$raw_value = '';
while ( false ... | [
"public",
"static",
"function",
"get_value_from_arg_or_stdin",
"(",
"$",
"args",
",",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"$",
"index",
"]",
")",
")",
"{",
"$",
"raw_value",
"=",
"$",
"args",
"[",
"$",
"index",
"]",
"... | Read value from a positional argument or from STDIN.
@param array $args The list of positional arguments.
@param int $index At which position to check for the value.
@return string | [
"Read",
"value",
"from",
"a",
"positional",
"argument",
"or",
"from",
"STDIN",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L923-L936 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.read_value | public static function read_value( $raw_value, $assoc_args = array() ) {
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) {
$value = json_decode( $raw_value, true );
if ( null === $value ) {
self::error( sprintf( 'Invalid JSON: %s', $raw_value ) );
}
} else {
$value = $raw_val... | php | public static function read_value( $raw_value, $assoc_args = array() ) {
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) {
$value = json_decode( $raw_value, true );
if ( null === $value ) {
self::error( sprintf( 'Invalid JSON: %s', $raw_value ) );
}
} else {
$value = $raw_val... | [
"public",
"static",
"function",
"read_value",
"(",
"$",
"raw_value",
",",
"$",
"assoc_args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"\\",
"WP_CLI",
"\\",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'format'",
")",
"===",
"'json'"... | Read a value, from various formats.
@access public
@category Input
@param mixed $value
@param array $assoc_args | [
"Read",
"a",
"value",
"from",
"various",
"formats",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L947-L958 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.print_value | public static function print_value( $value, $assoc_args = array() ) {
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) {
$value = json_encode( $value );
} elseif ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'yaml' ) {
$value = Spyc::YAMLDump( $value, 2, 0 );
} elseif ( ... | php | public static function print_value( $value, $assoc_args = array() ) {
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) {
$value = json_encode( $value );
} elseif ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'yaml' ) {
$value = Spyc::YAMLDump( $value, 2, 0 );
} elseif ( ... | [
"public",
"static",
"function",
"print_value",
"(",
"$",
"value",
",",
"$",
"assoc_args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"\\",
"WP_CLI",
"\\",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'format'",
")",
"===",
"'json'",
... | Display a value, in various formats
@param mixed $value Value to display.
@param array $assoc_args Arguments passed to the command, determining format. | [
"Display",
"a",
"value",
"in",
"various",
"formats"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L966-L976 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.error_to_string | public static function error_to_string( $errors ) {
if ( is_string( $errors ) ) {
return $errors;
}
// Only json_encode() the data when it needs it
$render_data = function( $data ) {
if ( is_array( $data ) || is_object( $data ) ) {
return json_encode( $data );
}
return '"' . $data . '"';
};
... | php | public static function error_to_string( $errors ) {
if ( is_string( $errors ) ) {
return $errors;
}
// Only json_encode() the data when it needs it
$render_data = function( $data ) {
if ( is_array( $data ) || is_object( $data ) ) {
return json_encode( $data );
}
return '"' . $data . '"';
};
... | [
"public",
"static",
"function",
"error_to_string",
"(",
"$",
"errors",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"errors",
")",
")",
"{",
"return",
"$",
"errors",
";",
"}",
"// Only json_encode() the data when it needs it",
"$",
"render_data",
"=",
"function",... | Convert a wp_error into a string
@param mixed $errors
@return string | [
"Convert",
"a",
"wp_error",
"into",
"a",
"string"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L984-L1007 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.launch_self | public static function launch_self( $command, $args = array(), $assoc_args = array(), $exit_on_error = true, $return_detailed = false, $runtime_args = array() ) {
$reused_runtime_args = array(
'path',
'url',
'user',
'allow-root',
);
foreach ( $reused_runtime_args as $key ) {
if ( isset( $runtime_a... | php | public static function launch_self( $command, $args = array(), $assoc_args = array(), $exit_on_error = true, $return_detailed = false, $runtime_args = array() ) {
$reused_runtime_args = array(
'path',
'url',
'user',
'allow-root',
);
foreach ( $reused_runtime_args as $key ) {
if ( isset( $runtime_a... | [
"public",
"static",
"function",
"launch_self",
"(",
"$",
"command",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"assoc_args",
"=",
"array",
"(",
")",
",",
"$",
"exit_on_error",
"=",
"true",
",",
"$",
"return_detailed",
"=",
"false",
",",
"$",
... | Run a WP-CLI command in a new process reusing the current runtime arguments.
Use `WP_CLI::runcommand()` instead, which is easier to use and works better.
Note: While this command does persist a limited set of runtime arguments,
it *does not* persist environment variables. Practically speaking, WP-CLI
packages won't b... | [
"Run",
"a",
"WP",
"-",
"CLI",
"command",
"in",
"a",
"new",
"process",
"reusing",
"the",
"current",
"runtime",
"arguments",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L1071-L1108 | train |
wp-cli/wp-cli | php/class-wp-cli.php | WP_CLI.get_config | public static function get_config( $key = null ) {
if ( null === $key ) {
return self::get_runner()->config;
}
if ( ! isset( self::get_runner()->config[ $key ] ) ) {
self::warning( "Unknown config option '$key'." );
return null;
}
return self::get_runner()->config[ $key ];
} | php | public static function get_config( $key = null ) {
if ( null === $key ) {
return self::get_runner()->config;
}
if ( ! isset( self::get_runner()->config[ $key ] ) ) {
self::warning( "Unknown config option '$key'." );
return null;
}
return self::get_runner()->config[ $key ];
} | [
"public",
"static",
"function",
"get_config",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"return",
"self",
"::",
"get_runner",
"(",
")",
"->",
"config",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
... | Get values of global configuration parameters.
Provides access to `--path=<path>`, `--url=<url>`, and other values of
the [global configuration parameters](https://wp-cli.org/config/).
```
WP_CLI::log( 'The --url=<url> value is: ' . WP_CLI::get_config( 'url' ) );
```
@access public
@category Input
@param string $ke... | [
"Get",
"values",
"of",
"global",
"configuration",
"parameters",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/class-wp-cli.php#L1156-L1167 | train |
wp-cli/wp-cli | php/WP_CLI/SynopsisParser.php | SynopsisParser.render | public static function render( &$synopsis ) {
if ( ! is_array( $synopsis ) ) {
return '';
}
$bits = [
'positional' => '',
'assoc' => '',
'generic' => '',
'flag' => '',
];
$reordered_synopsis = [
'positional' => [],
'assoc' => [],
'generic' => [],
... | php | public static function render( &$synopsis ) {
if ( ! is_array( $synopsis ) ) {
return '';
}
$bits = [
'positional' => '',
'assoc' => '',
'generic' => '',
'flag' => '',
];
$reordered_synopsis = [
'positional' => [],
'assoc' => [],
'generic' => [],
... | [
"public",
"static",
"function",
"render",
"(",
"&",
"$",
"synopsis",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"synopsis",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"bits",
"=",
"[",
"'positional'",
"=>",
"''",
",",
"'assoc'",
"=>",
"''",... | Render the Synopsis into a format string.
@param array $synopsis A structured synopsis. This might get reordered
to match the parsed output.
@return string Rendered synopsis. | [
"Render",
"the",
"Synopsis",
"into",
"a",
"format",
"string",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/SynopsisParser.php#L44-L113 | train |
wp-cli/wp-cli | php/WP_CLI/SynopsisParser.php | SynopsisParser.classify_token | private static function classify_token( $token ) {
$param = array();
list( $param['optional'], $token ) = self::is_optional( $token );
list( $param['repeating'], $token ) = self::is_repeating( $token );
$p_name = '([a-z-_0-9]+)';
$p_value = '([a-zA-Z-_|,0-9]+)';
if ( '--<field>=<value>' === $token ) {
... | php | private static function classify_token( $token ) {
$param = array();
list( $param['optional'], $token ) = self::is_optional( $token );
list( $param['repeating'], $token ) = self::is_repeating( $token );
$p_name = '([a-z-_0-9]+)';
$p_value = '([a-zA-Z-_|,0-9]+)';
if ( '--<field>=<value>' === $token ) {
... | [
"private",
"static",
"function",
"classify_token",
"(",
"$",
"token",
")",
"{",
"$",
"param",
"=",
"array",
"(",
")",
";",
"list",
"(",
"$",
"param",
"[",
"'optional'",
"]",
",",
"$",
"token",
")",
"=",
"self",
"::",
"is_optional",
"(",
"$",
"token",... | Classify argument attributes based on its syntax.
@param string $token
@return array $param | [
"Classify",
"argument",
"attributes",
"based",
"on",
"its",
"syntax",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/SynopsisParser.php#L121-L161 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.