PHP Class Google\Cloud\Dev\Snippet\Parser\Parser

Example: $parser = new Parser;
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php Class Usage Examples

Public Methods

Method Description
allExamples ( $class ) : array Retrieve all examples from a class and its methods.
classExample ( string $class, integer | string $index ) : Snippet Get a snippet from a class.
createIdentifier ( $fqn, $indexOrName )
examples ( DocBlock $docBlock, $fullyQualifiedName, string $file, integer $line, array $magicMethods = [] ) : array Parse examples from a DocBlock object.
examplesFromClass ( object | ReflectionClas\ReflectionClass $class ) : array Retrieve all examples from a class Doc Block.
examplesFromMethod ( object $class, string | ReflectionMetho\ReflectionMethod $method ) : array Retrieve all examples from a method's Doc Block.
methodExample ( string $class, string $method, integer $index ) : Snippet Get a snippet from a method.

Private Methods

Method Description
buildMagicMethods ( $magicMethods, $className )
extractSnippetName ( $content )

Method Details

allExamples() public method

Example: $examples = $parser->allExamples($parser);
public allExamples ( $class ) : array
return array

classExample() public method

Example: $snippet = $parser->classExample(Parser::class);
public classExample ( string $class, integer | string $index ) : Snippet
$class string the name of the class
$index integer | string The index of the example to return.
return Snippet

createIdentifier() public method

public createIdentifier ( $fqn, $indexOrName )

examples() public method

Example: Yeah, this example is pretty useless. $examples = $parser->examples($docBlock);
public examples ( DocBlock $docBlock, $fullyQualifiedName, string $file, integer $line, array $magicMethods = [] ) : array
$docBlock phpDocumentor\Reflection\DocBlock The DocBlock to parse
$file string The filename the docblock is in
$line integer The line where the tested method or class is declared.
$magicMethods array
return array

examplesFromClass() public method

Example: $examples = $parser->examplesFromClass($parser);
public examplesFromClass ( object | ReflectionClas\ReflectionClass $class ) : array
$class object | ReflectionClas\ReflectionClass An instance or reflector of the class to parse examples from.
return array

examplesFromMethod() public method

Example: $examples = $parser->examplesFromMethod($parser, 'examplesFromMethod');
public examplesFromMethod ( object $class, string | ReflectionMetho\ReflectionMethod $method ) : array
$class object An instance of the class to parse examples from.
$method string | ReflectionMetho\ReflectionMethod The name of the method to parse examples from.
return array

methodExample() public method

Example: $snippet = $parser->methodExample(Parser::class, 'methodExample'); Get the 2nd example (index=1) $snippet = $parser->methodExample(Parser::class, 'methodExample', 1);
public methodExample ( string $class, string $method, integer $index ) : Snippet
$class string The name of the class.
$method string The name of the method.
$index integer The 0-indexed example to return.
return Snippet