Download the PHP package rawr/phpdoc-parser without Composer
On this page you can find all versions of the php package rawr/phpdoc-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phpdoc-parser
PhpDoc parser
Lightweight parser of PhpDoc.
- Installation
- Composer
- Usage
- Tags
- Tag classes
- FQSEN Resolve
- Current limitations
- Fixed from the original
Installation
Installation for PHP 7.1 and later:
Usage
Parse annotations
The result is the following:
Tags
The following tags are already included in PhpDocumentor::tags()
:
@api
@author
@copyright
@deprecated
@example
@ignore
@internal
@link
@method
(all methods will be grouped inmethods
array)@package
@param
(all params will be grouped inparams
array)@property
(all properties will be grouped inproperties
array)@property-read
(also inproperties
array)@property-write
(also inproperties
array)@return
@see
@since
@throws
(all exceptions will be grouped inthrows
array)@todo
@uses
@used-by
@var
So if you only need to parse those tags, you can simply do:
Tag classes
Here's a list of available tags classes, that should cover most of the use cases:
Summery
ArrayTag
CustomTag
DescriptionTag
ExampleTag
FlagTag
MapTag
MethodTag
ModifyTag
MultiTag
NumberTag
RegExpTag
VarTag
WordTag
The following function is used in tags documentation, for short reference to parsing:
FQSEN Resolver
FQSEN stands for Fully Qualified Structural Element Name
. FQSEN convertor is used to expand class name or function name to fully unique name (so with full
namespace). For example, Foo
can be converted to Zoo\\Foo\\Bar
.
Such convertors are used in this lib. Some tags, that deal with variable types, or classes names, support adding them as a constructor parameter.
For example, TypeTag
, that can be used for parsing @return
tag, has the following constructor: TypeTag($name, $fqsenConvertor = null)
. If provided,
convertor expands the type, given as type of returned value in doc-comment. If ommited, the type will stay as it is in doc-comment.
Convertor can be provided in one of two ways:
$tags = PhpDocumentor::tags($fn)
- for all the tags, predefined inPhpDocumentor::tags()
$tags = $tags->add(new TypeTag('footag', $fn))
- for all the tags, that are explicitly added to predefined, it should be passed as a constructor parameter ( if it is supported by constructor).
After that create the parser from the tags as $parser = new PhpdocParser($tags)
.
The resolver function should accept a class name and return an expanded name.
Example
This example uses phpDocumentor/TypeResolver.
Current limitations
- Certain tags aren't yet supported, such as
@license
or@category
. -
Annotations aren't supported, for example
- As far as I'm aware this project does not support parsing inline tags yet
- Tag
@see
is only parsed once, instead of all occurrences - Tag
@since
ignores description - Tag
@version
ignores description - Tag
@var
doesn't allow for ignoring variable name - Tag
@link
ignores description - Tag
@deprecated
ignores description CustomTag
is not extensible enough, perhaps a new implementation is needed
Fixed from the original
The original implementation is in https://github.com/jasny/phpdoc-parser.
Features fixed and improved so far:
- Tags
@param
failed to handle multiline tags properly, now it's fixed - Typo
"summery"
to"summary"
- Improper parsing summary in multiple lines
- Added support for
@version
tag @method
interpretsstatic
properly- Fixed improper parsing of unclosed or improperly closed doc block
- Previous parser failed parsing for line endings
CR
andCRLF
, now it supports:LF
,CR
,CRLF
.