GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - php-type-language/phpdoc: [READ ONLY] 🗃️ Library for recognizing PHPDoc Tags in PHP DocBlock comments

BranchesTags
Open more actions menu

Latest commit

 

History

197 Commits
197 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
resources
resources
 
 
src
src
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpstan.neon
phpstan.neon
 
 
phpunit.xml
phpunit.xml
 
 

Repository files navigation

PHP 8.4+ Latest Stable Version Latest Unstable Version License MIT


The reference PHPDoc parser for TypeLang. It turns a raw /** ... */ comment into an immutable, iterable object graph of its description and tags.

Full documentation is available at typelang.dev.

Installation

Install the package via Composer:

composer require type-lang/phpdoc

Requirements:

  • PHP 8.1+

Usage

DocBlockParser::parse() returns a DocBlock — an immutable collection of the comment's description and tags:

use TypeLang\PhpDoc\DocBlockParser;

$parser = new DocBlockParser();

$block = $parser->parse(<<<'PHPDOC'
    /**
     * Sends a notification to the given recipient.
     *
     * @see Mailer::send() The underlying transport.
     * @link https://example.com/docs Delivery documentation.
     * @return bool
     */
    PHPDOC);

// The leading description (everything before the first tag)
echo $block->description;
// "Sends a notification to the given recipient."

// Tags form an ordered, countable, iterable collection
echo \count($block); // 3

foreach ($block as $tag) {
    echo $tag->name; // "see", "link", "return"
}

// Known tags expose their parsed parts
$see = $block[0]; // SeeTag
echo $see->reference; // "Mailer::send()"

Structure

A DocBlock is composed of three kinds of elements:

  • DocBlock — the whole comment; behaves as a Countable, IteratorAggregate and ArrayAccess collection of its tags.
  • Description — the leading text. A plain Description is just a string; a TaggedDescription also holds inline tags like {@see ...}.
  • Tag — a name (without the leading @) and an optional description. Known tags (@see, @link, ...) extend the base Tag with their own parsed parts; an unregistered tag keeps its whole suffix as the description.

See the documentation for the full list of supported tags.

About

[READ ONLY] 🗃️ Library for recognizing PHPDoc Tags in PHP DocBlock comments

typelang.dev

Topics

analyzercommentsdocblockparserphpdocphpdoc-parserreadertypes

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity
Custom properties

Stars

10 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.