WP_CLI
DocParser::get_arg_or_param_args
Get the args for an arg or param
Method of the class: DocParser{}
No Hooks.
Returns
Array|null. Interpreted YAML document, or null.
Usage
// private - for code of main (parent) class only $result = $this->get_arg_or_param_args( $regex );
- $regex(string) (required)
- Pattern to match against.
DocParser::get_arg_or_param_args() DocParser::get arg or param args code WP-CLI 2.13.0-alpha
private function get_arg_or_param_args( $regex ) {
$bits = explode( "\n", $this->doc_comment );
$within_arg = false;
$within_doc = false;
$document = [];
foreach ( $bits as $bit ) {
if ( preg_match( $regex, $bit ) ) {
$within_arg = true;
}
if ( $within_arg && $within_doc && '---' === $bit ) {
$within_doc = false;
}
if ( $within_arg && ! $within_doc && '---' === $bit ) {
$within_doc = true;
}
if ( $within_doc ) {
$document[] = $bit;
}
if ( $within_arg && '' === $bit ) {
$within_arg = false;
break;
}
}
if ( $document ) {
return Spyc::YAMLLoadString( implode( "\n", $document ) );
}
return null;
}