Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DocBlockFactory.php

function DocBlockFactory::create

Parameters

object|string $docblock A string containing the DocBlock to parse or an object supporting the: getDocComment method (such as a ReflectionClass object).

Overrides DocBlockFactoryInterface::create

File

vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php, line 119

Class

DocBlockFactory

Namespace

phpDocumentor\Reflection

Code

public function create($docblock, ?Types\Context $context = null, ?Location $location = null) : DocBlock {
    if (is_object($docblock)) {
        if (!method_exists($docblock, 'getDocComment')) {
            $exceptionMessage = 'Invalid object passed; the given object must support the getDocComment method';
            throw new InvalidArgumentException($exceptionMessage);
        }
        $docblock = $docblock->getDocComment();
        Assert::string($docblock);
    }
    Assert::stringNotEmpty($docblock);
    if ($context === null) {
        $context = new Types\Context('');
    }
    $parts = $this->splitDocBlock($this->stripDocComment($docblock));
    [
        $templateMarker,
        $summary,
        $description,
        $tags,
    ] = $parts;
    return new DocBlock($summary, $description ? $this->descriptionFactory
        ->create($description, $context) : null, $this->parseTagBlock($tags, $context), $context, $location, $templateMarker === '#@+', $templateMarker === '#@-');
}
RSS feed
Powered by Drupal