mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 18:13:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6fad15f7c | ||
|
|
836d531676 | ||
|
|
bba116ba9d | ||
|
|
23fa082874 | ||
|
|
e6811e927f | ||
|
|
05596d7626 | ||
|
|
e5e172728c | ||
|
|
9a2f0eb8ba | ||
|
|
bf44b757fe | ||
|
|
e6526132ee | ||
|
|
6b7c110b33 | ||
|
|
ad1e63e15c | ||
|
|
6eafab0ff3 | ||
|
|
fe49c3d9ee | ||
|
|
3f6ec1c280 | ||
|
|
72df918400 | ||
|
|
c10c41e932 | ||
|
|
977da00f0f | ||
|
|
7e5538a638 | ||
|
|
295d2fba38 | ||
|
|
ef9f04dd59 | ||
|
|
6171834fde | ||
|
|
7f729dc9a7 | ||
|
|
144140cd39 | ||
|
|
be72a2d318 | ||
|
|
6d03fa81d9 | ||
|
|
3e7bb6e171 | ||
|
|
0f32bd0e61 | ||
|
|
b0b90f44f0 | ||
|
|
6b69015d83 | ||
|
|
053005ed4e | ||
|
|
64165bd4ba | ||
|
|
9b08619fbd | ||
|
|
3dcbd98b5d | ||
|
|
d411a2bc7e | ||
|
|
e6a969a640 | ||
|
|
708c2c9253 | ||
|
|
d68dbdc53d | ||
|
|
fb5dfa51d4 | ||
|
|
ae02953010 | ||
|
|
fd0ac20074 | ||
|
|
21feb61eb5 | ||
|
|
280a3ce56d | ||
|
|
0604d62704 | ||
|
|
a66d783afd | ||
|
|
84de81c009 | ||
|
|
38743b6779 | ||
|
|
0d52cb6389 | ||
|
|
2281569ebc | ||
|
|
e0faa7f04f | ||
|
|
39a08094f1 | ||
|
|
07b195e1ee | ||
|
|
0bca477a34 | ||
|
|
66a7d3bf31 | ||
|
|
2331fc92f6 | ||
|
|
b1922e00de | ||
|
|
53ba484043 | ||
|
|
cfb3ebea55 | ||
|
|
c33820b04b | ||
|
|
280c4a1d44 | ||
|
|
66ae84e9d7 | ||
|
|
3023fb2220 | ||
|
|
a9b6edf3ce | ||
|
|
f3d1a28bf7 | ||
|
|
fd9e6bd26d | ||
|
|
d5e4b2ec73 | ||
|
|
bae8be0dcd | ||
|
|
3a5d30e027 | ||
|
|
d2414cd3dc | ||
|
|
070b13745a | ||
|
|
df7807cd73 | ||
|
|
b07e3c36b7 | ||
|
|
163dd7877e | ||
|
|
6d705c1a0f | ||
|
|
ab0bcb8d31 | ||
|
|
ac6e37af97 | ||
|
|
4a7affe15b | ||
|
|
b7797b4e1a | ||
|
|
8b529636bf | ||
|
|
2e9fd6a2e8 | ||
|
|
cbb14bab1e | ||
|
|
d57128e65c | ||
|
|
d9c0928243 | ||
|
|
63c9de4e8b | ||
|
|
76619d4a16 | ||
|
|
47d3f86c53 | ||
|
|
cfb104b8c8 | ||
|
|
5c51ccf185 | ||
|
|
5d93f42598 | ||
|
|
eb83d810de | ||
|
|
6f0fc03c49 | ||
|
|
b09525332f | ||
|
|
c2796044a6 |
@@ -0,0 +1,10 @@
|
||||
# Path-based git attributes
|
||||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
|
||||
|
||||
# Ignore all test and documentation with "export-ignore".
|
||||
/.gitignore export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/composer.lock export-ignore
|
||||
/phpunit.xml.dist export-ignore
|
||||
/tests export-ignore
|
||||
@@ -0,0 +1,43 @@
|
||||
name: Unit Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
php-tests:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
env:
|
||||
COMPOSER_NO_INTERACTION: 1
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php: [8.1, 8.0, 7.4, 7.3, 7.2]
|
||||
dependency-version: [prefer-lowest, prefer-stable]
|
||||
|
||||
name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
|
||||
|
||||
- name: Execute Unit Tests
|
||||
run: vendor/bin/phpunit
|
||||
+2
-1
@@ -1,2 +1,3 @@
|
||||
.idea
|
||||
vendor
|
||||
composer.lock
|
||||
vendor
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
script:
|
||||
- vendor/phpunit/phpunit/composer/bin/phpunit
|
||||
|
||||
before_script:
|
||||
- sudo apt-get -qq update > /dev/null
|
||||
- phpenv rehash > /dev/null
|
||||
- composer selfupdate --quiet
|
||||
- composer install --dev
|
||||
- vendor/phpunit/phpunit/composer/bin/phpunit
|
||||
- composer update --dev
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#phpdocumentor"
|
||||
email:
|
||||
- [email protected]
|
||||
- [email protected]
|
||||
- [email protected]
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010 Mike van Riel
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,4 +1,4 @@
|
||||
The ReflectionDocBlock Component
|
||||
The ReflectionDocBlock Component [](https://travis-ci.org/phpDocumentor/ReflectionDocBlock)
|
||||
================================
|
||||
|
||||
Introduction
|
||||
@@ -7,7 +7,7 @@ Introduction
|
||||
The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser
|
||||
that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest).
|
||||
|
||||
With this component can a library provide support for annotations via DocBlocks
|
||||
With this component, a library can provide support for annotations via DocBlocks
|
||||
or otherwise retrieve information that is embedded in a DocBlock.
|
||||
|
||||
> **Note**: *this is a core component of phpDocumentor and is constantly being
|
||||
|
||||
+13
-5
@@ -1,18 +1,26 @@
|
||||
{
|
||||
"name": "phpdocumentor/reflection-docblock",
|
||||
"name": "barryvdh/reflection-docblock",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Mike van Riel", "email": "[email protected]"}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2",
|
||||
"dflydev/markdown": "1.0.*"
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {"phpDocumentor": ["src/"]}
|
||||
"psr-0": {"Barryvdh": ["src/"]}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*@stable"
|
||||
"phpunit/phpunit": "^8.5.14|^9"
|
||||
},
|
||||
"suggest": {
|
||||
"dflydev/markdown": "~1.0",
|
||||
"erusev/parsedown": "~1.0"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
-67
@@ -1,67 +0,0 @@
|
||||
{
|
||||
"hash": "89c7387ec02d39de3c07849e525f95e4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dflydev/markdown",
|
||||
"version": "v1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dflydev/dflydev-markdown.git",
|
||||
"reference": "v1.0.2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/dflydev/dflydev-markdown/zipball/v1.0.2",
|
||||
"reference": "v1.0.2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"time": "2012-01-15 19:36:37",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"dflydev\\markdown": "src"
|
||||
}
|
||||
},
|
||||
"license": [
|
||||
"New BSD License"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dragonfly Development Inc.",
|
||||
"email": "[email protected]",
|
||||
"homepage": "http://dflydev.com"
|
||||
},
|
||||
{
|
||||
"name": "Beau Simensen",
|
||||
"email": "[email protected]",
|
||||
"homepage": "http://beausimensen.com"
|
||||
},
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"homepage": "http://michelf.com"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net"
|
||||
}
|
||||
],
|
||||
"description": "PHP Markdown & Extra",
|
||||
"homepage": "http://github.com/dflydev/dflydev-markdown",
|
||||
"keywords": [
|
||||
"markdown"
|
||||
]
|
||||
}
|
||||
],
|
||||
"packages-dev": null,
|
||||
"aliases": [
|
||||
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [
|
||||
|
||||
]
|
||||
}
|
||||
+6
-7
@@ -1,14 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<phpunit colors="true" strict="true" bootstrap="vendor/autoload.php">
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="phpDocumentor\Reflection\DocBlock">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
||||
@@ -0,0 +1,485 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock\Location;
|
||||
|
||||
/**
|
||||
* Parses the DocBlock for any structure.
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DocBlock implements \Reflector
|
||||
{
|
||||
/** @var string The opening line for this docblock. */
|
||||
protected $short_description = '';
|
||||
|
||||
/**
|
||||
* @var DocBlock\Description The actual
|
||||
* description for this docblock.
|
||||
*/
|
||||
protected $long_description = null;
|
||||
|
||||
/**
|
||||
* @var Tag[] An array containing all
|
||||
* the tags in this docblock; except inline.
|
||||
*/
|
||||
protected $tags = array();
|
||||
|
||||
/** @var Context Information about the context of this DocBlock. */
|
||||
protected $context = null;
|
||||
|
||||
/** @var Location Information about the location of this DocBlock. */
|
||||
protected $location = null;
|
||||
|
||||
/** @var bool Is this DocBlock (the start of) a template? */
|
||||
protected $isTemplateStart = false;
|
||||
|
||||
/** @var bool Does this DocBlock signify the end of a DocBlock template? */
|
||||
protected $isTemplateEnd = false;
|
||||
|
||||
/**
|
||||
* Parses the given docblock and populates the member fields.
|
||||
*
|
||||
* The constructor may also receive namespace information such as the
|
||||
* current namespace and aliases. This information is used by some tags
|
||||
* (e.g. @return, @param, etc.) to turn a relative Type into a FQCN.
|
||||
*
|
||||
* @param \Reflector|string $docblock A docblock comment (including
|
||||
* asterisks) or reflector supporting the getDocComment method.
|
||||
* @param Context $context The context in which the DocBlock
|
||||
* occurs.
|
||||
* @param Location $location The location within the file that this
|
||||
* DocBlock occurs in.
|
||||
*
|
||||
* @throws \InvalidArgumentException if the given argument does not have the
|
||||
* getDocComment method.
|
||||
*/
|
||||
public function __construct(
|
||||
$docblock,
|
||||
Context $context = null,
|
||||
Location $location = null
|
||||
) {
|
||||
if (is_object($docblock)) {
|
||||
if (!method_exists($docblock, 'getDocComment')) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Invalid object passed; the given reflector must support '
|
||||
. 'the getDocComment method'
|
||||
);
|
||||
}
|
||||
|
||||
$docblock = $docblock->getDocComment();
|
||||
}
|
||||
|
||||
$docblock = $this->cleanInput($docblock);
|
||||
|
||||
list($templateMarker, $short, $long, $tags) = $this->splitDocBlock($docblock);
|
||||
$this->isTemplateStart = $templateMarker === '#@+';
|
||||
$this->isTemplateEnd = $templateMarker === '#@-';
|
||||
$this->short_description = $short;
|
||||
$this->long_description = new DocBlock\Description($long, $this);
|
||||
$this->parseTags($tags);
|
||||
|
||||
$this->context = $context;
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the asterisks from the DocBlock comment.
|
||||
*
|
||||
* @param string $comment String containing the comment text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function cleanInput($comment)
|
||||
{
|
||||
$comment = trim(
|
||||
preg_replace(
|
||||
'#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
|
||||
'$1',
|
||||
$comment
|
||||
)
|
||||
);
|
||||
|
||||
// reg ex above is not able to remove */ from a single line docblock
|
||||
if (substr($comment, -2) == '*/') {
|
||||
$comment = trim(substr($comment, 0, -2));
|
||||
}
|
||||
|
||||
// normalize strings
|
||||
$comment = str_replace(array("\r\n", "\r"), "\n", $comment);
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the DocBlock into a template marker, summary, description and block of tags.
|
||||
*
|
||||
* @param string $comment Comment to split into the sub-parts.
|
||||
*
|
||||
* @author Richard van Velzen (@_richardJ) Special thanks to Richard for the regex responsible for the split.
|
||||
* @author Mike van Riel <[email protected]> for extending the regex with template marker support.
|
||||
*
|
||||
* @return string[] containing the template marker (if any), summary, description and a string containing the tags.
|
||||
*/
|
||||
protected function splitDocBlock($comment)
|
||||
{
|
||||
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This
|
||||
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
|
||||
// performance impact of running a regular expression
|
||||
if (strpos($comment, '@') === 0) {
|
||||
return array('', '', '', $comment);
|
||||
}
|
||||
|
||||
// clears all extra horizontal whitespace from the line endings to prevent parsing issues
|
||||
$comment = preg_replace('/\h*$/Sum', '', $comment);
|
||||
|
||||
/*
|
||||
* Splits the docblock into a template marker, short description, long description and tags section
|
||||
*
|
||||
* - The template marker is empty, #@+ or #@- if the DocBlock starts with either of those (a newline may
|
||||
* occur after it and will be stripped).
|
||||
* - The short description is started from the first character until a dot is encountered followed by a
|
||||
* newline OR two consecutive newlines (horizontal whitespace is taken into account to consider spacing
|
||||
* errors). This is optional.
|
||||
* - The long description, any character until a new line is encountered followed by an @ and word
|
||||
* characters (a tag). This is optional.
|
||||
* - Tags; the remaining characters
|
||||
*
|
||||
* Big thanks to RichardJ for contributing this Regular Expression
|
||||
*/
|
||||
preg_match(
|
||||
'/
|
||||
\A
|
||||
# 1. Extract the template marker
|
||||
(?:(\#\@\+|\#\@\-)\n?)?
|
||||
|
||||
# 2. Extract the summary
|
||||
(?:
|
||||
(?! @\pL ) # The summary may not start with an @
|
||||
(
|
||||
[^\n.]+
|
||||
(?:
|
||||
(?! \. \n | \n{2} ) # End summary upon a dot followed by newline or two newlines
|
||||
[\n.] (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line
|
||||
[^\n.]+ # Include anything else
|
||||
)*
|
||||
\.?
|
||||
)?
|
||||
)
|
||||
|
||||
# 3. Extract the description
|
||||
(?:
|
||||
\s* # Some form of whitespace _must_ precede a description because a summary must be there
|
||||
(?! @\pL ) # The description may not start with an @
|
||||
(
|
||||
[^\n]+
|
||||
(?: \n+
|
||||
(?! [ \t]* @\pL ) # End description when an @ is found as first character on a new line
|
||||
[^\n]+ # Include anything else
|
||||
)*
|
||||
)
|
||||
)?
|
||||
|
||||
# 4. Extract the tags (anything that follows)
|
||||
(\s+ [\s\S]*)? # everything that follows
|
||||
/ux',
|
||||
$comment,
|
||||
$matches
|
||||
);
|
||||
array_shift($matches);
|
||||
|
||||
while (count($matches) < 4) {
|
||||
$matches[] = '';
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag objects.
|
||||
*
|
||||
* @param string $tags Tag block to parse.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function parseTags($tags)
|
||||
{
|
||||
$result = array();
|
||||
$tags = trim($tags);
|
||||
if ('' !== $tags) {
|
||||
if ('@' !== $tags[0]) {
|
||||
throw new \LogicException(
|
||||
'A tag block started with text instead of an actual tag,'
|
||||
. ' this makes the tag block invalid: ' . $tags
|
||||
);
|
||||
}
|
||||
foreach (explode("\n", $tags) as $tag_line) {
|
||||
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
||||
$result[] = $tag_line;
|
||||
} else {
|
||||
$result[count($result) - 1] .= "\n" . $tag_line;
|
||||
}
|
||||
}
|
||||
|
||||
// create proper Tag objects
|
||||
foreach ($result as $key => $tag_line) {
|
||||
$result[$key] = Tag::createInstance(trim($tag_line), $this);
|
||||
}
|
||||
}
|
||||
|
||||
$this->tags = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text portion of the doc block.
|
||||
*
|
||||
* Gets the text portion (short and long description combined) of the doc
|
||||
* block.
|
||||
*
|
||||
* @return string The text portion of the doc block.
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
$short = $this->getShortDescription();
|
||||
$long = $this->getLongDescription()->getContents();
|
||||
|
||||
if ($long) {
|
||||
return "{$short}\n\n{$long}";
|
||||
} else {
|
||||
return $short;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text portion of the doc block.
|
||||
*
|
||||
* Sets the text portion (short and long description combined) of the doc
|
||||
* block.
|
||||
*
|
||||
* @param string $docblock The new text portion of the doc block.
|
||||
*
|
||||
* @return $this This doc block.
|
||||
*/
|
||||
public function setText($comment)
|
||||
{
|
||||
list(,$short, $long) = $this->splitDocBlock($comment);
|
||||
$this->short_description = $short;
|
||||
$this->long_description = new DocBlock\Description($long, $this);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns the opening line or also known as short description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShortDescription()
|
||||
{
|
||||
return $this->short_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full description or also known as long description.
|
||||
*
|
||||
* @return DocBlock\Description
|
||||
*/
|
||||
public function getLongDescription()
|
||||
{
|
||||
return $this->long_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this DocBlock is the start of a Template section.
|
||||
*
|
||||
* A Docblock may serve as template for a series of subsequent DocBlocks. This is indicated by a special marker
|
||||
* (`#@+`) that is appended directly after the opening `/**` of a DocBlock.
|
||||
*
|
||||
* An example of such an opening is:
|
||||
*
|
||||
* ```
|
||||
* /**#@+
|
||||
* * My DocBlock
|
||||
* * /
|
||||
* ```
|
||||
*
|
||||
* The description and tags (not the summary!) are copied onto all subsequent DocBlocks and also applied to all
|
||||
* elements that follow until another DocBlock is found that contains the closing marker (`#@-`).
|
||||
*
|
||||
* @see self::isTemplateEnd() for the check whether a closing marker was provided.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTemplateStart()
|
||||
{
|
||||
return $this->isTemplateStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this DocBlock is the end of a Template section.
|
||||
*
|
||||
* @see self::isTemplateStart() for a more complete description of the Docblock Template functionality.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTemplateEnd()
|
||||
{
|
||||
return $this->isTemplateEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current context.
|
||||
*
|
||||
* @return Context
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current location.
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tags for this DocBlock.
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of tags matching the given name. If no tags are found
|
||||
* an empty array is returned.
|
||||
*
|
||||
* @param string $name String to search by.
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTagsByName($name)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($this->getTags() as $tag) {
|
||||
if ($tag->getName() != $name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $tag;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a tag of a certain type is present in this DocBlock.
|
||||
*
|
||||
* @param string $name Tag name to check for.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTag($name)
|
||||
{
|
||||
/** @var Tag $tag */
|
||||
foreach ($this->getTags() as $tag) {
|
||||
if ($tag->getName() == $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a tag at the end of the list of tags.
|
||||
*
|
||||
* @param Tag $tag The tag to add.
|
||||
*
|
||||
* @return Tag The newly added tag.
|
||||
*
|
||||
* @throws \LogicException When the tag belongs to a different DocBlock.
|
||||
*/
|
||||
public function appendTag(Tag $tag)
|
||||
{
|
||||
if (null === $tag->getDocBlock()) {
|
||||
$tag->setDocBlock($this);
|
||||
}
|
||||
|
||||
if ($tag->getDocBlock() === $this) {
|
||||
$this->tags[] = $tag;
|
||||
} else {
|
||||
throw new \LogicException(
|
||||
'This tag belongs to a different DocBlock object.'
|
||||
);
|
||||
}
|
||||
|
||||
return $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a tag from the list of tags.
|
||||
*
|
||||
* @param Tag $tag The tag to be deleted.
|
||||
*
|
||||
* @return bool True if the tag was deleted.
|
||||
*/
|
||||
public function deleteTag(Tag $tag)
|
||||
{
|
||||
if (($key = array_search($tag, $this->tags)) !== false) {
|
||||
unset($this->tags[$key]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a string representation of this object.
|
||||
*
|
||||
* @todo determine the exact format as used by PHP Reflection and
|
||||
* implement it.
|
||||
*
|
||||
* @return string
|
||||
* @codeCoverageIgnore Not yet implemented
|
||||
*/
|
||||
public static function export()
|
||||
{
|
||||
throw new \Exception('Not yet implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported information (we should use the export static method
|
||||
* BUT this throws an exception at this point).
|
||||
*
|
||||
* @return string
|
||||
* @codeCoverageIgnore Not yet implemented
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'Not yet implemented';
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* The context in which a DocBlock occurs.
|
||||
+57
-18
@@ -10,9 +10,9 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* Parses a Description of a DocBlock or tag.
|
||||
@@ -29,26 +29,22 @@ class Description implements \Reflector
|
||||
/** @var array The contents, as an array of strings and Tag objects. */
|
||||
protected $parsedContents = null;
|
||||
|
||||
/** @var \phpDocumentor\Reflection\DocBlock\Tags[] */
|
||||
protected $tags = array();
|
||||
|
||||
/** @var DocBlock The DocBlock which this description belongs to. */
|
||||
protected $docblock = null;
|
||||
|
||||
/**
|
||||
* Populates the fields of a description.
|
||||
*
|
||||
* @param string $content The DocBlock contents without asterisks.
|
||||
* @param string $content The description's conetnts.
|
||||
* @param DocBlock $docblock The DocBlock which this description belongs to.
|
||||
*/
|
||||
public function __construct($content, DocBlock $docblock = null)
|
||||
{
|
||||
$this->contents = trim($content);
|
||||
$this->docblock = $docblock;
|
||||
$this->setContent($content)->setDocBlock($docblock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text of this description.
|
||||
* Gets the text of this description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -57,6 +53,21 @@ class Description implements \Reflector
|
||||
return $this->contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text of this description.
|
||||
*
|
||||
* @param string $content The new text of this description.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->contents = trim($content);
|
||||
|
||||
$this->parsedContents = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed text of this description.
|
||||
*
|
||||
@@ -98,10 +109,12 @@ class Description implements \Reflector
|
||||
)
|
||||
\}/Sux',
|
||||
$this->contents,
|
||||
null,
|
||||
-1,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
||||
|
||||
$count = count($this->parsedContents);
|
||||
for ($i=1; $i<$count; $i += 2) {
|
||||
$this->parsedContents[$i] = Tag::createInstance(
|
||||
$this->parsedContents[$i],
|
||||
$this->docblock
|
||||
@@ -111,7 +124,7 @@ class Description implements \Reflector
|
||||
//In order to allow "literal" inline tags, the otherwise invalid
|
||||
//sequence "{@}" is changed to "@", and "{}" is changed to "}".
|
||||
//See unit tests for examples.
|
||||
for ($i=0, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
||||
for ($i=0; $i<$count; $i += 2) {
|
||||
$this->parsedContents[$i] = str_replace(
|
||||
array('{@}', '{}'),
|
||||
array('@', '}'),
|
||||
@@ -127,7 +140,7 @@ class Description implements \Reflector
|
||||
*
|
||||
* @todo this should become a more intelligent piece of code where the
|
||||
* configuration contains a setting what format long descriptions are.
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore Will be removed soon, in favor of adapters at
|
||||
* PhpDocumentor itself that will process text in various formats.
|
||||
*
|
||||
@@ -148,7 +161,10 @@ class Description implements \Reflector
|
||||
);
|
||||
}
|
||||
|
||||
if (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
||||
if (class_exists('Parsedown')) {
|
||||
$markdown = \Parsedown::instance();
|
||||
$result = $markdown->parse($result);
|
||||
} elseif (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
||||
$markdown = new \dflydev\markdown\MarkdownExtraParser();
|
||||
$result = $markdown->transformMarkdown($result);
|
||||
}
|
||||
@@ -156,6 +172,31 @@ class Description implements \Reflector
|
||||
return trim($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the docblock this tag belongs to.
|
||||
*
|
||||
* @return DocBlock The docblock this description belongs to.
|
||||
*/
|
||||
public function getDocBlock()
|
||||
{
|
||||
return $this->docblock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the docblock this tag belongs to.
|
||||
*
|
||||
* @param DocBlock $docblock The new docblock this description belongs to.
|
||||
* Setting NULL removes any association.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocBlock(DocBlock $docblock = null)
|
||||
{
|
||||
$this->docblock = $docblock;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a string representation of this object.
|
||||
*
|
||||
@@ -171,14 +212,12 @@ class Description implements \Reflector
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported information (we should use the export static method
|
||||
* BUT this throws an exception at this point).
|
||||
* Returns the long description as a string.
|
||||
*
|
||||
* @return string
|
||||
* @codeCoverageIgnore Not yet implemented
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'Not yet implemented';
|
||||
return $this->getContents();
|
||||
}
|
||||
}
|
||||
+32
-9
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* The location a DocBlock occurs within a file.
|
||||
@@ -22,17 +22,16 @@ namespace phpDocumentor\Reflection\DocBlock;
|
||||
class Location
|
||||
{
|
||||
/** @var int Line where the DocBlock text starts. */
|
||||
protected $line_number = 0;
|
||||
protected $lineNumber = 0;
|
||||
|
||||
/** @var int Column where the DocBlock text starts. */
|
||||
protected $column_number = 0;
|
||||
protected $columnNumber = 0;
|
||||
|
||||
public function __construct(
|
||||
$line_number = 0,
|
||||
$column_number = 0
|
||||
$lineNumber = 0,
|
||||
$columnNumber = 0
|
||||
) {
|
||||
$this->line_number = (int)$line_number;
|
||||
$this->column_number = (int)$column_number;
|
||||
$this->setLineNumber($lineNumber)->setColumnNumber($columnNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +39,19 @@ class Location
|
||||
*/
|
||||
public function getLineNumber()
|
||||
{
|
||||
return $this->line_number;
|
||||
return $this->lineNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $lineNumber
|
||||
* @return $this
|
||||
*/
|
||||
public function setLineNumber($lineNumber)
|
||||
{
|
||||
$this->lineNumber = (int)$lineNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,6 +59,18 @@ class Location
|
||||
*/
|
||||
public function getColumnNumber()
|
||||
{
|
||||
return $this->column_number;
|
||||
return $this->columnNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $columnNumber
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnNumber($columnNumber)
|
||||
{
|
||||
$this->columnNumber = (int)$columnNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Barry vd. Heuvel <[email protected]>
|
||||
* @copyright 2013 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* Serializes a DocBlock instance.
|
||||
*
|
||||
* @author Barry vd. Heuvel <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class Serializer
|
||||
{
|
||||
|
||||
/** @var string The string to indent the comment with. */
|
||||
protected $indentString = ' ';
|
||||
|
||||
/** @var int The number of times the indent string is repeated. */
|
||||
protected $indent = 0;
|
||||
|
||||
/** @var bool Whether to indent the first line. */
|
||||
protected $isFirstLineIndented = true;
|
||||
|
||||
/** @var int|null The max length of a line. */
|
||||
protected $lineLength = null;
|
||||
|
||||
/** @var bool Separate tag groups. */
|
||||
protected $separateTags = false;
|
||||
|
||||
/**
|
||||
* Create a Serializer instance.
|
||||
*
|
||||
* @param int $indent The number of times the indent string is
|
||||
* repeated.
|
||||
* @param string $indentString The string to indent the comment with.
|
||||
* @param bool $indentFirstLine Whether to indent the first line.
|
||||
* @param int|null $lineLength The max length of a line or NULL to
|
||||
* disable line wrapping.
|
||||
* @param bool $separateTags Separate tag groups.
|
||||
*/
|
||||
public function __construct(
|
||||
$indent = 0,
|
||||
$indentString = ' ',
|
||||
$indentFirstLine = true,
|
||||
$lineLength = null,
|
||||
$separateTags = false
|
||||
) {
|
||||
$this->setIndentationString($indentString);
|
||||
$this->setIndent($indent);
|
||||
$this->setIsFirstLineIndented($indentFirstLine);
|
||||
$this->setLineLength($lineLength);
|
||||
$this->setSeparateTags($separateTags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the string to indent comments with.
|
||||
*
|
||||
* @param string $indentationString The string to indent comments with.
|
||||
*
|
||||
* @return $this This serializer object.
|
||||
*/
|
||||
public function setIndentationString($indentString)
|
||||
{
|
||||
$this->indentString = (string)$indentString;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string to indent comments with.
|
||||
*
|
||||
* @return string The indent string.
|
||||
*/
|
||||
public function getIndentationString()
|
||||
{
|
||||
return $this->indentString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of indents.
|
||||
*
|
||||
* @param int $indent The number of times the indent string is repeated.
|
||||
*
|
||||
* @return $this This serializer object.
|
||||
*/
|
||||
public function setIndent($indent)
|
||||
{
|
||||
$this->indent = (int)$indent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of indents.
|
||||
*
|
||||
* @return int The number of times the indent string is repeated.
|
||||
*/
|
||||
public function getIndent()
|
||||
{
|
||||
return $this->indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the first line should be indented.
|
||||
*
|
||||
* Sets whether or not the first line (the one with the "/**") should be
|
||||
* indented.
|
||||
*
|
||||
* @param bool $indentFirstLine The new value for this setting.
|
||||
*
|
||||
* @return $this This serializer object.
|
||||
*/
|
||||
public function setIsFirstLineIndented($indentFirstLine)
|
||||
{
|
||||
$this->isFirstLineIndented = (bool)$indentFirstLine;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not the first line should be indented.
|
||||
*
|
||||
* @return bool Whether or not the first line should be indented.
|
||||
*/
|
||||
public function isFirstLineIndented()
|
||||
{
|
||||
return $this->isFirstLineIndented;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the line length.
|
||||
*
|
||||
* Sets the length of each line in the serialization. Content will be
|
||||
* wrapped within this limit.
|
||||
*
|
||||
* @param int|null $lineLength The length of each line. NULL to disable line
|
||||
* wrapping altogether.
|
||||
*
|
||||
* @return $this This serializer object.
|
||||
*/
|
||||
public function setLineLength($lineLength)
|
||||
{
|
||||
$this->lineLength = null === $lineLength ? null : (int)$lineLength;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the line length.
|
||||
*
|
||||
* @return int|null The length of each line or NULL if line wrapping is
|
||||
* disabled.
|
||||
*/
|
||||
public function getLineLength()
|
||||
{
|
||||
return $this->lineLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether there should be an empty line between tag groups.
|
||||
*
|
||||
* @param bool $separateTags The new value for this setting.
|
||||
*
|
||||
* @return $this This serializer object.
|
||||
*/
|
||||
public function setSeparateTags($separateTags)
|
||||
{
|
||||
$this->separateTags = (bool)$separateTags;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether there should be an empty line between tag groups.
|
||||
*
|
||||
* @return bool Whether there should be an empty line between tag groups.
|
||||
*/
|
||||
public function getSeparateTags()
|
||||
{
|
||||
return $this->separateTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a DocBlock comment.
|
||||
*
|
||||
* @param DocBlock The DocBlock to serialize.
|
||||
*
|
||||
* @return string The serialized doc block.
|
||||
*/
|
||||
public function getDocComment(DocBlock $docblock)
|
||||
{
|
||||
$indent = str_repeat($this->indentString, $this->indent);
|
||||
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
||||
|
||||
$text = $docblock->getText();
|
||||
if ($this->lineLength) {
|
||||
//3 === strlen(' * ')
|
||||
$wrapLength = $this->lineLength - strlen($indent) - 3;
|
||||
$text = wordwrap($text, $wrapLength);
|
||||
}
|
||||
$text = str_replace("\n", "\n{$indent} * ", $text);
|
||||
|
||||
$comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
|
||||
|
||||
$tags = array_values($docblock->getTags());
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($tags as $key => $tag) {
|
||||
$nextTag = isset($tags[$key + 1]) ? $tags[$key + 1] : null;
|
||||
|
||||
$tagText = (string) $tag;
|
||||
if ($this->lineLength) {
|
||||
$tagText = wordwrap($tagText, $wrapLength);
|
||||
}
|
||||
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
||||
|
||||
$comment .= "{$indent} * {$tagText}\n";
|
||||
|
||||
if ($this->separateTags && $nextTag !== null && ! $tag->inSameGroup($nextTag)) {
|
||||
$comment .= "{$indent} *\n";
|
||||
}
|
||||
}
|
||||
|
||||
$comment .= $indent . ' */';
|
||||
|
||||
return $comment;
|
||||
}
|
||||
}
|
||||
+181
-42
@@ -10,9 +10,9 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* Parses a tag definition for a DocBlock.
|
||||
@@ -23,16 +23,27 @@ use phpDocumentor\Reflection\DocBlock;
|
||||
*/
|
||||
class Tag implements \Reflector
|
||||
{
|
||||
/**
|
||||
* PCRE regular expression matching a tag name.
|
||||
*/
|
||||
const REGEX_TAGNAME = '[\w\-\_\\\\]+';
|
||||
|
||||
/** @var string Name of the tag */
|
||||
protected $tag = '';
|
||||
|
||||
/** @var string Content of the tag */
|
||||
/**
|
||||
* @var string|null Content of the tag.
|
||||
* When set to NULL, it means it needs to be regenerated.
|
||||
*/
|
||||
protected $content = '';
|
||||
|
||||
/** @var string Description of the content of this tag */
|
||||
protected $description = '';
|
||||
|
||||
/** @var array The description, as an array of strings and Tag objects. */
|
||||
/**
|
||||
* @var array|null The description, as an array of strings and Tag objects.
|
||||
* When set to NULL, it means it needs to be regenerated.
|
||||
*/
|
||||
protected $parsedDescription = null;
|
||||
|
||||
/** @var Location Location of the tag. */
|
||||
@@ -48,43 +59,45 @@ class Tag implements \Reflector
|
||||
*/
|
||||
private static $tagHandlerMappings = array(
|
||||
'author'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\AuthorTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\AuthorTag',
|
||||
'covers'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\CoversTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\CoversTag',
|
||||
'deprecated'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag',
|
||||
'example'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ExampleTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\ExampleTag',
|
||||
'link'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\LinkTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\LinkTag',
|
||||
'method'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\MethodTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\MethodTag',
|
||||
'param'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ParamTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\ParamTag',
|
||||
'property-read'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyReadTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\PropertyReadTag',
|
||||
'property'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\PropertyTag',
|
||||
'property-write'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyWriteTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\PropertyWriteTag',
|
||||
'return'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ReturnTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\ReturnTag',
|
||||
'see'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\SeeTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\SeeTag',
|
||||
'since'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\SinceTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\SinceTag',
|
||||
'source'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\SourceTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\SourceTag',
|
||||
'throw'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\ThrowsTag',
|
||||
'throws'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\ThrowsTag',
|
||||
'uses'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\UsesTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\UsesTag',
|
||||
'var'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\VarTag',
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\VarTag',
|
||||
'version'
|
||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\VersionTag'
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag',
|
||||
'SuppressWarnings'
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -104,7 +117,7 @@ class Tag implements \Reflector
|
||||
Location $location = null
|
||||
) {
|
||||
if (!preg_match(
|
||||
'/^@([\w\-\_\\\\]+)(?:\s*([^\s].*)|$)?/us',
|
||||
'/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us',
|
||||
$tag_line,
|
||||
$matches
|
||||
)) {
|
||||
@@ -173,28 +186,28 @@ class Tag implements \Reflector
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Name of the tag.
|
||||
* @param string $name Name of the tag.
|
||||
* @param string $content The contents of the given tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$name,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
$this->tag = $type;
|
||||
$this->content = $content;
|
||||
$this->description = trim($content);
|
||||
$this->docblock = $docblock;
|
||||
$this->location = $location;
|
||||
$this
|
||||
->setName($name)
|
||||
->setContent($content)
|
||||
->setDocBlock($docblock)
|
||||
->setLocation($location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this tag.
|
||||
* Gets the name of this tag.
|
||||
*
|
||||
* @return string
|
||||
* @return string The name of this tag.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
@@ -202,17 +215,57 @@ class Tag implements \Reflector
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of this tag.
|
||||
* Sets the name of this tag.
|
||||
*
|
||||
* @param string $name The new name of this tag.
|
||||
*
|
||||
* @return $this
|
||||
* @throws \InvalidArgumentException When an invalid tag name is provided.
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Invalid tag name supplied: ' . $name
|
||||
);
|
||||
}
|
||||
|
||||
$this->tag = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content of this tag.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = $this->description;
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description component of this tag.
|
||||
* Sets the content of this tag.
|
||||
*
|
||||
* @param string $content The new content of this tag.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->setDescription($content);
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description component of this tag.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -222,7 +275,23 @@ class Tag implements \Reflector
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed text of this description.
|
||||
* Sets the description component of this tag.
|
||||
*
|
||||
* @param string $description The new description component of this tag.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->content = null;
|
||||
$this->parsedDescription = null;
|
||||
$this->description = trim($description);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parsed text of this description.
|
||||
*
|
||||
* @return array An array of strings and tag objects, in the order they
|
||||
* occur within the description.
|
||||
@@ -237,14 +306,86 @@ class Tag implements \Reflector
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location of the tag.
|
||||
* Gets the docblock this tag belongs to.
|
||||
*
|
||||
* @return DocBlock The docblock this tag belongs to.
|
||||
*/
|
||||
public function getDocBlock()
|
||||
{
|
||||
return $this->docblock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the docblock this tag belongs to.
|
||||
*
|
||||
* @param DocBlock $docblock The new docblock this tag belongs to. Setting
|
||||
* NULL removes any association.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocBlock(DocBlock $docblock = null)
|
||||
{
|
||||
$this->docblock = $docblock;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location of the tag.
|
||||
*
|
||||
* @return Location Tag's location.
|
||||
* @return Location The tag's location.
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of the tag.
|
||||
*
|
||||
* @param Location $location The new location of the tag.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocation(Location $location = null)
|
||||
{
|
||||
$this->location = $location;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the given tags should be together or apart.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function inSameGroup(Tag $tag)
|
||||
{
|
||||
$firstName = $this->getName();
|
||||
$secondName = $tag->getName();
|
||||
|
||||
if ($firstName === $secondName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$groups = array(
|
||||
array('deprecated', 'link', 'see', 'since'),
|
||||
array('author', 'copyright', 'license'),
|
||||
array('category', 'package', 'subpackage'),
|
||||
array('property', 'property-read', 'property-write'),
|
||||
array('param', 'return'),
|
||||
);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
if (in_array($firstName, $group, true) && in_array($secondName, $group, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a string representation of this object.
|
||||
@@ -260,14 +401,12 @@ class Tag implements \Reflector
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported information (we should use the export static method
|
||||
* BUT this throws an exception at this point).
|
||||
* Returns the tag as a serialized string
|
||||
*
|
||||
* @return string
|
||||
* @codeCoverageIgnore Not yet implemented
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'Not yet implemented';
|
||||
return "@{$this->getName()} {$this->getContent()}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for an @author tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class AuthorTag extends Tag
|
||||
{
|
||||
/**
|
||||
* PCRE regular expression matching any valid value for the name component.
|
||||
*/
|
||||
const REGEX_AUTHOR_NAME = '[^\<]*';
|
||||
|
||||
/**
|
||||
* PCRE regular expression matching any valid value for the email component.
|
||||
*/
|
||||
const REGEX_AUTHOR_EMAIL = '[^\>]*';
|
||||
|
||||
/** @var string The name of the author */
|
||||
protected $authorName = '';
|
||||
|
||||
/** @var string The email of the author */
|
||||
protected $authorEmail = '';
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = $this->authorName;
|
||||
if ('' != $this->authorEmail) {
|
||||
$this->content .= "<{$this->authorEmail}>";
|
||||
}
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
parent::setContent($content);
|
||||
if (preg_match(
|
||||
'/^(' . self::REGEX_AUTHOR_NAME .
|
||||
')(\<(' . self::REGEX_AUTHOR_EMAIL .
|
||||
')\>)?$/u',
|
||||
$this->description,
|
||||
$matches
|
||||
)) {
|
||||
$this->authorName = trim($matches[1]);
|
||||
if (isset($matches[3])) {
|
||||
$this->authorEmail = trim($matches[3]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author's name.
|
||||
*
|
||||
* @return string The author's name.
|
||||
*/
|
||||
public function getAuthorName()
|
||||
{
|
||||
return $this->authorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author's name.
|
||||
*
|
||||
* @param string $authorName The new author name.
|
||||
* An invalid value will set an empty string.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthorName($authorName)
|
||||
{
|
||||
$this->content = null;
|
||||
$this->authorName
|
||||
= preg_match('/^' . self::REGEX_AUTHOR_NAME . '$/u', $authorName)
|
||||
? $authorName : '';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author's email.
|
||||
*
|
||||
* @return string The author's email.
|
||||
*/
|
||||
public function getAuthorEmail()
|
||||
{
|
||||
return $this->authorEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author's email.
|
||||
*
|
||||
* @param string $authorEmail The new author email.
|
||||
* An invalid value will set an empty string.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthorEmail($authorEmail)
|
||||
{
|
||||
$this->authorEmail
|
||||
= preg_match('/^' . self::REGEX_AUTHOR_EMAIL . '$/u', $authorEmail)
|
||||
? $authorEmail : '';
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @covers tag in a Docblock.
|
||||
+2
-2
@@ -10,9 +10,9 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag\VersionTag;
|
||||
use Barryvdh\Reflection\DocBlock\Tag\VersionTag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @deprecated tag in a Docblock.
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @example tag in a Docblock.
|
||||
*
|
||||
* @author Vasil Rangelov <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ExampleTag extends SourceTag
|
||||
{
|
||||
/**
|
||||
* @var string Path to a file to use as an example.
|
||||
* May also be an absolute URI.
|
||||
*/
|
||||
protected $filePath = '';
|
||||
|
||||
/**
|
||||
* @var bool Whether the file path component represents an URI.
|
||||
* This determines how the file portion appears at {@link getContent()}.
|
||||
*/
|
||||
protected $isURI = false;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$filePath = '';
|
||||
if ($this->isURI) {
|
||||
if (false === strpos($this->filePath, ':')) {
|
||||
$filePath = str_replace(
|
||||
'%2F',
|
||||
'/',
|
||||
rawurlencode($this->filePath)
|
||||
);
|
||||
} else {
|
||||
$filePath = $this->filePath;
|
||||
}
|
||||
} else {
|
||||
$filePath = '"' . $this->filePath . '"';
|
||||
}
|
||||
|
||||
$this->content = $filePath . ' ' . parent::getContent();
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
Tag::setContent($content);
|
||||
if (preg_match(
|
||||
'/^
|
||||
# File component
|
||||
(?:
|
||||
# File path in quotes
|
||||
\"([^\"]+)\"
|
||||
|
|
||||
# File URI
|
||||
(\S+)
|
||||
)
|
||||
# Remaining content (parsed by SourceTag)
|
||||
(?:\s+(.*))?
|
||||
$/sux',
|
||||
$this->description,
|
||||
$matches
|
||||
)) {
|
||||
if ('' !== $matches[1]) {
|
||||
$this->setFilePath($matches[1]);
|
||||
} else {
|
||||
$this->setFileURI($matches[2]);
|
||||
}
|
||||
|
||||
if (isset($matches[3])) {
|
||||
parent::setContent($matches[3]);
|
||||
} else {
|
||||
$this->setDescription('');
|
||||
}
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file path.
|
||||
*
|
||||
* @return string Path to a file to use as an example.
|
||||
* May also be an absolute URI.
|
||||
*/
|
||||
public function getFilePath()
|
||||
{
|
||||
return $this->filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file path.
|
||||
*
|
||||
* @param string $filePath The new file path to use for the example.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilePath($filePath)
|
||||
{
|
||||
$this->isURI = false;
|
||||
$this->filePath = trim($filePath);
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file path as an URI.
|
||||
*
|
||||
* This function is equivalent to {@link setFilePath()}, except that it
|
||||
* convers an URI to a file path before that.
|
||||
*
|
||||
* There is no getFileURI(), as {@link getFilePath()} is compatible.
|
||||
*
|
||||
* @param type $uri The new file URI to use as an example.
|
||||
*/
|
||||
public function setFileURI($uri)
|
||||
{
|
||||
$this->isURI = true;
|
||||
if (false === strpos($uri, ':')) {
|
||||
//Relative URL
|
||||
$this->filePath = rawurldecode(
|
||||
str_replace(array('/', '\\'), '%2F', $uri)
|
||||
);
|
||||
} else {
|
||||
//Absolute URL or URI.
|
||||
$this->filePath = $uri;
|
||||
}
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Ben Selby <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @link tag in a Docblock.
|
||||
*
|
||||
* @author Ben Selby <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class LinkTag extends Tag
|
||||
{
|
||||
/** @var string */
|
||||
protected $link = '';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = "{$this->link} {$this->description}";
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
parent::setContent($content);
|
||||
$parts = preg_split('/\s+/Su', $this->description, 2);
|
||||
|
||||
$this->link = $parts[0];
|
||||
|
||||
$this->setDescription(isset($parts[1]) ? $parts[1] : $parts[0]);
|
||||
|
||||
$this->content = $content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link
|
||||
*
|
||||
* @param string $link The link
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
$this->link = $link;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+95
-28
@@ -10,10 +10,9 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @method in a Docblock.
|
||||
@@ -30,37 +29,64 @@ class MethodTag extends ReturnTag
|
||||
|
||||
/** @var string */
|
||||
protected $arguments = '';
|
||||
|
||||
/** @var bool */
|
||||
protected $isStatic = false;
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'method').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
Tag::__construct($type, $content, $docblock, $location);
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = '';
|
||||
if ($this->isStatic) {
|
||||
$this->content .= 'static ';
|
||||
}
|
||||
$this->content .= $this->type .
|
||||
" {$this->method_name}({$this->arguments}) " .
|
||||
$this->description;
|
||||
}
|
||||
|
||||
$matches = array();
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
Tag::setContent($content);
|
||||
// 1. none or more whitespace
|
||||
// 2. optionally a word with underscores followed by whitespace : as
|
||||
// 2. optionally the keyword "static" followed by whitespace
|
||||
// 3. optionally a word with underscores followed by whitespace : as
|
||||
// type for the return value
|
||||
// 3. then optionally a word with underscores followed by () and
|
||||
// 4. then optionally a word with underscores followed by () and
|
||||
// whitespace : as method name as used by phpDocumentor
|
||||
// 4. then a word with underscores, followed by ( and any character
|
||||
// 5. then a word with underscores, followed by ( and any character
|
||||
// until a ) and whitespace : as method name with signature
|
||||
// 5. any remaining text : as description
|
||||
// 6. any remaining text : as description
|
||||
if (preg_match(
|
||||
'/^
|
||||
# Static keyword
|
||||
# Declates a static method ONLY if type is also present
|
||||
(?:
|
||||
(static)
|
||||
\s+
|
||||
)?
|
||||
# Return type
|
||||
(?:
|
||||
([\w\|_\\\\]+)
|
||||
(
|
||||
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
||||
|
|
||||
(?:
|
||||
(?:[\w\|_\\\\]+(?:<[\s\S]*>)?)
|
||||
# array notation
|
||||
(?:\[\])*
|
||||
)*
|
||||
|
|
||||
(?:\([\s\S]*\))?
|
||||
)
|
||||
\s+
|
||||
)?
|
||||
# Legacy method name (not captured)
|
||||
@@ -80,18 +106,27 @@ class MethodTag extends ReturnTag
|
||||
)) {
|
||||
list(
|
||||
,
|
||||
$static,
|
||||
$this->type,
|
||||
$this->method_name,
|
||||
$this->arguments,
|
||||
$this->description
|
||||
) = $matches;
|
||||
if (!$this->type) {
|
||||
$this->type = 'void';
|
||||
if ($static) {
|
||||
if (!$this->type) {
|
||||
$this->type = 'static';
|
||||
} else {
|
||||
$this->isStatic = true;
|
||||
}
|
||||
} else {
|
||||
if (!$this->type) {
|
||||
$this->type = 'void';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo date('c') . ' ERR (3): @method contained invalid contents: '
|
||||
. $this->content . PHP_EOL;
|
||||
$this->parsedDescription = null;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,11 +134,14 @@ class MethodTag extends ReturnTag
|
||||
*
|
||||
* @param string $method_name The name of the method.
|
||||
*
|
||||
* @return void
|
||||
* @return $this
|
||||
*/
|
||||
public function setMethodName($method_name)
|
||||
{
|
||||
$this->method_name = $method_name;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +164,9 @@ class MethodTag extends ReturnTag
|
||||
public function setArguments($arguments)
|
||||
{
|
||||
$this->arguments = $arguments;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,4 +190,30 @@ class MethodTag extends ReturnTag
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the method tag describes a static method or not.
|
||||
*
|
||||
* @return bool TRUE if the method declaration is for a static method, FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
public function isStatic()
|
||||
{
|
||||
return $this->isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new value for whether the method is static or not.
|
||||
*
|
||||
* @param bool $isStatic The new value to set.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsStatic($isStatic)
|
||||
{
|
||||
$this->isStatic = $isStatic;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @param tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ParamTag extends ReturnTag
|
||||
{
|
||||
/** @var string */
|
||||
protected $variableName = '';
|
||||
|
||||
/** @var bool determines whether this is a variadic argument */
|
||||
protected $isVariadic = false;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content
|
||||
= "{$this->type} {$this->variableName} {$this->description}";
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
Tag::setContent($content);
|
||||
|
||||
$parts = [];
|
||||
$rest = $this->description;
|
||||
|
||||
// parsing generics and closures to detect types
|
||||
for($pos = 0, $stacks = []; $pos < strlen($rest); $pos++) {
|
||||
$char = $rest[$pos];
|
||||
|
||||
if($char === '<') {
|
||||
array_unshift($stacks, $char);
|
||||
}
|
||||
if($char === '(') {
|
||||
array_unshift($stacks, $char);
|
||||
}
|
||||
if($char === '>' && isset($stacks[0]) && $stacks[0] === '<') {
|
||||
array_shift($stacks);
|
||||
}
|
||||
if($char === ')' && isset($stacks[0]) && $stacks[0] === '(') {
|
||||
array_shift($stacks);
|
||||
}
|
||||
|
||||
if(!$stacks && preg_match('/\A(\s+)(.*)/su', substr($rest, $pos), $matches)) {
|
||||
$parts[0] = substr($rest, 0, $pos);
|
||||
$parts[1] = $matches[1];
|
||||
$rest = $matches[2];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
array_push($parts, ...preg_split('/(\s+)/u', $rest, 2, PREG_SPLIT_DELIM_CAPTURE));
|
||||
|
||||
// if the first item that is encountered is not a variable; it is a type
|
||||
if (isset($parts[0])
|
||||
&& (strlen($parts[0]) > 0)
|
||||
&& ($parts[0][0] !== '$')
|
||||
) {
|
||||
$this->type = array_shift($parts);
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0])
|
||||
&& (strlen($parts[0]) > 0)
|
||||
&& ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')
|
||||
) {
|
||||
$this->variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
|
||||
if (substr($this->variableName, 0, 3) === '...') {
|
||||
$this->isVariadic = true;
|
||||
$this->variableName = substr($this->variableName, 3);
|
||||
}
|
||||
}
|
||||
|
||||
$this->setDescription(implode('', $parts));
|
||||
|
||||
$this->content = $content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the variable's name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariableName()
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the variable's name.
|
||||
*
|
||||
* @param string $name The new name for this variable.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVariableName($name)
|
||||
{
|
||||
$this->variableName = $name;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this tag is variadic.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVariadic()
|
||||
{
|
||||
return $this->isVariadic;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @property-read tag in a Docblock.
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @property tag in a Docblock.
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @property-write tag in a Docblock.
|
||||
+58
-22
@@ -10,11 +10,10 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Type\Collection;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
use Barryvdh\Reflection\DocBlock\Type\Collection;
|
||||
|
||||
/**
|
||||
* Reflection class for a @return tag in a Docblock.
|
||||
@@ -27,31 +26,39 @@ class ReturnTag extends Tag
|
||||
{
|
||||
/** @var string The raw type component. */
|
||||
protected $type = '';
|
||||
|
||||
|
||||
/** @var Collection The parsed type component. */
|
||||
protected $types = null;
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'return').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
parent::__construct($type, $content, $docblock, $location);
|
||||
$content = preg_split('/\s+/u', $this->description, 2);
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = "{$this->getType()} {$this->description}";
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
parent::setContent($content);
|
||||
|
||||
$parts = preg_split('/(?<!,)\s+/Su', $this->description, 2);
|
||||
|
||||
// any output is considered a type
|
||||
$this->type = $content[0];
|
||||
$this->type = $parts[0];
|
||||
$this->types = null;
|
||||
|
||||
$this->description = isset($content[1]) ? $content[1] : '';
|
||||
$this->setDescription(isset($parts[1]) ? $parts[1] : '');
|
||||
|
||||
$this->content = $content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,9 +81,38 @@ class ReturnTag extends Tag
|
||||
return (string) $this->getTypesCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type section of the variable
|
||||
*
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->types = null;
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a type to the type section of the variable
|
||||
*
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function addType($type)
|
||||
{
|
||||
$this->type = $this->type . Collection::OPERATOR_OR . $type;
|
||||
$this->types = null;
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type collection.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getTypesCollection()
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @see tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SeeTag extends Tag
|
||||
{
|
||||
/** @var string */
|
||||
protected $refers = null;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = "{$this->refers} {$this->description}";
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
parent::setContent($content);
|
||||
$parts = preg_split('/\s+/Su', $this->description, 2);
|
||||
|
||||
// any output is considered a type
|
||||
$this->refers = $parts[0];
|
||||
|
||||
$this->setDescription(isset($parts[1]) ? $parts[1] : '');
|
||||
|
||||
$this->content = $content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the structural element this tag refers to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReference()
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the structural element this tag refers to.
|
||||
*
|
||||
* @param string $refers The new type this tag refers to.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setReference($refers)
|
||||
{
|
||||
$this->refers = $refers;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,9 +10,9 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag\VersionTag;
|
||||
use Barryvdh\Reflection\DocBlock\Tag\VersionTag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @since tag in a Docblock.
|
||||
+56
-17
@@ -10,9 +10,9 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @source tag in a Docblock.
|
||||
@@ -36,20 +36,24 @@ class SourceTag extends Tag
|
||||
protected $lineCount = null;
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'source').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
parent::__construct($type, $content, $docblock, $location);
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content
|
||||
= "{$this->startingLine} {$this->lineCount} {$this->description}";
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
parent::setContent($content);
|
||||
if (preg_match(
|
||||
'/^
|
||||
# Starting line
|
||||
@@ -70,12 +74,15 @@ class SourceTag extends Tag
|
||||
if (isset($matches[2]) && '' !== $matches[2]) {
|
||||
$this->lineCount = (int)$matches[2];
|
||||
}
|
||||
$this->description = $matches[3];
|
||||
$this->setDescription($matches[3]);
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the starting line.
|
||||
* Gets the starting line.
|
||||
*
|
||||
* @return int The starting line, relative to the structural element's
|
||||
* location.
|
||||
@@ -85,6 +92,22 @@ class SourceTag extends Tag
|
||||
return $this->startingLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the starting line.
|
||||
*
|
||||
* @param int $startingLine The new starting line, relative to the
|
||||
* structural element's location.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStartingLine($startingLine)
|
||||
{
|
||||
$this->startingLine = $startingLine;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of lines.
|
||||
*
|
||||
@@ -95,4 +118,20 @@ class SourceTag extends Tag
|
||||
{
|
||||
return $this->lineCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of lines.
|
||||
*
|
||||
* @param int|null $lineCount The new number of lines, relative to the
|
||||
* starting line. NULL means "to the end".
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLineCount($lineCount)
|
||||
{
|
||||
$this->lineCount = $lineCount;
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Andrew Smith <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @SuppressWarnings tag in a Docblock.
|
||||
*
|
||||
* @author Andrew Smith <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SuppressWarningsTag extends Tag
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return "@{$this->getName()}{$this->getContent()}";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @throws tag in a Docblock.
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @uses tag in a Docblock.
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @var tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VarTag extends ParamTag
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @version tag in a Docblock.
|
||||
*
|
||||
* @author Vasil Rangelov <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VersionTag extends Tag
|
||||
{
|
||||
/**
|
||||
* PCRE regular expression matching a version vector.
|
||||
* Assumes the "x" modifier.
|
||||
*/
|
||||
const REGEX_VECTOR = '(?:
|
||||
# Normal release vectors.
|
||||
\d\S*
|
||||
|
|
||||
# VCS version vectors. Per PHPCS, they are expected to
|
||||
# follow the form of the VCS name, followed by ":", followed
|
||||
# by the version vector itself.
|
||||
# By convention, popular VCSes like CVS, SVN and GIT use "$"
|
||||
# around the actual version vector.
|
||||
[^\s\:]+\:\s*\$[^\$]+\$
|
||||
)';
|
||||
|
||||
/** @var string The version vector. */
|
||||
protected $version = '';
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = "{$this->version} {$this->description}";
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
parent::setContent($content);
|
||||
|
||||
if (preg_match(
|
||||
'/^
|
||||
# The version vector
|
||||
(' . self::REGEX_VECTOR . ')
|
||||
\s*
|
||||
# The description
|
||||
(.+)?
|
||||
$/sux',
|
||||
$this->description,
|
||||
$matches
|
||||
)) {
|
||||
$this->version = $matches[1];
|
||||
$this->setDescription(isset($matches[2]) ? $matches[2] : '');
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version section of the tag.
|
||||
*
|
||||
* @return string The version section of the tag.
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version section of the tag.
|
||||
*
|
||||
* @param string $version The new version section of the tag.
|
||||
* An invalid value will set an empty string.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVersion($version)
|
||||
{
|
||||
$this->version
|
||||
= preg_match('/^' . self::REGEX_VECTOR . '$/ux', $version)
|
||||
? $version
|
||||
: '';
|
||||
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+77
-11
@@ -10,9 +10,9 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Type;
|
||||
namespace Barryvdh\Reflection\DocBlock\Type;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
|
||||
/**
|
||||
* Collection
|
||||
@@ -34,9 +34,9 @@ class Collection extends \ArrayObject
|
||||
const OPERATOR_NAMESPACE = '\\';
|
||||
|
||||
/** @var string[] List of recognized keywords */
|
||||
protected $keywords = array(
|
||||
protected static $keywords = array(
|
||||
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
|
||||
'object', 'mixed', 'array', 'resource', 'void', 'null',
|
||||
'object', 'mixed', 'array', 'resource', 'void', 'null', 'scalar',
|
||||
'callback', 'callable', 'false', 'true', 'self', '$this', 'static'
|
||||
);
|
||||
|
||||
@@ -106,7 +106,7 @@ class Collection extends \ArrayObject
|
||||
}
|
||||
|
||||
// separate the type by the OR operator
|
||||
$type_parts = explode(self::OPERATOR_OR, $type);
|
||||
$type_parts = $this->explode($type);
|
||||
foreach ($type_parts as $part) {
|
||||
$expanded_type = $this->expand($part);
|
||||
if ($expanded_type) {
|
||||
@@ -114,10 +114,10 @@ class Collection extends \ArrayObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representation of the collection.
|
||||
*
|
||||
*
|
||||
* @return string The resolved types across the collection, separated with
|
||||
* {@link self::OPERATOR_OR}.
|
||||
*/
|
||||
@@ -126,6 +126,40 @@ class Collection extends \ArrayObject
|
||||
return implode(self::OPERATOR_OR, $this->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the given union of types and returns separated by OR operator
|
||||
* single types.
|
||||
*
|
||||
* @param string $type The type or union of types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function explode($type)
|
||||
{
|
||||
$type_parts = [];
|
||||
$curr_type = '';
|
||||
$nest_level = 0;
|
||||
|
||||
foreach (str_split($type) as $char) {
|
||||
if ($char === self::OPERATOR_OR && $nest_level === 0) {
|
||||
$type_parts[] = $curr_type;
|
||||
$curr_type = '';
|
||||
} else {
|
||||
if ($char === '<' || $char === '(') {
|
||||
$nest_level++;
|
||||
} else if ($char === '>' || $char === ')') {
|
||||
$nest_level--;
|
||||
}
|
||||
|
||||
$curr_type .= $char;
|
||||
}
|
||||
}
|
||||
|
||||
$type_parts[] = $curr_type;
|
||||
|
||||
return $type_parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the given type and returns the FQCN variant.
|
||||
*
|
||||
@@ -151,17 +185,31 @@ class Collection extends \ArrayObject
|
||||
return '';
|
||||
}
|
||||
|
||||
if (substr($type, 0, 6) === 'array<' && substr($type, -1) === '>') {
|
||||
return $type;
|
||||
}
|
||||
|
||||
if($type[0] === '(') {
|
||||
return $type;
|
||||
}
|
||||
|
||||
if ($this->isTypeAnArray($type)) {
|
||||
return $this->expand(substr($type, 0, -2)).self::OPERATOR_ARRAY;
|
||||
return $this->expand(substr($type, 0, -2)) . self::OPERATOR_ARRAY;
|
||||
}
|
||||
|
||||
if ($this->isRelativeType($type) && !$this->isTypeAKeyword($type)) {
|
||||
|
||||
if($this->shouldBeAbsolute($type)){
|
||||
return self::OPERATOR_NAMESPACE . $type;
|
||||
}
|
||||
|
||||
$type_parts = explode(self::OPERATOR_NAMESPACE, $type, 2);
|
||||
|
||||
$namespace_aliases = $this->context->getNamespaceAliases();
|
||||
// if the first segment is not an alias; prepend namespace name and
|
||||
// return
|
||||
if (!isset($namespace_aliases[$type_parts[0]])) {
|
||||
if (!isset($namespace_aliases[$type_parts[0]]) &&
|
||||
!isset($namespace_aliases[strstr($type_parts[0], '::', true)])) {
|
||||
$namespace = $this->context->getNamespace();
|
||||
if ('' !== $namespace) {
|
||||
$namespace .= self::OPERATOR_NAMESPACE;
|
||||
@@ -169,6 +217,12 @@ class Collection extends \ArrayObject
|
||||
return self::OPERATOR_NAMESPACE . $namespace . $type;
|
||||
}
|
||||
|
||||
if (strpos($type_parts[0], '::')) {
|
||||
$type_parts[] = strstr($type_parts[0], '::');
|
||||
$type_parts[0] = $namespace_aliases[strstr($type_parts[0], '::', true)];
|
||||
return implode('', $type_parts);
|
||||
}
|
||||
|
||||
$type_parts[0] = $namespace_aliases[$type_parts[0]];
|
||||
$type = implode(self::OPERATOR_NAMESPACE, $type_parts);
|
||||
}
|
||||
@@ -186,7 +240,7 @@ class Collection extends \ArrayObject
|
||||
*/
|
||||
protected function isTypeAnArray($type)
|
||||
{
|
||||
return (substr($type, -2) == self::OPERATOR_ARRAY);
|
||||
return substr($type, -2) === self::OPERATOR_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +253,7 @@ class Collection extends \ArrayObject
|
||||
*/
|
||||
protected function isTypeAKeyword($type)
|
||||
{
|
||||
return in_array(strtolower($type), $this->keywords);
|
||||
return in_array(strtolower($type), static::$keywords, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,4 +272,16 @@ class Collection extends \ArrayObject
|
||||
return ($type[0] !== self::OPERATOR_NAMESPACE)
|
||||
|| $this->isTypeAKeyword($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects if the type should actually be absolute, by checking if it exists.
|
||||
*
|
||||
* @param string $type A relative or absolute type as defined in the
|
||||
* phpDocumentor documentation.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldBeAbsolute($type){
|
||||
return class_exists($type);
|
||||
}
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use phpDocumentor\Reflection\DocBlock\Location;
|
||||
|
||||
/**
|
||||
* Parses the DocBlock for any structure.
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DocBlock implements \Reflector
|
||||
{
|
||||
/** @var string The opening line for this docblock. */
|
||||
protected $short_description = '';
|
||||
|
||||
/**
|
||||
* @var \phpDocumentor\Reflection\DocBlock\LongDescription The actual
|
||||
* description for this docblock.
|
||||
*/
|
||||
protected $long_description = null;
|
||||
|
||||
/**
|
||||
* @var \phpDocumentor\Reflection\DocBlock\Tags[] An array containing all
|
||||
* the tags in this docblock; except inline.
|
||||
*/
|
||||
protected $tags = array();
|
||||
|
||||
/** @var Context Information about the context of this DocBlock. */
|
||||
protected $context = null;
|
||||
|
||||
/** @var Location Information about the location of this DocBlock. */
|
||||
protected $location = null;
|
||||
|
||||
/**
|
||||
* Parses the given docblock and populates the member fields.
|
||||
*
|
||||
* The constructor may also receive namespace information such as the
|
||||
* current namespace and aliases. This information is used by some tags
|
||||
* (e.g. @return, @param, etc.) to turn a relative Type into a FQCN.
|
||||
*
|
||||
* @param \Reflector|string $docblock A docblock comment (including
|
||||
* asterisks) or reflector supporting the getDocComment method.
|
||||
* @param Context $context The context in which the DocBlock
|
||||
* occurs.
|
||||
* @param Location $location The location within the file that this
|
||||
* DocBlock occurs in.
|
||||
*
|
||||
* @throws \InvalidArgumentException if the given argument does not have the
|
||||
* getDocComment method.
|
||||
*/
|
||||
public function __construct(
|
||||
$docblock,
|
||||
Context $context = null,
|
||||
Location $location = null
|
||||
) {
|
||||
if (is_object($docblock)) {
|
||||
if (!method_exists($docblock, 'getDocComment')) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Invalid object passed; the given reflector must support '
|
||||
. 'the getDocComment method'
|
||||
);
|
||||
}
|
||||
|
||||
$docblock = $docblock->getDocComment();
|
||||
}
|
||||
|
||||
$docblock = $this->cleanInput($docblock);
|
||||
|
||||
list($short, $long, $tags) = $this->splitDocBlock($docblock);
|
||||
$this->short_description = $short;
|
||||
$this->long_description = new DocBlock\Description($long, $this);
|
||||
$this->parseTags($tags);
|
||||
|
||||
$this->context = $context;
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the asterisks from the DocBlock comment.
|
||||
*
|
||||
* @param string $comment String containing the comment text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function cleanInput($comment)
|
||||
{
|
||||
$comment = trim(
|
||||
preg_replace(
|
||||
'#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
|
||||
'$1',
|
||||
$comment
|
||||
)
|
||||
);
|
||||
|
||||
// reg ex above is not able to remove */ from a single line docblock
|
||||
if (substr($comment, -2) == '*/') {
|
||||
$comment = trim(substr($comment, 0, -2));
|
||||
}
|
||||
|
||||
// normalize strings
|
||||
$comment = str_replace(array("\r\n", "\r"), "\n", $comment);
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the DocBlock into a short description, long description and
|
||||
* block of tags.
|
||||
*
|
||||
* @param string $comment Comment to split into the sub-parts.
|
||||
*
|
||||
* @author RichardJ Special thanks to RichardJ for the regex responsible
|
||||
* for the split.
|
||||
*
|
||||
* @return string[] containing the short-, long description and an element
|
||||
* containing the tags.
|
||||
*/
|
||||
protected function splitDocBlock($comment)
|
||||
{
|
||||
if (strpos($comment, '@') === 0) {
|
||||
$matches = array('', '', $comment);
|
||||
} else {
|
||||
// clears all extra horizontal whitespace from the line endings
|
||||
// to prevent parsing issues
|
||||
$comment = preg_replace('/\h*$/Sum', '', $comment);
|
||||
|
||||
/*
|
||||
* Splits the docblock into a short description, long description and
|
||||
* tags section
|
||||
* - The short description is started from the first character until
|
||||
* a dot is encountered followed by a whitespace OR
|
||||
* two consecutive newlines (horizontal whitespace is taken into
|
||||
* account to consider spacing errors)
|
||||
* - The long description, any character until a new line is
|
||||
* encountered followed by an @ and word characters (a tag).
|
||||
* This is optional.
|
||||
* - Tags; the remaining characters
|
||||
*
|
||||
* Big thanks to RichardJ for contributing this Regular Expression
|
||||
*/
|
||||
preg_match(
|
||||
'/
|
||||
\A (
|
||||
[^\n.]+
|
||||
(?:
|
||||
(?! \. \s | \n{2} ) # disallow the first seperator here
|
||||
[\n.] (?! [ \t]* @\pL ) # disallow second seperator
|
||||
[^\n.]+
|
||||
)*
|
||||
\.?
|
||||
)
|
||||
(?:
|
||||
\s* # first seperator (actually newlines but it\'s all whitespace)
|
||||
(?! @\pL ) # disallow the rest, to make sure this one doesn\'t match,
|
||||
#if it doesn\'t exist
|
||||
(
|
||||
[^\n]+
|
||||
(?: \n+
|
||||
(?! [ \t]* @\pL ) # disallow second seperator (@param)
|
||||
[^\n]+
|
||||
)*
|
||||
)
|
||||
)?
|
||||
(\s+ [\s\S]*)? # everything that follows
|
||||
/ux',
|
||||
$comment,
|
||||
$matches
|
||||
);
|
||||
array_shift($matches);
|
||||
}
|
||||
|
||||
while (count($matches) < 3) {
|
||||
$matches[] = '';
|
||||
}
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tag objects.
|
||||
*
|
||||
* @param string $tags Tag block to parse.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function parseTags($tags)
|
||||
{
|
||||
$result = array();
|
||||
$tags = trim($tags);
|
||||
if ('' !== $tags) {
|
||||
if ('@' !== $tags[0]) {
|
||||
throw new \LogicException(
|
||||
'A tag block started with text instead of an actual tag,'
|
||||
. ' this makes the tag block invalid: ' . $tags
|
||||
);
|
||||
}
|
||||
foreach (explode("\n", $tags) as $tag_line) {
|
||||
if (trim($tag_line) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
||||
$result[] = $tag_line;
|
||||
} else {
|
||||
$result[count($result) - 1] .= PHP_EOL . $tag_line;
|
||||
}
|
||||
}
|
||||
|
||||
// create proper Tag objects
|
||||
foreach ($result as $key => $tag_line) {
|
||||
$result[$key] = DocBlock\Tag::createInstance($tag_line, $this);
|
||||
}
|
||||
}
|
||||
|
||||
$this->tags = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the opening line or also known as short description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShortDescription()
|
||||
{
|
||||
return $this->short_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full description or also known as long description.
|
||||
*
|
||||
* @return \phpDocumentor\Reflection\DocBlock\LongDescription
|
||||
*/
|
||||
public function getLongDescription()
|
||||
{
|
||||
return $this->long_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current context.
|
||||
*
|
||||
* @return Context
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current location.
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tags for this DocBlock.
|
||||
*
|
||||
* @return \phpDocumentor\Reflection\DocBlock\Tag[]
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of tags matching the given name. If no tags are found
|
||||
* an empty array is returned.
|
||||
*
|
||||
* @param string $name String to search by.
|
||||
*
|
||||
* @return \phpDocumentor\Reflection\DocBlock_Tag[]
|
||||
*/
|
||||
public function getTagsByName($name)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
/** @var \phpDocumentor\Reflection\DocBlock\Tag $tag */
|
||||
foreach ($this->getTags() as $tag) {
|
||||
if ($tag->getName() != $name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $tag;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a tag of a certain type is present in this DocBlock.
|
||||
*
|
||||
* @param string $name Tag name to check for.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTag($name)
|
||||
{
|
||||
/** @var \phpDocumentor\Reflection\DocBlock\Tag $tag */
|
||||
foreach ($this->getTags() as $tag) {
|
||||
if ($tag->getName() == $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a string representation of this object.
|
||||
*
|
||||
* @todo determine the exact format as used by PHP Reflection and
|
||||
* implement it.
|
||||
*
|
||||
* @return string
|
||||
* @codeCoverageIgnore Not yet implemented
|
||||
*/
|
||||
public static function export()
|
||||
{
|
||||
throw new \Exception('Not yet implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported information (we should use the export static method
|
||||
* BUT this throws an exception at this point).
|
||||
*
|
||||
* @return string
|
||||
* @codeCoverageIgnore Not yet implemented
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'Not yet implemented';
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for an @author tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class AuthorTag extends Tag
|
||||
{
|
||||
/** @var string The name of the author */
|
||||
protected $name = '';
|
||||
|
||||
/** @var string The email of the author */
|
||||
protected $email = '';
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'author').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
parent::__construct($type, $content, $docblock, $location);
|
||||
if (preg_match(
|
||||
'/^([^\<]*)(\<([^\>]*)\>)?$/',
|
||||
$this->description,
|
||||
$matches
|
||||
)) {
|
||||
$this->name = trim($matches[1]);
|
||||
if (isset($matches[3])) {
|
||||
$this->email = trim($matches[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author's name.
|
||||
*
|
||||
* @return string The author's name.
|
||||
*/
|
||||
public function getAuthorName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author's email.
|
||||
*
|
||||
* @return string The author's email.
|
||||
*/
|
||||
public function getAuthorEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @example tag in a Docblock.
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ExampleTag extends SourceTag
|
||||
{
|
||||
/** @var string Path to a file to use as an example. Can also be an URI. */
|
||||
protected $filePath = '';
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'example').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
Tag::__construct($type, $content, $docblock, $location);
|
||||
if (preg_match(
|
||||
'/^
|
||||
(?:
|
||||
# File path in quotes
|
||||
\"([^\"]+)\"
|
||||
|
|
||||
# File URI
|
||||
(\S+)
|
||||
)
|
||||
# Remaining content (parsed by SourceTag)
|
||||
(?:\s+(.*))?
|
||||
$/sux',
|
||||
$this->description,
|
||||
$matches
|
||||
)) {
|
||||
if ('' !== $matches[1]) {
|
||||
//Quoted file path.
|
||||
$this->filePath = trim($matches[1]);
|
||||
} elseif (false === strpos($matches[2], ':')) {
|
||||
//Relative URL or a file path with no spaces in it.
|
||||
$this->filePath = rawurldecode(
|
||||
str_replace(array('/', '\\'), '%2F', $matches[2])
|
||||
);
|
||||
} else {
|
||||
//Absolute URL or URI.
|
||||
$this->filePath = $matches[2];
|
||||
}
|
||||
|
||||
if (isset($matches[3])) {
|
||||
parent::__construct($type, $matches[3]);
|
||||
$this->content = $content;
|
||||
} else {
|
||||
$this->description = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file path.
|
||||
*
|
||||
* @return string Path to a file to use as an example. Can also be an URI.
|
||||
*/
|
||||
public function getFilePath()
|
||||
{
|
||||
return $this->filePath;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Ben Selby <benmatselby@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @link tag in a Docblock.
|
||||
*
|
||||
* @author Ben Selby <benmatselby@gmail.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class LinkTag extends Tag
|
||||
{
|
||||
/** @var string */
|
||||
protected $link = '';
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'link').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
parent::__construct($type, $content, $docblock, $location);
|
||||
$content = preg_split('/\s+/u', $this->description, 2);
|
||||
|
||||
// any output is considered a type
|
||||
$this->link = $content[0];
|
||||
|
||||
$this->description = isset($content[1]) ? $content[1] : $content[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link
|
||||
*
|
||||
* @param string $link The link
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @param tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ParamTag extends ReturnTag
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $variableName = null;
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'param').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
Tag::__construct($type, $content, $docblock, $location);
|
||||
$content = preg_split(
|
||||
'/(\s+)/u',
|
||||
$this->description,
|
||||
3,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
|
||||
// if the first item that is encountered is not a variable; it is a type
|
||||
if (isset($content[0])
|
||||
&& (strlen($content[0]) > 0)
|
||||
&& ($content[0][0] !== '$')
|
||||
) {
|
||||
$this->type = array_shift($content);
|
||||
array_shift($content);
|
||||
}
|
||||
|
||||
// if the next item starts with a $ it must be the variable name
|
||||
if (isset($content[0])
|
||||
&& (strlen($content[0]) > 0)
|
||||
&& ($content[0][0] == '$')
|
||||
) {
|
||||
$this->variableName = array_shift($content);
|
||||
array_shift($content);
|
||||
}
|
||||
|
||||
$this->description = implode('', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the variable's name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariableName()
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the variable's name.
|
||||
*
|
||||
* @param string $name The new name for this variable.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setVariableName($name)
|
||||
{
|
||||
$this->variableName = $name;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @see tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SeeTag extends Tag
|
||||
{
|
||||
/** @var string */
|
||||
protected $refers = null;
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'see').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
parent::__construct($type, $content, $docblock, $location);
|
||||
$content = preg_split('/\s+/u', $this->description, 2);
|
||||
|
||||
// any output is considered a type
|
||||
$this->refers = $content[0];
|
||||
|
||||
$this->description = isset($content[1]) ? $content[1] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the variable.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReference()
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @var tag in a Docblock.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VarTag extends ParamTag
|
||||
{
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'var').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
Tag::__construct($type, $content, $docblock, $location);
|
||||
$content = preg_split('/\s+/u', $this->description);
|
||||
|
||||
if (count($content) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// var always starts with the variable name
|
||||
$this->type = array_shift($content);
|
||||
|
||||
// if the next item starts with a $ it must be the variable name
|
||||
if ((count($content) > 0)
|
||||
&& (strlen($content[0]) > 0)
|
||||
&& ($content[0][0] == '$')
|
||||
) {
|
||||
$this->variableName = array_shift($content);
|
||||
}
|
||||
|
||||
$this->description = implode(' ', $content);
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Reflection class for a @version tag in a Docblock.
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VersionTag extends Tag
|
||||
{
|
||||
/** @var string The version vector. */
|
||||
protected $version = '';
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
* @param string $type Tag identifier for this tag (should be 'version').
|
||||
* @param string $content Contents for this tag.
|
||||
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||
* @param Location $location Location of the tag.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
) {
|
||||
parent::__construct($type, $content, $docblock, $location);
|
||||
|
||||
if (preg_match(
|
||||
'/^
|
||||
# The version vector
|
||||
((?:
|
||||
# Normal release vectors.
|
||||
\d\S*
|
||||
|
|
||||
# VCS version vectors. Per PHPCS, they are expected to
|
||||
# follow the form of the VCS name, followed by ":", followed
|
||||
# by the version vector itself.
|
||||
# By convention, popular VCSes like CVS, SVN and GIT use "$"
|
||||
# around the actual version vector.
|
||||
[^\s\:]+\:\s*\$[^\$]+\$
|
||||
))
|
||||
\s*
|
||||
# The description
|
||||
(.+)?
|
||||
$/sux',
|
||||
$this->description,
|
||||
$matches
|
||||
)) {
|
||||
$this->version = $matches[1];
|
||||
$this->description = isset($matches[2]) ? $matches[2] : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version section of the tag.
|
||||
*
|
||||
* @return string The version section of the tag.
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -10,17 +10,19 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Description
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Description
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
||||
class DescriptionTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
@@ -106,7 +108,7 @@ LONGDESC;
|
||||
|
||||
$parsedDescription = $parsedContents[1]->getParsedDescription();
|
||||
$this->assertCount(3, $parsedDescription);
|
||||
$this->assertSame("inline tag with\n", $parsedDescription[0]);
|
||||
$this->assertSame("inline tag with", trim($parsedDescription[0]));
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag\LinkTag',
|
||||
$parsedDescription[1]
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\CoversTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
class CoversTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\CoversTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\CoversTag can create
|
||||
* a link for the covers doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -31,7 +33,7 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\CoversTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DeprecatedTagTest extends \PHPUnit_Framework_TestCase
|
||||
class DeprecatedTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @deprecated doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class DeprecatedTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-6
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\ExampleTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ExampleTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ExampleTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
|
||||
* understand the @source DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -33,8 +35,7 @@ class ExampleTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exLineCount
|
||||
* @param string $exFilepath
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag::getFilePath
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ExampleTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-6
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\LinkTag
|
||||
*
|
||||
* @author Ben Selby <benmatselby@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
class LinkTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @link doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,8 +34,7 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exLink
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::getLink
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\LinkTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+59
-23
@@ -10,17 +10,19 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\MethodTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
class MethodTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $signature The signature to test.
|
||||
@@ -34,10 +36,7 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $description The short description mentioned in the
|
||||
* signature.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::getMethodName
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::getArguments
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\MethodTag
|
||||
* @dataProvider getTestSignatures
|
||||
*
|
||||
* @return void
|
||||
@@ -47,6 +46,7 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
$valid,
|
||||
$expected_name,
|
||||
$expected_return,
|
||||
$expected_isStatic,
|
||||
$paramCount,
|
||||
$description
|
||||
) {
|
||||
@@ -67,63 +67,99 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected_name, $tag->getMethodName());
|
||||
$this->assertEquals($expected_return, $tag->getType());
|
||||
$this->assertEquals($description, $tag->getDescription());
|
||||
$this->assertEquals($expected_isStatic, $tag->isStatic());
|
||||
$this->assertCount($paramCount, $tag->getArguments());
|
||||
}
|
||||
|
||||
public function getTestSignatures()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'foo',
|
||||
false, 'foo', '', 0, ''
|
||||
),
|
||||
// TODO: Verify this case
|
||||
// array(
|
||||
// 'foo',
|
||||
// false, 'foo', '', false, 0, ''
|
||||
// ),
|
||||
array(
|
||||
'foo()',
|
||||
true, 'foo', 'void', 0, ''
|
||||
true, 'foo', 'void', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'foo() description',
|
||||
true, 'foo', 'void', 0, 'description'
|
||||
true, 'foo', 'void', false, 0, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo()',
|
||||
true, 'foo', 'int', 0, ''
|
||||
true, 'foo', 'int', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'int foo() description',
|
||||
true, 'foo', 'int', 0, 'description'
|
||||
true, 'foo', 'int', false, 0, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo($a, $b)',
|
||||
true, 'foo', 'int', 2, ''
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo() foo(int $a, int $b)',
|
||||
true, 'foo', 'int', 2, ''
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo(int $a, int $b)',
|
||||
true, 'foo', 'int', 2, ''
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'null|int foo(int $a, int $b)',
|
||||
true, 'foo', 'null|int', 2, ''
|
||||
true, 'foo', 'null|int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo(null|int $a, int $b)',
|
||||
true, 'foo', 'int', 2, ''
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'\Exception foo() foo(Exception $a, Exception $b)',
|
||||
true, 'foo', '\Exception', 2, ''
|
||||
true, 'foo', '\Exception', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo() foo(Exception $a, Exception $b) description',
|
||||
true, 'foo', 'int', 2, 'description'
|
||||
true, 'foo', 'int', false, 2, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo() foo(\Exception $a, \Exception $b) description',
|
||||
true, 'foo', 'int', 2, 'description'
|
||||
true, 'foo', 'int', false, 2, 'description'
|
||||
),
|
||||
array(
|
||||
'void()',
|
||||
true, 'void', 'void', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'static foo()',
|
||||
true, 'foo', 'static', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'static void foo()',
|
||||
true, 'foo', 'void', true, 0, ''
|
||||
),
|
||||
array(
|
||||
'static static foo()',
|
||||
true, 'foo', 'static', true, 0, ''
|
||||
),
|
||||
|
||||
// generic array
|
||||
array(
|
||||
'array<int, string> foo()',
|
||||
true, 'foo', 'array<int, string>', false, 0, ''
|
||||
),
|
||||
|
||||
// nested generics
|
||||
array(
|
||||
'array<int, array<string, mixed>> foo()',
|
||||
true, 'foo', 'array<int, array<string, mixed>>', false, 0, ''
|
||||
),
|
||||
|
||||
// closure
|
||||
array(
|
||||
'(\Closure(int, string): bool) foo()',
|
||||
true, 'foo', '(\Closure(int, string): bool)', false, 0, ''
|
||||
),
|
||||
);
|
||||
}
|
||||
+76
-8
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ParamTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ParamTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ParamTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ParamTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ParamTag can
|
||||
* understand the @param DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -33,9 +35,7 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $extractedVarName
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::getVariableName
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ParamTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
@@ -114,7 +114,75 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Type on a new line"
|
||||
)
|
||||
),
|
||||
|
||||
// generic array
|
||||
array(
|
||||
'param',
|
||||
'array<int, string> $names',
|
||||
'array<int, string>',
|
||||
array('array<int, string>'),
|
||||
'$names',
|
||||
''
|
||||
),
|
||||
|
||||
// nested generics
|
||||
array(
|
||||
'param',
|
||||
'array<int, array<string, mixed>> $arrays',
|
||||
'array<int, array<string, mixed>>',
|
||||
array('array<int, array<string, mixed>>'),
|
||||
'$arrays',
|
||||
''
|
||||
),
|
||||
|
||||
// closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(int, string): bool) $callback',
|
||||
'(\Closure(int, string): bool)',
|
||||
array('(\Closure(int, string): bool)'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// generic array in closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(array<int, string>): bool) $callback',
|
||||
'(\Closure(array<int, string>): bool)',
|
||||
array('(\Closure(array<int, string>): bool)'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// union types in closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(int|string): bool)|bool $callback',
|
||||
'(\Closure(int|string): bool)|bool',
|
||||
array('(\Closure(int|string): bool)', 'bool'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// example from Laravel Framework - Eloquent Builder)
|
||||
array(
|
||||
'param',
|
||||
'array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>|string $relations',
|
||||
'array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>|string',
|
||||
array('array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>', 'string'),
|
||||
'$relations',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string|null $callback',
|
||||
'(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string|null',
|
||||
array('(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)', 'string', 'null'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+29
-7
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Return tag test.
|
||||
*
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ReturnTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ReturnTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ReturnTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ReturnTag can
|
||||
* understand the @return DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,8 +34,7 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ReturnTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
@@ -97,6 +98,27 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string> Types of Bobs',
|
||||
'array<int, string>',
|
||||
array('array<int, string>'),
|
||||
'Types of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string>|string Types of Bobs',
|
||||
'array<int, string>|string',
|
||||
array('array<int, string>', 'string'),
|
||||
'Types of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string|bool>|string Types of Bobs',
|
||||
'array<int, string|bool>|string',
|
||||
array('array<int, string|bool>', 'string'),
|
||||
'Types of Bobs'
|
||||
)
|
||||
);
|
||||
}
|
||||
+6
-5
@@ -10,17 +10,19 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SeeTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
class SeeTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
||||
@@ -31,8 +33,7 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::getReference
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SinceTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SinceTagTest extends \PHPUnit_Framework_TestCase
|
||||
class SinceTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @since doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class SinceTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SinceTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-7
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SourceTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SourceTagTest extends \PHPUnit_Framework_TestCase
|
||||
class SourceTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
|
||||
* understand the @source DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,9 +34,7 @@ class SourceTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exStartingLine
|
||||
* @param string $exLineCount
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag::getStartingLine
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag::getLineCount
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SourceTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor SuppressWarnings Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Andrew Smith <espadav8@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag
|
||||
*
|
||||
* @author Andrew Smith <espadav8@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SuppressWarningsTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag can
|
||||
* understand the @SuppressWarnings doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exType
|
||||
* @param string $exVariable
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$description
|
||||
) {
|
||||
$tag = new SuppressWarningsTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($description, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $description
|
||||
return array(
|
||||
array(
|
||||
'SuppressWarnings',
|
||||
'SuppressWarnings(PHPMD)',
|
||||
'SuppressWarnings(PHPMD)',
|
||||
),
|
||||
array(
|
||||
'SuppressWarnings',
|
||||
'SuppressWarnings(PHPMD.TooManyMethods)',
|
||||
'SuppressWarnings(PHPMD.TooManyMethods)',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ThrowsTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ThrowsTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ThrowsTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag can
|
||||
* understand the @throws DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,8 +34,7 @@ class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
+8
-5
@@ -10,20 +10,23 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\UsesTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
class UsesTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\UsesTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\UsesTag can create
|
||||
* a link for the @uses doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -31,7 +34,7 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\UsesTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+8
-5
@@ -10,20 +10,23 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
class VarTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\VarTag can
|
||||
* understand the @var doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +35,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exVariable
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VarTag::__construct
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-6
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VersionTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VersionTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VersionTagTest extends \PHPUnit_Framework_TestCase
|
||||
class VersionTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @version doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,8 +34,7 @@ class VersionTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VersionTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VersionTag::getVersion
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\VersionTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+20
-26
@@ -10,34 +10,35 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class TagTest extends \PHPUnit_Framework_TestCase
|
||||
class TagTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagLine()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
Tag::createInstance('Invalid tag line');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -70,13 +71,13 @@ class TagTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagHandlerCorrectRegistration()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
if (!ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
}
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
@@ -93,7 +94,7 @@ class TagTest extends \PHPUnit_Framework_TestCase
|
||||
include 'data:text/plain;base64,'. base64_encode(
|
||||
<<<TAG_HANDLER
|
||||
<?php
|
||||
class MyTagHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
||||
class MyTagHandler extends \Barryvdh\Reflection\DocBlock\Tag {}
|
||||
TAG_HANDLER
|
||||
);
|
||||
|
||||
@@ -118,8 +119,8 @@ TAG_HANDLER
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::createInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -162,8 +163,8 @@ TAG_HANDLER
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::createInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -201,7 +202,7 @@ TAG_HANDLER
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -232,7 +233,7 @@ TAG_HANDLER
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -265,16 +266,14 @@ TAG_HANDLER
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\VarTag can
|
||||
* understand the @var doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::getDescription
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::getContent
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -309,11 +308,6 @@ TAG_HANDLER
|
||||
'unknown',
|
||||
'',
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'',
|
||||
'unknown',
|
||||
'unknown',
|
||||
)
|
||||
);
|
||||
}
|
||||
+98
-23
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Collection Test
|
||||
*
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
@@ -10,26 +10,27 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Type;
|
||||
namespace Barryvdh\Reflection\DocBlock\Type;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Type\Collection
|
||||
*
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Type\Collection
|
||||
*
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
class CollectionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getContext
|
||||
*
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::getContext
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct()
|
||||
@@ -41,8 +42,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithTypes()
|
||||
@@ -52,8 +53,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithNamespace()
|
||||
@@ -69,8 +70,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithNamespaceAliases()
|
||||
@@ -88,8 +89,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpand
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAdd($fixture, $expected)
|
||||
@@ -108,8 +109,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithoutNamespace
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddWithoutNamespace($fixture, $expected)
|
||||
@@ -124,13 +125,33 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
* @expectedException InvalidArgumentException
|
||||
*
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithPropertyOrMethod
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddMethodsAndProperties($fixture, $expected)
|
||||
{
|
||||
$collection = new Collection(
|
||||
array(),
|
||||
new Context(null, array('LinkDescriptor' => '\phpDocumentor\LinkDescriptor'))
|
||||
);
|
||||
$collection->add($fixture);
|
||||
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddWithInvalidArgument()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$collection = new Collection();
|
||||
$collection->add(array());
|
||||
}
|
||||
@@ -177,6 +198,30 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
'DocBlock[]|int[]',
|
||||
array($namespace.'DocBlock[]', 'int[]')
|
||||
),
|
||||
array(
|
||||
'array<int, string>',
|
||||
array('array<int, string>')
|
||||
),
|
||||
array(
|
||||
'array<int, string>|string',
|
||||
array('array<int, string>', 'string')
|
||||
),
|
||||
array(
|
||||
'array<int, float|bool>|string',
|
||||
array('array<int, float|bool>', 'string')
|
||||
),
|
||||
array(
|
||||
'array<int, string|array<int, bool>>|array<int, float>|string',
|
||||
array('array<int, string|array<int, bool>>', 'array<int, float>', 'string')
|
||||
),
|
||||
array(
|
||||
'LinkDescriptor::setLink()',
|
||||
array($namespace.'LinkDescriptor::setLink()')
|
||||
),
|
||||
array(
|
||||
'Alias\LinkDescriptor::setLink()',
|
||||
array('\My\Space\Aliasing\LinkDescriptor::setLink()')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,4 +237,34 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return $this->provideTypesToExpand($method, '\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the method and property types and their expected values to test
|
||||
* the retrieval of types.
|
||||
*
|
||||
* @param string $method Name of the method consuming this data provider.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function provideTypesToExpandWithPropertyOrMethod($method)
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'LinkDescriptor::setLink()',
|
||||
array('\phpDocumentor\LinkDescriptor::setLink()')
|
||||
),
|
||||
array(
|
||||
'phpDocumentor\LinkDescriptor::setLink()',
|
||||
array('\phpDocumentor\LinkDescriptor::setLink()')
|
||||
),
|
||||
array(
|
||||
'LinkDescriptor::$link',
|
||||
array('\phpDocumentor\LinkDescriptor::$link')
|
||||
),
|
||||
array(
|
||||
'phpDocumentor\LinkDescriptor::$link',
|
||||
array('\phpDocumentor\LinkDescriptor::$link')
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+68
-26
@@ -10,23 +10,25 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
namespace Barryvdh\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use phpDocumentor\Reflection\DocBlock\Location;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock\Location;
|
||||
use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for phpDocumentor\Reflection\DocBlock
|
||||
* Test class for Barryvdh\Reflection\DocBlock
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
class DocBlockTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock
|
||||
* @covers \Barryvdh\Reflection\DocBlock
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -34,9 +36,9 @@ class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a short description.
|
||||
* This is a short description
|
||||
*
|
||||
* This is a long description.
|
||||
* This is a long description
|
||||
*
|
||||
* @see \MyClass
|
||||
* @return void
|
||||
@@ -48,11 +50,11 @@ DOCBLOCK;
|
||||
new Location(2)
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a short description.',
|
||||
'This is a short description',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a long description.',
|
||||
'This is a long description',
|
||||
$object->getLongDescription()->getContents()
|
||||
);
|
||||
$this->assertCount(2, $object->getTags());
|
||||
@@ -69,8 +71,8 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::splitDocBlock
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock::splitDocBlock
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithTagsOnly()
|
||||
@@ -91,7 +93,42 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::cleanInput
|
||||
* @covers \Barryvdh\Reflection\DocBlock::isTemplateStart
|
||||
*/
|
||||
public function testIfStartOfTemplateIsDiscovered()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**#@+
|
||||
* @see \MyClass
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(2, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
$this->assertTrue($object->hasTag('return'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
$this->assertTrue($object->isTemplateStart());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Barryvdh\Reflection\DocBlock::isTemplateEnd
|
||||
*/
|
||||
public function testIfEndOfTemplateIsDiscovered()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**#@-*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertTrue($object->isTemplateEnd());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Barryvdh\Reflection\DocBlock::cleanInput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -108,7 +145,7 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::__construct
|
||||
* @covers \Barryvdh\Reflection\DocBlock::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -116,7 +153,7 @@ DOCBLOCK;
|
||||
{
|
||||
$object = new DocBlock(new \ReflectionClass($this));
|
||||
$this->assertEquals(
|
||||
'Test class for phpDocumentor\Reflection\DocBlock',
|
||||
'Test class for Barryvdh\Reflection\DocBlock',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
@@ -129,12 +166,12 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionOnInvalidObject()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new DocBlock($this);
|
||||
}
|
||||
|
||||
@@ -142,7 +179,8 @@ DOCBLOCK;
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a short description. This is a long description.
|
||||
* This is a short description.
|
||||
* This is a long description.
|
||||
* This is a continuation of the long description.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
@@ -159,21 +197,22 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||
* @expectedException \LogicException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagBlock()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
if (!ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
return;
|
||||
}
|
||||
|
||||
include 'data:text/plain;base64,'. base64_encode(
|
||||
<<<DOCBLOCK_EXTENSION
|
||||
<?php
|
||||
class MyReflectionDocBlock extends \phpDocumentor\Reflection\DocBlock {
|
||||
class MyReflectionDocBlock extends \Barryvdh\Reflection\DocBlock {
|
||||
protected function splitDocBlock(\$comment) {
|
||||
return array('', '', 'Invalid tag block');
|
||||
}
|
||||
@@ -225,7 +264,7 @@ DOCBLOCK;
|
||||
|
||||
/**
|
||||
* @depends testConstructFromReflector
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
* @covers \Barryvdh\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -238,7 +277,7 @@ DOCBLOCK;
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -256,7 +295,7 @@ DOCBLOCK;
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -271,12 +310,15 @@ DOCBLOCK;
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertCount(1, $object->getTags());
|
||||
$this->assertCount(1, $tags = $object->getTags());
|
||||
/** @var ReturnTag $tag */
|
||||
$tag = reset($tags);
|
||||
$this->assertEquals("Content on\n multiple lines.\n\n One more, after the break.", $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
* @covers \Barryvdh\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
Reference in New Issue
Block a user