WP_CLI\DocParser::get_synopsis PHP Method

get_synopsis() public method

Get the command's synopsis.
public get_synopsis ( ) : string
return string
    public function get_synopsis()
    {
        if (!preg_match('|^@synopsis\\s+(.+)|m', $this->docComment, $matches)) {
            return '';
        }
        return $matches[1];
    }

Usage Example

Example #1
0
    function test_complete()
    {
        $doc = new DocParser(<<<EOB
/**
 * Rock and roll!
 *
 * ## OPTIONS
 *
 * --volume=<number>
 * : Sets the volume.
 *
 * ## EXAMPLES
 *
 * wp rock-on --volume=11
 *
 * @synopsis [--volume=<number>]
 * @alias rock-on
 */
EOB
);
        $this->assertEquals('Rock and roll!', $doc->get_shortdesc());
        $this->assertEquals('[--volume=<number>]', $doc->get_synopsis());
        $this->assertEquals('rock-on', $doc->get_tag('alias'));
        $longdesc = <<<EOB
## OPTIONS

--volume=<number>
: Sets the volume.

## EXAMPLES

wp rock-on --volume=11
EOB;
        $this->assertEquals($longdesc, $doc->get_longdesc());
    }
All Usage Examples Of WP_CLI\DocParser::get_synopsis