Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

ReflectionDocBlock

> 编程语言
Open source

ReflectionDocBlock ================== Introduction ------------ The ReflectionDocBlock component of phpDocumentor provides a DocBlock parse…

9.4K stars0 likes2 views
WebsiteGitHub

About

ReflectionDocBlock ================== Introduction ------------ The ReflectionDocBlock component of phpDocumentor provides a DocBlock parse…

ReflectionDocBlock

Introduction

The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser that is 100% compatible with the PHPDoc standard.

With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

Installation

bash
composer require phpdocumentor/reflection-docblock

Usage

In order to parse the DocBlock one needs a DocBlockFactory that can be instantiated using its createInstance factory method like this:

php
$factory  = \phpDocumentor\Reflection\DocBlockFactory::createInstance();

Then we can use the create method of the factory to interpret the DocBlock. Please note that it is also possible to provide a class that has the getDocComment() method, such as an object of type ReflectionClass, the create method will read that if it exists.

php
$docComment = <<<DOCCOMMENT
/**
 * This is an example of a summary.
 *
 * This is a Description. A Summary and Description are separated by either
 * two subsequent newlines (thus a whiteline in between as can be seen in this
 * example), or when the Summary ends with a dot (`.`) and some form of
 * whitespace.
 */
DOCCOMMENT;

$docblock = $factory->create($docComment);

The create method will yield an object of type \phpDocumentor\Reflection\DocBlock whose methods can be queried:

php
// Contains the summary for this DocBlock
$summary = $docblock->getSummary();

// Contains \phpDocumentor\Reflection\DocBlock\Description object
$description = $docblock->getDescription();

// You can either cast it to string
$description = (string) $docblock->getDescription();

// Or use the render method to get a string representation of the Description.
$description = $docblock->getDescription()->render();

For more examples it would be best to review the scripts in the /docs/examples folder.

Issues· 19 open

View all issuesOpen on GitHub
  • #449

    InvalidTag name with leading @

    Updated Mar 15, 2026
  • #439

    Add factories for `@template-extends` and `@template-implements`

    Updated Jan 21, 2026
  • #412

    BUG: @example tag not working

    Updated Jul 23, 2025
  • #372

    Add @template & Conditional return types

    Updated Jul 14, 2024
  • #346

    Add more information when an InvalidTag occurs and a link to the phpDocumentor documentation

    Updated Dec 4, 2022
  • #255

    Inline tag handling with nested braces is not working as expected

    bughelp wantedUpdated Jun 19, 2022
  • #335

    Referring a global variable with @see $varname in a docblock causes

    Updated May 23, 2022
  • #199

    Support Annotation-style tags

    Updated Jan 27, 2020
  • #180

    FQSEN resolution fails on anonymous classes

    Updated Oct 10, 2019
  • #87

    Location information for tags

    help wantedin discussionUpdated Aug 23, 2018

> Tags

PHPdocblocks

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言