Download the PHP package stein197/doxer without Composer
On this page you can find all versions of the php package stein197/doxer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package doxer
PHP docblock comment parser
Simple PHP documentation comment parser. First, install it via composer as follows:
And then use it like this:
Each docblock comment can have tags which start with @
sign and each tag can have an array of properties and an optional description. The next list shows which tags are currently supported:
- @author
<name>
[<email>]
- @deprecated
[<version>]
[<description>]
- @license
[<url>]
[<description>]
- @link
<uri>
[<description>]
- @param
<type>
<name>
[<description>]
- @return
<type>
[<description>]
- @see
<uri>
[<description>]
- @since
<version>
[<description>]
- @var
<type>
[<name>]
[<description>]
- @uses
<uri>
[<description>]
- @throws
<type>
[<description>]
So for example if tag "@return string A string" is parsed, it's properties will only contain type
entry:
But if the tag does not match any of predefined, then it will be parsed as @tag [<description>]
. So for example if tag "@nonexistent string A string" is parsed, all it will contain is a description:
If tag to be parsed can have properties but has incorrect syntax, properties and description will be nulls:
NOTE! If tag accepts name property which will start with
$
sign (@param
,@var
tags), then after retrievingname
property the name will be retrieved without leading "$":
API
The only class that is supposed to be used is Stein197\Doxer\Doc
, which accepts a docblock string as the only constructor parameter. Then the next methods could be used:
Method | Return type | Description |
---|---|---|
getDescription() |
string |
Returns docblock description or null if it's not present |
getTags(?string $name = null) |
Stein197\Doxer\Tag[] |
Returns an array of tags or null if there are no tags present. If optional parameter is passed then only tags with matching name will be retrieved |
exists() |
bool |
Returns true if doc exists. Even empty description block treats as existing one |
The next table contains list of Stein197\Doxer\Tag
public methods:
Method | Return type | Description |
---|---|---|
getDescription() |
string |
Returns tag description or null if it's not present |
getName() |
string |
Returns the name of a tag without leading @ sign |
getProperties() |
string[] |
Returns an array of tag properties or null if there are no properties |
getProperty(string $name) |
string |
Returns single property value or null if there is no such property |
Tests
To run unit tests call the test
composer script: