gitwtfhub

wtf is reflectiondocblock?

phpdocumentor/reflectiondocblock — explained in plain English

Analysis updated 2026-06-24

9,387PHPAudience · developerComplexity · 2/5LicenseSetup · easy

TL;DR

ReflectionDocBlock is a PHP library that parses PHPDoc comment blocks above functions and classes into queryable objects, making it easy to read summaries, descriptions, and tags like parameter types from code comments.

Mindmap

mindmap
  root((reflectiondocblock))
    What it does
      Parse PHPDoc comments
      Convert to objects
      Query tags and types
    Key concepts
      DocBlock format
      PHPDoc standard
      Summary and description
      Tags like param return
    API
      Factory create method
      Raw string or Reflection
      DocBlock object
    Use cases
      Custom annotations
      Doc generators
      Runtime type inspection
    Audience
      PHP framework authors

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Parse PHPDoc comments in your own PHP library to support custom annotations or extract type information at runtime.

REASON 2

Build a PHP documentation generator that reads structured code comments and exports them as structured data.

REASON 3

Inspect function parameter types and return values from DocBlocks without writing a custom comment parser.

What's in the stack?

PHPComposer

How it stacks up

phpdocumentor/reflectiondocblockdingo/apiswiftmailer/swiftmailer
Stars9,3879,3529,459
LanguagePHPPHPPHP
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min
MIT license, use freely in any project, commercial or open-source, just keep the copyright notice.

Wtf does this do

ReflectionDocBlock is a PHP library that reads and interprets DocBlocks, which are the structured comment blocks PHP developers place above functions, classes, and properties in their code. These comments follow a format called the PHPDoc standard, and they typically begin with a slash and two asterisks. The library parses those comment blocks and converts them into objects that code can inspect and query. If you are building a tool that needs to understand what a PHP function is supposed to do based on its comments, or if you want to support annotations in your own library, this component handles the parsing work for you. It is part of the phpDocumentor project, which is the standard documentation generator for PHP. Using it is fairly direct. You create a factory object and call its create method with either a raw comment string or a PHP reflection object that has a getDocComment method. The factory returns a DocBlock object. From that object you can retrieve the summary (the opening line of the comment), the full description, and any tags embedded in the comment such as types, parameters, or return values. The library is installed via Composer, the standard PHP package manager, with a single command. It carries an MIT license, which means it can be used freely in commercial and open-source projects alike. The README is short and covers only the basics of instantiation and querying. Additional examples are available in the repository's docs folder for anyone who needs to explore more advanced usage.

Yoink these prompts

Prompt 1
Show me how to use ReflectionDocBlock to read the @param and @return tags from a PHP function's DocBlock and print them as a plain-English summary.
Prompt 2
I'm building a PHP framework that supports custom @Route annotations in DocBlocks. Walk me through using ReflectionDocBlock's factory to parse those tags from controller methods.
Prompt 3
How do I install ReflectionDocBlock via Composer and write a script that accepts a PHP class name, reflects all its methods, and prints each method's DocBlock summary and parameter list?
Prompt 4
Use ReflectionDocBlock to validate that all public methods in a PHP class have a non-empty DocBlock summary and at least one @param tag, return a list of non-compliant methods.
Prompt 5
Explain the difference between passing a raw DocBlock string vs a PHP ReflectionMethod object to ReflectionDocBlock's factory, and when you'd use each approach.

Frequently asked questions

wtf is reflectiondocblock?

ReflectionDocBlock is a PHP library that parses PHPDoc comment blocks above functions and classes into queryable objects, making it easy to read summaries, descriptions, and tags like parameter types from code comments.

What language is reflectiondocblock written in?

Mainly PHP. The stack also includes PHP, Composer.

What license does reflectiondocblock use?

MIT license, use freely in any project, commercial or open-source, just keep the copyright notice.

How hard is reflectiondocblock to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is reflectiondocblock for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.