mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 18:13:13 +00:00
Compare commits
57
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db125e8df4 | ||
|
|
62d62638b2 | ||
|
|
476f62b577 | ||
|
|
e5c8b970d6 | ||
|
|
d5d2d76892 | ||
|
|
fba297a2a7 | ||
|
|
0fd348d3fe | ||
|
|
67e478e26a | ||
|
|
e292151642 | ||
|
|
8bb2a5f9b7 | ||
|
|
ac3b854893 | ||
|
|
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 | ||
|
|
fd9e6bd26d | ||
|
|
d5e4b2ec73 | ||
|
|
bae8be0dcd | ||
|
|
3a5d30e027 | ||
|
|
d2414cd3dc | ||
|
|
070b13745a | ||
|
|
df7807cd73 | ||
|
|
b07e3c36b7 | ||
|
|
163dd7877e |
@@ -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.4, 8.3, 8.2, 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@v4
|
||||||
|
|
||||||
|
- 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
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
|
.phpunit.result.cache
|
||||||
composer.lock
|
composer.lock
|
||||||
vendor
|
vendor
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
before_commands:
|
|
||||||
- "composer install --no-dev --prefer-source"
|
|
||||||
|
|
||||||
tools:
|
|
||||||
external_code_coverage:
|
|
||||||
enabled: false
|
|
||||||
timeout: 300
|
|
||||||
filter:
|
|
||||||
excluded_paths: ["tests", "vendor"]
|
|
||||||
php_code_coverage:
|
|
||||||
enabled: false
|
|
||||||
test_command: phpunit -c phpunit.xml.dist
|
|
||||||
php_code_sniffer:
|
|
||||||
enabled: true
|
|
||||||
config:
|
|
||||||
standard: PSR2
|
|
||||||
filter:
|
|
||||||
paths: ["src/*", "tests/*"]
|
|
||||||
php_cpd:
|
|
||||||
enabled: true
|
|
||||||
excluded_dirs: ["tests", "vendor"]
|
|
||||||
php_cs_fixer:
|
|
||||||
enabled: true
|
|
||||||
config:
|
|
||||||
level: all
|
|
||||||
filter:
|
|
||||||
paths: ["src/*", "tests/*"]
|
|
||||||
php_loc:
|
|
||||||
enabled: true
|
|
||||||
excluded_dirs: ["tests", "vendor"]
|
|
||||||
php_mess_detector:
|
|
||||||
enabled: true
|
|
||||||
config:
|
|
||||||
ruleset: phpmd.xml.dist
|
|
||||||
design_rules: { eval_expression: false }
|
|
||||||
filter:
|
|
||||||
paths: ["src/*"]
|
|
||||||
php_pdepend:
|
|
||||||
enabled: true
|
|
||||||
excluded_dirs: ["tests", "vendor"]
|
|
||||||
php_analyzer:
|
|
||||||
enabled: true
|
|
||||||
filter:
|
|
||||||
paths: ["src/*", "tests/*"]
|
|
||||||
sensiolabs_security_checker: true
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
language: php
|
|
||||||
php:
|
|
||||||
- 5.3.3
|
|
||||||
- 5.3
|
|
||||||
- 5.4
|
|
||||||
- 5.5
|
|
||||||
- 5.6
|
|
||||||
- 7.0
|
|
||||||
- hhvm
|
|
||||||
- hhvm-nightly
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- php: hhvm
|
|
||||||
- php: hhvm-nightly
|
|
||||||
|
|
||||||
script:
|
|
||||||
- vendor/bin/phpunit
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- sudo apt-get -qq update > /dev/null
|
|
||||||
- phpenv rehash > /dev/null
|
|
||||||
- composer selfupdate --quiet
|
|
||||||
- composer install --no-interaction --prefer-source --dev
|
|
||||||
- vendor/bin/phpunit
|
|
||||||
- composer update --no-interaction --prefer-source --dev
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
irc: "irc.freenode.org#phpdocumentor"
|
|
||||||
email:
|
|
||||||
- [email protected]
|
|
||||||
- [email protected]
|
|
||||||
- [email protected]
|
|
||||||
+6
-6
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "phpdocumentor/reflection-docblock",
|
"name": "barryvdh/reflection-docblock",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
@@ -9,18 +9,18 @@
|
|||||||
"php": ">=5.3.3"
|
"php": ">=5.3.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {"phpDocumentor": ["src/"]}
|
"psr-0": {"Barryvdh": ["src/"]}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~4.0"
|
"phpunit/phpunit": "^8.5.14|^9"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"erusev/parsedown": "~1.0",
|
"dflydev/markdown": "~1.0",
|
||||||
"league/commonmark": "*"
|
"erusev/parsedown": "~1.0"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.0.x-dev"
|
"dev-master": "2.2.x-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<ruleset
|
|
||||||
name="ProxyManager rules"
|
|
||||||
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
|
||||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
|
|
||||||
>
|
|
||||||
<rule ref="rulesets/codesize.xml"/>
|
|
||||||
<rule ref="rulesets/unusedcode.xml"/>
|
|
||||||
<rule ref="rulesets/design.xml">
|
|
||||||
<!-- eval is needed to generate runtime classes -->
|
|
||||||
<exclude name="EvalExpression"/>
|
|
||||||
</rule>
|
|
||||||
<rule ref="rulesets/naming.xml">
|
|
||||||
<exclude name="LongVariable"/>
|
|
||||||
</rule>
|
|
||||||
<rule ref="rulesets/naming.xml/LongVariable">
|
|
||||||
<properties>
|
|
||||||
<property name="minimum">40</property>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
</ruleset>
|
|
||||||
+6
-7
@@ -1,14 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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">
|
||||||
<phpunit colors="true" strict="true" bootstrap="vendor/autoload.php">
|
<coverage>
|
||||||
|
<include>
|
||||||
|
<directory suffix=".php">./src/</directory>
|
||||||
|
</include>
|
||||||
|
</coverage>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="phpDocumentor\Reflection\DocBlock">
|
<testsuite name="phpDocumentor\Reflection\DocBlock">
|
||||||
<directory>./tests/</directory>
|
<directory>./tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<filter>
|
|
||||||
<whitelist>
|
|
||||||
<directory suffix=".php">./src/</directory>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection;
|
namespace Barryvdh\Reflection;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use Barryvdh\Reflection\DocBlock\Tag;
|
||||||
use phpDocumentor\Reflection\DocBlock\Context;
|
use Barryvdh\Reflection\DocBlock\Context;
|
||||||
use phpDocumentor\Reflection\DocBlock\Location;
|
use Barryvdh\Reflection\DocBlock\Location;
|
||||||
|
use Barryvdh\Reflection\DocBlock\Tag\TemplateTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the DocBlock for any structure.
|
* Parses the DocBlock for any structure.
|
||||||
@@ -40,6 +41,9 @@ class DocBlock implements \Reflector
|
|||||||
*/
|
*/
|
||||||
protected $tags = array();
|
protected $tags = array();
|
||||||
|
|
||||||
|
/** @var string[] An array containing all the generics in this docblock. */
|
||||||
|
protected $generics = array();
|
||||||
|
|
||||||
/** @var Context Information about the context of this DocBlock. */
|
/** @var Context Information about the context of this DocBlock. */
|
||||||
protected $context = null;
|
protected $context = null;
|
||||||
|
|
||||||
@@ -57,24 +61,28 @@ class DocBlock implements \Reflector
|
|||||||
*
|
*
|
||||||
* The constructor may also receive namespace information such as the
|
* The constructor may also receive namespace information such as the
|
||||||
* current namespace and aliases. This information is used by some tags
|
* current namespace and aliases. This information is used by some tags
|
||||||
* (e.g. return, param, etc.) to turn a relative Type into a FQCN.
|
* (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
|
* @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.
|
* 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(
|
public function __construct(
|
||||||
$docblock,
|
$docblock,
|
||||||
Context $context = null,
|
?Context $context = null,
|
||||||
Location $location = null
|
?Location $location = null
|
||||||
) {
|
) {
|
||||||
if (is_object($docblock)) {
|
if (is_object($docblock)) {
|
||||||
if (!method_exists($docblock, 'getDocComment')) {
|
if (!method_exists($docblock, 'getDocComment')) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'Invalid object passed; the given reflector must support the getDocComment method'
|
'Invalid object passed; the given reflector must support '
|
||||||
|
. 'the getDocComment method'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +242,11 @@ class DocBlock implements \Reflector
|
|||||||
|
|
||||||
// create proper Tag objects
|
// create proper Tag objects
|
||||||
foreach ($result as $key => $tag_line) {
|
foreach ($result as $key => $tag_line) {
|
||||||
$result[$key] = Tag::createInstance(trim($tag_line), $this);
|
$tag = Tag::createInstance(trim($tag_line), $this);
|
||||||
|
if ($tag instanceof TemplateTag) {
|
||||||
|
$this->generics[] = $tag->getTemplateName();
|
||||||
|
}
|
||||||
|
$result[$key] = $tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,13 +274,14 @@ class DocBlock implements \Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text portion of the DocBlock.
|
* Set the text portion of the doc block.
|
||||||
*
|
*
|
||||||
* Sets the text portion (short and long description combined) of the DocBlock.
|
* Sets the text portion (short and long description combined) of the doc
|
||||||
|
* block.
|
||||||
*
|
*
|
||||||
* @param string $comment The new text portion of the DocBlock.
|
* @param string $docblock The new text portion of the doc block.
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this This doc block.
|
||||||
*/
|
*/
|
||||||
public function setText($comment)
|
public function setText($comment)
|
||||||
{
|
{
|
||||||
@@ -434,6 +447,33 @@ class DocBlock implements \Reflector
|
|||||||
return $tag;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the generics for this DocBlock.
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getGenerics()
|
||||||
|
{
|
||||||
|
return $this->generics;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a string representation of this object.
|
* Builds a string representation of this object.
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The context in which a DocBlock occurs.
|
||||||
|
*
|
||||||
|
* @author Vasil Rangelov <[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
class Context
|
||||||
|
{
|
||||||
|
/** @var string The current namespace. */
|
||||||
|
protected $namespace = '';
|
||||||
|
|
||||||
|
/** @var array List of namespace aliases => Fully Qualified Namespace. */
|
||||||
|
protected $namespace_aliases = array();
|
||||||
|
|
||||||
|
/** @var string Name of the structural element, within the namespace. */
|
||||||
|
protected $lsen = '';
|
||||||
|
|
||||||
|
/** @var string[] List of generics */
|
||||||
|
protected $generics = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cteates a new context.
|
||||||
|
* @param string $namespace The namespace where this DocBlock
|
||||||
|
* resides in.
|
||||||
|
* @param array $namespace_aliases List of namespace aliases => Fully
|
||||||
|
* Qualified Namespace.
|
||||||
|
* @param string $lsen Name of the structural element, within
|
||||||
|
* the namespace.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
$namespace = '',
|
||||||
|
array $namespace_aliases = array(),
|
||||||
|
$lsen = '',
|
||||||
|
array $generics = array()
|
||||||
|
) {
|
||||||
|
if (!empty($namespace)) {
|
||||||
|
$this->setNamespace($namespace);
|
||||||
|
}
|
||||||
|
$this->setNamespaceAliases($namespace_aliases);
|
||||||
|
$this->setLSEN($lsen);
|
||||||
|
$this->setGenerics($generics);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string The namespace where this DocBlock resides in.
|
||||||
|
*/
|
||||||
|
public function getNamespace()
|
||||||
|
{
|
||||||
|
return $this->namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array List of namespace aliases => Fully Qualified Namespace.
|
||||||
|
*/
|
||||||
|
public function getNamespaceAliases()
|
||||||
|
{
|
||||||
|
return $this->namespace_aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Local Structural Element Name.
|
||||||
|
*
|
||||||
|
* @return string Name of the structural element, within the namespace.
|
||||||
|
*/
|
||||||
|
public function getLSEN()
|
||||||
|
{
|
||||||
|
return $this->lsen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of generics.
|
||||||
|
*
|
||||||
|
* @return string[] List of generics
|
||||||
|
*/
|
||||||
|
public function getGenerics()
|
||||||
|
{
|
||||||
|
return $this->generics;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new namespace.
|
||||||
|
*
|
||||||
|
* Sets a new namespace for the context. Leading and trailing slashes are
|
||||||
|
* trimmed, and the keywords "global" and "default" are treated as aliases
|
||||||
|
* to no namespace.
|
||||||
|
*
|
||||||
|
* @param string $namespace The new namespace to set.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNamespace($namespace)
|
||||||
|
{
|
||||||
|
if ('global' !== $namespace
|
||||||
|
&& 'default' !== $namespace
|
||||||
|
) {
|
||||||
|
// Srip leading and trailing slash
|
||||||
|
$this->namespace = trim((string)$namespace, '\\');
|
||||||
|
} else {
|
||||||
|
$this->namespace = '';
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the namespace aliases, replacing all previous ones.
|
||||||
|
*
|
||||||
|
* @param array $namespace_aliases List of namespace aliases => Fully
|
||||||
|
* Qualified Namespace.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNamespaceAliases(array $namespace_aliases)
|
||||||
|
{
|
||||||
|
$this->namespace_aliases = array();
|
||||||
|
foreach ($namespace_aliases as $alias => $fqnn) {
|
||||||
|
$this->setNamespaceAlias($alias, $fqnn);
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a namespace alias to the context.
|
||||||
|
*
|
||||||
|
* @param string $alias The alias name (the part after "as", or the last
|
||||||
|
* part of the Fully Qualified Namespace Name) to add.
|
||||||
|
* @param string $fqnn The Fully Qualified Namespace Name for this alias.
|
||||||
|
* Any form of leading/trailing slashes are accepted, but what will be
|
||||||
|
* stored is a name, prefixed with a slash, and no trailing slash.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNamespaceAlias($alias, $fqnn)
|
||||||
|
{
|
||||||
|
$this->namespace_aliases[$alias] = '\\' . trim((string)$fqnn, '\\');
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new Local Structural Element Name.
|
||||||
|
*
|
||||||
|
* Sets a new Local Structural Element Name. A local name also contains
|
||||||
|
* punctuation determining the kind of structural element (e.g. trailing "("
|
||||||
|
* and ")" for functions and methods).
|
||||||
|
*
|
||||||
|
* @param string $lsen The new local name of a structural element.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setLSEN($lsen)
|
||||||
|
{
|
||||||
|
$this->lsen = (string)$lsen;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new list of generics.
|
||||||
|
*
|
||||||
|
* @param string[] $generics The new list of generics.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setGenerics(array $generics)
|
||||||
|
{
|
||||||
|
$this->generics = $generics;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-10
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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.
|
* Parses a Description of a DocBlock or tag.
|
||||||
@@ -26,7 +26,7 @@ class Description implements \Reflector
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $contents = '';
|
protected $contents = '';
|
||||||
|
|
||||||
/** @var array|null The contents, as an array of strings and Tag objects or null if it is not parsed yet. */
|
/** @var array The contents, as an array of strings and Tag objects. */
|
||||||
protected $parsedContents = null;
|
protected $parsedContents = null;
|
||||||
|
|
||||||
/** @var DocBlock The DocBlock which this description belongs to. */
|
/** @var DocBlock The DocBlock which this description belongs to. */
|
||||||
@@ -35,10 +35,10 @@ class Description implements \Reflector
|
|||||||
/**
|
/**
|
||||||
* Populates the fields of a description.
|
* Populates the fields of a description.
|
||||||
*
|
*
|
||||||
* @param string $content The description's content.
|
* @param string $content The description's contents.
|
||||||
* @param DocBlock $docblock The DocBlock which this description belongs to.
|
* @param DocBlock $docblock The DocBlock which this description belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($content, DocBlock $docblock = null)
|
public function __construct($content, ?DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->setContent($content)->setDocBlock($docblock);
|
$this->setContent($content)->setDocBlock($docblock);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ class Description implements \Reflector
|
|||||||
)
|
)
|
||||||
\}/Sux',
|
\}/Sux',
|
||||||
$this->contents,
|
$this->contents,
|
||||||
null,
|
-1,
|
||||||
PREG_SPLIT_DELIM_CAPTURE
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -167,9 +167,6 @@ class Description implements \Reflector
|
|||||||
} elseif (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
} elseif (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
||||||
$markdown = new \dflydev\markdown\MarkdownExtraParser();
|
$markdown = new \dflydev\markdown\MarkdownExtraParser();
|
||||||
$result = $markdown->transformMarkdown($result);
|
$result = $markdown->transformMarkdown($result);
|
||||||
} elseif (class_exists('League\CommonMark\CommonMarkConverter')) {
|
|
||||||
$markdown = new \League\CommonMark\CommonMarkConverter();
|
|
||||||
$result = $markdown->convertToHtml($result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim($result);
|
return trim($result);
|
||||||
@@ -193,7 +190,7 @@ class Description implements \Reflector
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setDocBlock(DocBlock $docblock = null)
|
public function setDocBlock(?DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->docblock = $docblock;
|
$this->docblock = $docblock;
|
||||||
|
|
||||||
+9
-15
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
namespace Barryvdh\Reflection\DocBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location a DocBlock occurs within a file.
|
* The location a DocBlock occurs within a file.
|
||||||
@@ -27,15 +27,15 @@ class Location
|
|||||||
/** @var int Column where the DocBlock text starts. */
|
/** @var int Column where the DocBlock text starts. */
|
||||||
protected $columnNumber = 0;
|
protected $columnNumber = 0;
|
||||||
|
|
||||||
public function __construct($lineNumber = 0, $columnNumber = 0)
|
public function __construct(
|
||||||
{
|
$lineNumber = 0,
|
||||||
|
$columnNumber = 0
|
||||||
|
) {
|
||||||
$this->setLineNumber($lineNumber)->setColumnNumber($columnNumber);
|
$this->setLineNumber($lineNumber)->setColumnNumber($columnNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the line number that is covered by this location.
|
* @return int Line where the DocBlock text starts.
|
||||||
*
|
|
||||||
* @return integer
|
|
||||||
*/
|
*/
|
||||||
public function getLineNumber()
|
public function getLineNumber()
|
||||||
{
|
{
|
||||||
@@ -43,10 +43,8 @@ class Location
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers which line number is covered by this location object.
|
|
||||||
*
|
|
||||||
* @param integer $lineNumber
|
|
||||||
*
|
*
|
||||||
|
* @param type $lineNumber
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setLineNumber($lineNumber)
|
public function setLineNumber($lineNumber)
|
||||||
@@ -57,9 +55,7 @@ class Location
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the column number (character position on a line) for this location object.
|
* @return int Column where the DocBlock text starts.
|
||||||
*
|
|
||||||
* @return integer
|
|
||||||
*/
|
*/
|
||||||
public function getColumnNumber()
|
public function getColumnNumber()
|
||||||
{
|
{
|
||||||
@@ -67,10 +63,8 @@ class Location
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the column number (character position on a line) for this location object.
|
|
||||||
*
|
|
||||||
* @param integer $columnNumber
|
|
||||||
*
|
*
|
||||||
|
* @param int $columnNumber
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setColumnNumber($columnNumber)
|
public function setColumnNumber($columnNumber)
|
||||||
+43
-7
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
namespace Barryvdh\Reflection\DocBlock;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock;
|
use Barryvdh\Reflection\DocBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes a DocBlock instance.
|
* Serializes a DocBlock instance.
|
||||||
@@ -23,6 +23,7 @@ use phpDocumentor\Reflection\DocBlock;
|
|||||||
*/
|
*/
|
||||||
class Serializer
|
class Serializer
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var string The string to indent the comment with. */
|
/** @var string The string to indent the comment with. */
|
||||||
protected $indentString = ' ';
|
protected $indentString = ' ';
|
||||||
|
|
||||||
@@ -35,6 +36,9 @@ class Serializer
|
|||||||
/** @var int|null The max length of a line. */
|
/** @var int|null The max length of a line. */
|
||||||
protected $lineLength = null;
|
protected $lineLength = null;
|
||||||
|
|
||||||
|
/** @var bool Separate tag groups. */
|
||||||
|
protected $separateTags = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Serializer instance.
|
* Create a Serializer instance.
|
||||||
*
|
*
|
||||||
@@ -44,30 +48,32 @@ class Serializer
|
|||||||
* @param bool $indentFirstLine Whether to indent the first line.
|
* @param bool $indentFirstLine Whether to indent the first line.
|
||||||
* @param int|null $lineLength The max length of a line or NULL to
|
* @param int|null $lineLength The max length of a line or NULL to
|
||||||
* disable line wrapping.
|
* disable line wrapping.
|
||||||
|
* @param bool $separateTags Separate tag groups.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$indent = 0,
|
$indent = 0,
|
||||||
$indentString = ' ',
|
$indentString = ' ',
|
||||||
$indentFirstLine = true,
|
$indentFirstLine = true,
|
||||||
$lineLength = null
|
$lineLength = null,
|
||||||
|
$separateTags = false
|
||||||
) {
|
) {
|
||||||
$this->setIndentationString($indentString);
|
$this->setIndentationString($indentString);
|
||||||
$this->setIndent($indent);
|
$this->setIndent($indent);
|
||||||
$this->setIsFirstLineIndented($indentFirstLine);
|
$this->setIsFirstLineIndented($indentFirstLine);
|
||||||
$this->setLineLength($lineLength);
|
$this->setLineLength($lineLength);
|
||||||
|
$this->setSeparateTags($separateTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the string to indent comments with.
|
* Sets the string to indent comments with.
|
||||||
*
|
*
|
||||||
* @param string $indentString The string to indent comments with.
|
* @param string $indentationString The string to indent comments with.
|
||||||
*
|
*
|
||||||
* @return $this This serializer object.
|
* @return $this This serializer object.
|
||||||
*/
|
*/
|
||||||
public function setIndentationString($indentString)
|
public function setIndentationString($indentString)
|
||||||
{
|
{
|
||||||
$this->indentString = (string)$indentString;
|
$this->indentString = (string)$indentString;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +164,29 @@ class Serializer
|
|||||||
return $this->lineLength;
|
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.
|
* Generate a DocBlock comment.
|
||||||
*
|
*
|
||||||
@@ -170,7 +199,6 @@ class Serializer
|
|||||||
$indent = str_repeat($this->indentString, $this->indent);
|
$indent = str_repeat($this->indentString, $this->indent);
|
||||||
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
||||||
|
|
||||||
$wrapLength = 80;
|
|
||||||
$text = $docblock->getText();
|
$text = $docblock->getText();
|
||||||
if ($this->lineLength) {
|
if ($this->lineLength) {
|
||||||
//3 === strlen(' * ')
|
//3 === strlen(' * ')
|
||||||
@@ -181,8 +209,12 @@ class Serializer
|
|||||||
|
|
||||||
$comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
|
$comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
|
||||||
|
|
||||||
|
$tags = array_values($docblock->getTags());
|
||||||
|
|
||||||
/** @var Tag $tag */
|
/** @var Tag $tag */
|
||||||
foreach ($docblock->getTags() as $tag) {
|
foreach ($tags as $key => $tag) {
|
||||||
|
$nextTag = isset($tags[$key + 1]) ? $tags[$key + 1] : null;
|
||||||
|
|
||||||
$tagText = (string) $tag;
|
$tagText = (string) $tag;
|
||||||
if ($this->lineLength) {
|
if ($this->lineLength) {
|
||||||
$tagText = wordwrap($tagText, $wrapLength);
|
$tagText = wordwrap($tagText, $wrapLength);
|
||||||
@@ -190,6 +222,10 @@ class Serializer
|
|||||||
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
||||||
|
|
||||||
$comment .= "{$indent} * {$tagText}\n";
|
$comment .= "{$indent} * {$tagText}\n";
|
||||||
|
|
||||||
|
if ($this->separateTags && $nextTag !== null && ! $tag->inSameGroup($nextTag)) {
|
||||||
|
$comment .= "{$indent} *\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment .= $indent . ' */';
|
$comment .= $indent . ' */';
|
||||||
+79
-67
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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.
|
* Parses a tag definition for a DocBlock.
|
||||||
@@ -59,43 +59,47 @@ class Tag implements \Reflector
|
|||||||
*/
|
*/
|
||||||
private static $tagHandlerMappings = array(
|
private static $tagHandlerMappings = array(
|
||||||
'author'
|
'author'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\AuthorTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\AuthorTag',
|
||||||
'covers'
|
'covers'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\CoversTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\CoversTag',
|
||||||
'deprecated'
|
'deprecated'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag',
|
||||||
'example'
|
'example'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ExampleTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\ExampleTag',
|
||||||
'link'
|
'link'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\LinkTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\LinkTag',
|
||||||
'method'
|
'method'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\MethodTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\MethodTag',
|
||||||
'param'
|
'param'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ParamTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\ParamTag',
|
||||||
'property-read'
|
'property-read'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyReadTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\PropertyReadTag',
|
||||||
'property'
|
'property'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\PropertyTag',
|
||||||
'property-write'
|
'property-write'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyWriteTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\PropertyWriteTag',
|
||||||
'return'
|
'return'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ReturnTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\ReturnTag',
|
||||||
'see'
|
'see'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\SeeTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\SeeTag',
|
||||||
'since'
|
'since'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\SinceTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\SinceTag',
|
||||||
'source'
|
'source'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\SourceTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\SourceTag',
|
||||||
'throw'
|
'throw'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\ThrowsTag',
|
||||||
'throws'
|
'throws'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\ThrowsTag',
|
||||||
'uses'
|
'uses'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\UsesTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\UsesTag',
|
||||||
'var'
|
'var'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\VarTag',
|
=> '\Barryvdh\Reflection\DocBlock\Tag\VarTag',
|
||||||
'version'
|
'version'
|
||||||
=> '\phpDocumentor\Reflection\DocBlock\Tag\VersionTag'
|
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag',
|
||||||
|
'SuppressWarnings'
|
||||||
|
=> '\Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag',
|
||||||
|
'template'
|
||||||
|
=> '\Barryvdh\Reflection\DocBlock\Tag\TemplateTag'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,10 +115,18 @@ class Tag implements \Reflector
|
|||||||
*/
|
*/
|
||||||
final public static function createInstance(
|
final public static function createInstance(
|
||||||
$tag_line,
|
$tag_line,
|
||||||
DocBlock $docblock = null,
|
?DocBlock $docblock = null,
|
||||||
Location $location = null
|
?Location $location = null
|
||||||
) {
|
) {
|
||||||
$matches = self::extractTagParts($tag_line);
|
if (!preg_match(
|
||||||
|
'/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us',
|
||||||
|
$tag_line,
|
||||||
|
$matches
|
||||||
|
)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'Invalid tag_line detected: ' . $tag_line
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$handler = __CLASS__;
|
$handler = __CLASS__;
|
||||||
if (isset(self::$tagHandlerMappings[$matches[1]])) {
|
if (isset(self::$tagHandlerMappings[$matches[1]])) {
|
||||||
@@ -184,8 +196,8 @@ class Tag implements \Reflector
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
$name,
|
$name,
|
||||||
$content,
|
$content,
|
||||||
DocBlock $docblock = null,
|
?DocBlock $docblock = null,
|
||||||
Location $location = null
|
?Location $location = null
|
||||||
) {
|
) {
|
||||||
$this
|
$this
|
||||||
->setName($name)
|
->setName($name)
|
||||||
@@ -209,13 +221,16 @@ class Tag implements \Reflector
|
|||||||
*
|
*
|
||||||
* @param string $name The new name of this tag.
|
* @param string $name The new name of this tag.
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException When an invalid tag name is provided.
|
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
|
* @throws \InvalidArgumentException When an invalid tag name is provided.
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->validateTagName($name);
|
if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'Invalid tag name supplied: ' . $name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->tag = $name;
|
$this->tag = $name;
|
||||||
|
|
||||||
@@ -310,7 +325,7 @@ class Tag implements \Reflector
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setDocBlock(DocBlock $docblock = null)
|
public function setDocBlock(?DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->docblock = $docblock;
|
$this->docblock = $docblock;
|
||||||
|
|
||||||
@@ -334,13 +349,46 @@ class Tag implements \Reflector
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setLocation(Location $location = null)
|
public function setLocation(?Location $location = null)
|
||||||
{
|
{
|
||||||
$this->location = $location;
|
$this->location = $location;
|
||||||
|
|
||||||
return $this;
|
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.
|
* Builds a string representation of this object.
|
||||||
*
|
*
|
||||||
@@ -363,40 +411,4 @@ class Tag implements \Reflector
|
|||||||
{
|
{
|
||||||
return "@{$this->getName()} {$this->getContent()}";
|
return "@{$this->getName()} {$this->getContent()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts all components for a tag.
|
|
||||||
*
|
|
||||||
* @param string $tagLine
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
private static function extractTagParts($tagLine)
|
|
||||||
{
|
|
||||||
$matches = array();
|
|
||||||
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us', $tagLine, $matches)) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $matches;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates if the tag name matches the expected format, otherwise throws an exception.
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function validateTagName($name)
|
|
||||||
{
|
|
||||||
if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
'The tag name "' . $name . '" is not wellformed. Tags may only consist of letters, underscores, '
|
|
||||||
. 'hyphens and backslashes.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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 an @author tag in a Docblock.
|
* Reflection class for an @author tag in a Docblock.
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @covers tag in a Docblock.
|
* Reflection class for a @covers tag in a Docblock.
|
||||||
+2
-2
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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.
|
* Reflection class for a @deprecated tag in a Docblock.
|
||||||
+27
-29
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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 @example tag in a Docblock.
|
* Reflection class for a @example tag in a Docblock.
|
||||||
@@ -41,11 +41,19 @@ class ExampleTag extends SourceTag
|
|||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
if (null === $this->content) {
|
if (null === $this->content) {
|
||||||
$filePath = '"' . $this->filePath . '"';
|
$filePath = '';
|
||||||
if ($this->isURI) {
|
if ($this->isURI) {
|
||||||
$filePath = $this->isUriRelative($this->filePath)
|
if (false === strpos($this->filePath, ':')) {
|
||||||
? str_replace('%2F', '/', rawurlencode($this->filePath))
|
$filePath = str_replace(
|
||||||
:$this->filePath;
|
'%2F',
|
||||||
|
'/',
|
||||||
|
rawurlencode($this->filePath)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$filePath = $this->filePath;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$filePath = '"' . $this->filePath . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->content = $filePath . ' ' . parent::getContent();
|
$this->content = $filePath . ' ' . parent::getContent();
|
||||||
@@ -53,7 +61,6 @@ class ExampleTag extends SourceTag
|
|||||||
|
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -124,35 +131,26 @@ class ExampleTag extends SourceTag
|
|||||||
* Sets the file path as an URI.
|
* Sets the file path as an URI.
|
||||||
*
|
*
|
||||||
* This function is equivalent to {@link setFilePath()}, except that it
|
* This function is equivalent to {@link setFilePath()}, except that it
|
||||||
* converts an URI to a file path before that.
|
* convers an URI to a file path before that.
|
||||||
*
|
*
|
||||||
* There is no getFileURI(), as {@link getFilePath()} is compatible.
|
* There is no getFileURI(), as {@link getFilePath()} is compatible.
|
||||||
*
|
*
|
||||||
* @param string $uri The new file URI to use as an example.
|
* @param type $uri The new file URI to use as an example.
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
*/
|
||||||
public function setFileURI($uri)
|
public function setFileURI($uri)
|
||||||
{
|
{
|
||||||
$this->isURI = true;
|
$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;
|
$this->content = null;
|
||||||
|
|
||||||
$this->filePath = $this->isUriRelative($uri)
|
|
||||||
? rawurldecode(str_replace(array('/', '\\'), '%2F', $uri))
|
|
||||||
: $this->filePath = $uri;
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the provided URI is relative or contains a complete scheme (and thus is absolute).
|
|
||||||
*
|
|
||||||
* @param string $uri
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function isUriRelative($uri)
|
|
||||||
{
|
|
||||||
return false === strpos($uri, ':');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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 @link tag in a Docblock.
|
* Reflection class for a @link tag in a Docblock.
|
||||||
+13
-3
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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 @method in a Docblock.
|
* Reflection class for a @method in a Docblock.
|
||||||
@@ -76,7 +76,17 @@ class MethodTag extends ReturnTag
|
|||||||
)?
|
)?
|
||||||
# Return type
|
# Return type
|
||||||
(?:
|
(?:
|
||||||
([\w\|_\\\\]+)
|
(
|
||||||
|
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
||||||
|
|
|
||||||
|
(?:
|
||||||
|
(?:[\w\|_\\\\]+(?:<[\s\S]*>)?)
|
||||||
|
# array notation
|
||||||
|
(?:\[\])*
|
||||||
|
)*
|
||||||
|
|
|
||||||
|
(?:\([\s\S]*\))?
|
||||||
|
)
|
||||||
\s+
|
\s+
|
||||||
)?
|
)?
|
||||||
# Legacy method name (not captured)
|
# Legacy method name (not captured)
|
||||||
+33
-8
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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 @param tag in a Docblock.
|
* Reflection class for a @param tag in a Docblock.
|
||||||
@@ -46,12 +46,37 @@ class ParamTag extends ReturnTag
|
|||||||
public function setContent($content)
|
public function setContent($content)
|
||||||
{
|
{
|
||||||
Tag::setContent($content);
|
Tag::setContent($content);
|
||||||
$parts = preg_split(
|
|
||||||
'/(\s+)/Su',
|
$parts = [];
|
||||||
$this->description,
|
$rest = $this->description;
|
||||||
3,
|
|
||||||
PREG_SPLIT_DELIM_CAPTURE
|
// 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 the first item that is encountered is not a variable; it is a type
|
||||||
if (isset($parts[0])
|
if (isset($parts[0])
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @property-read tag in a Docblock.
|
* Reflection class for a @property-read tag in a Docblock.
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @property tag in a Docblock.
|
* Reflection class for a @property tag in a Docblock.
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @property-write tag in a Docblock.
|
* Reflection class for a @property-write tag in a Docblock.
|
||||||
+36
-6
@@ -10,10 +10,10 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use Barryvdh\Reflection\DocBlock\Tag;
|
||||||
use phpDocumentor\Reflection\DocBlock\Type\Collection;
|
use Barryvdh\Reflection\DocBlock\Type\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @return tag in a Docblock.
|
* Reflection class for a @return tag in a Docblock.
|
||||||
@@ -36,7 +36,7 @@ class ReturnTag extends Tag
|
|||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
if (null === $this->content) {
|
if (null === $this->content) {
|
||||||
$this->content = "{$this->type} {$this->description}";
|
$this->content = "{$this->getType()} {$this->description}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->content;
|
return $this->content;
|
||||||
@@ -49,7 +49,7 @@ class ReturnTag extends Tag
|
|||||||
{
|
{
|
||||||
parent::setContent($content);
|
parent::setContent($content);
|
||||||
|
|
||||||
$parts = preg_split('/\s+/Su', $this->description, 2);
|
$parts = preg_split('/(?<!,)\s+/Su', $this->description, 2);
|
||||||
|
|
||||||
// any output is considered a type
|
// any output is considered a type
|
||||||
$this->type = $parts[0];
|
$this->type = $parts[0];
|
||||||
@@ -81,6 +81,35 @@ class ReturnTag extends Tag
|
|||||||
return (string) $this->getTypesCollection();
|
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.
|
* Returns the type collection.
|
||||||
*
|
*
|
||||||
@@ -91,7 +120,8 @@ class ReturnTag extends Tag
|
|||||||
if (null === $this->types) {
|
if (null === $this->types) {
|
||||||
$this->types = new Collection(
|
$this->types = new Collection(
|
||||||
array($this->type),
|
array($this->type),
|
||||||
$this->docblock ? $this->docblock->getContext() : null
|
$this->docblock ? $this->docblock->getContext() : null,
|
||||||
|
$this->docblock ? $this->docblock->getGenerics() : array()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->types;
|
return $this->types;
|
||||||
+2
-2
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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 @see tag in a Docblock.
|
* Reflection class for a @see tag in a Docblock.
|
||||||
+2
-2
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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.
|
* Reflection class for a @since tag in a Docblock.
|
||||||
+2
-2
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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.
|
* Reflection class for a @source tag in a Docblock.
|
||||||
@@ -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()}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
<?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 @template tag in a Docblock.
|
||||||
|
*
|
||||||
|
* @author chack1172 <[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
class TemplateTag extends ParamTag
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
protected $templateName = null;
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
protected $bound = null;
|
||||||
|
|
||||||
|
public function getContent()
|
||||||
|
{
|
||||||
|
if (null === $this->content) {
|
||||||
|
$this->content = $this->templateName;
|
||||||
|
if (null !== $this->bound) {
|
||||||
|
$this->content .= ' of ' . $this->bound;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function setContent($content)
|
||||||
|
{
|
||||||
|
$parts = explode(' of ', $content);
|
||||||
|
$this->templateName = $parts[0];
|
||||||
|
if (isset($parts[1])) {
|
||||||
|
$this->bound = $parts[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setDescription('');
|
||||||
|
$this->content = $content;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the template name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTemplateName()
|
||||||
|
{
|
||||||
|
return $this->templateName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the template name
|
||||||
|
*
|
||||||
|
* @param string $templateName
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTemplateName($templateName)
|
||||||
|
{
|
||||||
|
$this->templateName = $templateName;
|
||||||
|
$this->content = null;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bound type
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getBound()
|
||||||
|
{
|
||||||
|
return $this->bound;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bound type
|
||||||
|
* @param string|null $bound
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setBound($bound)
|
||||||
|
{
|
||||||
|
$this->bound = $bound;
|
||||||
|
$this->content = null;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @throws tag in a Docblock.
|
* Reflection class for a @throws tag in a Docblock.
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @uses tag in a Docblock.
|
* Reflection class for a @uses tag in a Docblock.
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @var tag in a Docblock.
|
* Reflection class for a @var tag in a Docblock.
|
||||||
+2
-2
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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 @version tag in a Docblock.
|
* Reflection class for a @version tag in a Docblock.
|
||||||
+102
-7
@@ -10,9 +10,9 @@
|
|||||||
* @link http://phpdoc.org
|
* @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
|
* Collection
|
||||||
@@ -37,7 +37,14 @@ class Collection extends \ArrayObject
|
|||||||
protected static $keywords = array(
|
protected static $keywords = array(
|
||||||
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
|
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
|
||||||
'object', 'mixed', 'array', 'resource', 'void', 'null', 'scalar',
|
'object', 'mixed', 'array', 'resource', 'void', 'null', 'scalar',
|
||||||
'callback', 'callable', 'false', 'true', 'self', '$this', 'static'
|
'callback', 'callable', 'false', 'true', 'self', '$this', 'static',
|
||||||
|
'array-key', 'number', 'iterable', 'pure-callable', 'closed-resource',
|
||||||
|
'open-resource', 'positive-int', 'negative-int', 'non-positive-int',
|
||||||
|
'non-negative-int', 'non-zero-int', 'non-empty-array', 'list',
|
||||||
|
'non-empty-list', 'key-of', 'value-of', 'template-type', 'class-string',
|
||||||
|
'callable-string', 'numeric-string', 'non-empty-string',
|
||||||
|
'non-falsy-string', 'literal-string', 'lowercase-string', 'never',
|
||||||
|
'never-return', 'never-returns', 'no-return', 'int-mask', 'int-mask-of'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,6 +57,13 @@ class Collection extends \ArrayObject
|
|||||||
*/
|
*/
|
||||||
protected $context = null;
|
protected $context = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of generics types
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $generics = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the namespace and aliases; uses that to add and expand the
|
* Registers the namespace and aliases; uses that to add and expand the
|
||||||
* given types.
|
* given types.
|
||||||
@@ -60,9 +74,11 @@ class Collection extends \ArrayObject
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
array $types = array(),
|
array $types = array(),
|
||||||
Context $context = null
|
?Context $context = null,
|
||||||
|
array $generics = array()
|
||||||
) {
|
) {
|
||||||
$this->context = null === $context ? new Context() : $context;
|
$this->context = null === $context ? new Context() : $context;
|
||||||
|
$this->generics = array_merge($this->context->getGenerics(), $generics);
|
||||||
|
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$this->add($type);
|
$this->add($type);
|
||||||
@@ -106,7 +122,7 @@ class Collection extends \ArrayObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// separate the type by the OR operator
|
// separate the type by the OR operator
|
||||||
$type_parts = explode(self::OPERATOR_OR, $type);
|
$type_parts = $this->explode($type);
|
||||||
foreach ($type_parts as $part) {
|
foreach ($type_parts as $part) {
|
||||||
$expanded_type = $this->expand($part);
|
$expanded_type = $this->expand($part);
|
||||||
if ($expanded_type) {
|
if ($expanded_type) {
|
||||||
@@ -126,6 +142,40 @@ class Collection extends \ArrayObject
|
|||||||
return implode(self::OPERATOR_OR, $this->getArrayCopy());
|
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.
|
* Analyzes the given type and returns the FQCN variant.
|
||||||
*
|
*
|
||||||
@@ -151,17 +201,31 @@ class Collection extends \ArrayObject
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preg_match('/^[\w-]+<.*>$/', $type)) {
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($type[0] === '(') {
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isTypeAnArray($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->isRelativeType($type) && !$this->isTypeAKeyword($type) && !$this->isTypeAGeneric($type)) {
|
||||||
|
|
||||||
|
if($this->shouldBeAbsolute($type)){
|
||||||
|
return self::OPERATOR_NAMESPACE . $type;
|
||||||
|
}
|
||||||
|
|
||||||
$type_parts = explode(self::OPERATOR_NAMESPACE, $type, 2);
|
$type_parts = explode(self::OPERATOR_NAMESPACE, $type, 2);
|
||||||
|
|
||||||
$namespace_aliases = $this->context->getNamespaceAliases();
|
$namespace_aliases = $this->context->getNamespaceAliases();
|
||||||
// if the first segment is not an alias; prepend namespace name and
|
// if the first segment is not an alias; prepend namespace name and
|
||||||
// return
|
// 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();
|
$namespace = $this->context->getNamespace();
|
||||||
if ('' !== $namespace) {
|
if ('' !== $namespace) {
|
||||||
$namespace .= self::OPERATOR_NAMESPACE;
|
$namespace .= self::OPERATOR_NAMESPACE;
|
||||||
@@ -169,6 +233,12 @@ class Collection extends \ArrayObject
|
|||||||
return self::OPERATOR_NAMESPACE . $namespace . $type;
|
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_parts[0] = $namespace_aliases[$type_parts[0]];
|
||||||
$type = implode(self::OPERATOR_NAMESPACE, $type_parts);
|
$type = implode(self::OPERATOR_NAMESPACE, $type_parts);
|
||||||
}
|
}
|
||||||
@@ -218,4 +288,29 @@ class Collection extends \ArrayObject
|
|||||||
return ($type[0] !== self::OPERATOR_NAMESPACE)
|
return ($type[0] !== self::OPERATOR_NAMESPACE)
|
||||||
|| $this->isTypeAKeyword($type);
|
|| $this->isTypeAKeyword($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detects whether the given type represents a generic.
|
||||||
|
*
|
||||||
|
* @param string $type A relative or absolute type as defined in the
|
||||||
|
* phpDocumentor documentation.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isTypeAGeneric($type)
|
||||||
|
{
|
||||||
|
return in_array($type, $this->generics, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,75 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of phpDocumentor.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @copyright 2010-2015 Mike van Riel<[email protected]>
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
|
||||||
* @link http://phpdoc.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides information about the Context in which the DocBlock occurs that receives this context.
|
|
||||||
*
|
|
||||||
* A DocBlock does not know of its own accord in which namespace it occurs and which namespace aliases are applicable
|
|
||||||
* for the block of code in which it is in. This information is however necessary to resolve Class names in tags since
|
|
||||||
* you can provide a short form or make use of namespace aliases.
|
|
||||||
*
|
|
||||||
* The phpDocumentor Reflection component knows how to create this class but if you use the DocBlock parser from your
|
|
||||||
* own application it is possible to generate a Context class using the ContextFactory; this will analyze the file in
|
|
||||||
* which an associated class resides for its namespace and imports.
|
|
||||||
*
|
|
||||||
* @see ContextFactory::createFromClassReflector()
|
|
||||||
* @see ContextFactory::createForNamespace()
|
|
||||||
*/
|
|
||||||
final class Context
|
|
||||||
{
|
|
||||||
/** @var string The current namespace. */
|
|
||||||
private $namespace = '';
|
|
||||||
|
|
||||||
/** @var array List of namespace aliases => Fully Qualified Namespace. */
|
|
||||||
private $namespaceAliases = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN)
|
|
||||||
* format (without a preceding `\`).
|
|
||||||
*
|
|
||||||
* @param string $namespace The namespace where this DocBlock resides in.
|
|
||||||
* @param array $namespaceAliases List of namespace aliases => Fully Qualified Namespace.
|
|
||||||
*/
|
|
||||||
public function __construct($namespace, array $namespaceAliases = [])
|
|
||||||
{
|
|
||||||
$this->namespace = ('global' !== $namespace && 'default' !== $namespace)
|
|
||||||
? trim((string)$namespace, '\\')
|
|
||||||
: '';
|
|
||||||
|
|
||||||
foreach ($namespaceAliases as $alias => $fqnn) {
|
|
||||||
$this->namespaceAliases[$alias] = trim((string)$fqnn, '\\');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Qualified Namespace Name (thus without `\` in front) where the associated element is in.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return $this->namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of Qualified Namespace Names (thus without `\` in front) that are imported, the keys represent
|
|
||||||
* the alias for the imported Namespace.
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function getNamespaceAliases()
|
|
||||||
{
|
|
||||||
return $this->namespaceAliases;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of phpDocumentor.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @copyright 2010-2015 Mike van Riel<[email protected]>
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
|
||||||
* @link http://phpdoc.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience class to create a Context for DocBlocks when not using the Reflection Component of phpDocumentor.
|
|
||||||
*
|
|
||||||
* For a DocBlock to be able to resolve types that use partial namespace names or rely on namespace imports we need to
|
|
||||||
* provide a bit of context so that the DocBlock can read that and based on it decide how to resolve the types to
|
|
||||||
* Fully Qualified names.
|
|
||||||
*
|
|
||||||
* @see Context for more information.
|
|
||||||
*/
|
|
||||||
final class ContextFactory
|
|
||||||
{
|
|
||||||
/** The literal used at the end of a use statement. */
|
|
||||||
const T_LITERAL_END_OF_USE = ';';
|
|
||||||
|
|
||||||
/** The literal used between sets of use statements */
|
|
||||||
const T_LITERAL_USE_SEPARATOR = ',';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a Context given a Class Reflection.
|
|
||||||
*
|
|
||||||
* @param \ReflectionClass $class
|
|
||||||
*
|
|
||||||
* @see Context for more information on Contexts.
|
|
||||||
*
|
|
||||||
* @return Context
|
|
||||||
*/
|
|
||||||
public function createFromClassReflector(\ReflectionClass $class)
|
|
||||||
{
|
|
||||||
return $this->createForNamespace(
|
|
||||||
$class->getNamespaceName(),
|
|
||||||
file_get_contents($class->getFileName())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a Context for a namespace in the provided file contents.
|
|
||||||
*
|
|
||||||
* @param string $namespace It does not matter if a `\` precedes the namespace name, this method first normalizes.
|
|
||||||
* @param string $fileContents the file's contents to retrieve the aliases from with the given namespace.
|
|
||||||
*
|
|
||||||
* @see Context for more information on Contexts.
|
|
||||||
*
|
|
||||||
* @return Context
|
|
||||||
*/
|
|
||||||
public function createForNamespace($namespace, $fileContents)
|
|
||||||
{
|
|
||||||
$namespace = trim($namespace, '\\');
|
|
||||||
$useStatements = [];
|
|
||||||
$currentNamespace = '';
|
|
||||||
$tokens = new \ArrayIterator(token_get_all($fileContents));
|
|
||||||
|
|
||||||
while ($tokens->valid()) {
|
|
||||||
switch ($tokens->current()[0]) {
|
|
||||||
case T_NAMESPACE:
|
|
||||||
$currentNamespace = $this->parseNamespace($tokens);
|
|
||||||
break;
|
|
||||||
case T_USE:
|
|
||||||
if ($currentNamespace === $namespace) {
|
|
||||||
$useStatements = array_merge($useStatements, $this->parseUseStatement($tokens));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$tokens->next();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Context($namespace, $useStatements);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deduce the name from tokens when we are at the T_NAMESPACE token.
|
|
||||||
*
|
|
||||||
* @param \ArrayIterator $tokens
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function parseNamespace(\ArrayIterator $tokens)
|
|
||||||
{
|
|
||||||
// skip to the first string or namespace separator
|
|
||||||
$this->skipToNextStringOrNamespaceSeparator($tokens);
|
|
||||||
|
|
||||||
$name = '';
|
|
||||||
while ($tokens->valid() && ($tokens->current()[0] === T_STRING || $tokens->current()[0] === T_NS_SEPARATOR)
|
|
||||||
) {
|
|
||||||
$name .= $tokens->current()[1];
|
|
||||||
$tokens->next();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deduce the names of all imports when we are at the T_USE token.
|
|
||||||
*
|
|
||||||
* @param \ArrayIterator $tokens
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
private function parseUseStatement(\ArrayIterator $tokens)
|
|
||||||
{
|
|
||||||
$uses = [];
|
|
||||||
$continue = true;
|
|
||||||
|
|
||||||
while ($continue) {
|
|
||||||
$this->skipToNextStringOrNamespaceSeparator($tokens);
|
|
||||||
|
|
||||||
list($alias, $fqnn) = $this->extractUseStatement($tokens);
|
|
||||||
$uses[$alias] = $fqnn;
|
|
||||||
if ($tokens->current()[0] === self::T_LITERAL_END_OF_USE) {
|
|
||||||
$continue = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $uses;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fast-forwards the iterator as longs as we don't encounter a T_STRING or T_NS_SEPARATOR token.
|
|
||||||
*
|
|
||||||
* @param \ArrayIterator $tokens
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function skipToNextStringOrNamespaceSeparator(\ArrayIterator $tokens)
|
|
||||||
{
|
|
||||||
while ($tokens->valid() && ($tokens->current()[0] !== T_STRING) && ($tokens->current()[0] !== T_NS_SEPARATOR)) {
|
|
||||||
$tokens->next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deduce the namespace name and alias of an import when we are at the T_USE token or have not reached the end of
|
|
||||||
* a USE statement yet.
|
|
||||||
*
|
|
||||||
* @param \ArrayIterator $tokens
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function extractUseStatement(\ArrayIterator $tokens)
|
|
||||||
{
|
|
||||||
$result = [''];
|
|
||||||
while ($tokens->valid()
|
|
||||||
&& ($tokens->current()[0] !== self::T_LITERAL_USE_SEPARATOR)
|
|
||||||
&& ($tokens->current()[0] !== self::T_LITERAL_END_OF_USE)
|
|
||||||
) {
|
|
||||||
if ($tokens->current()[0] === T_AS) {
|
|
||||||
$result[] = '';
|
|
||||||
}
|
|
||||||
if ($tokens->current()[0] === T_STRING || $tokens->current()[0] === T_NS_SEPARATOR) {
|
|
||||||
$result[count($result) - 1] .= $tokens->current()[1];
|
|
||||||
}
|
|
||||||
$tokens->next();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($result) == 1) {
|
|
||||||
$result[] = substr($result[0], strrpos($result[0], '\\') + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_reverse($result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+6
-4
@@ -10,17 +10,19 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
class DescriptionTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testConstruct()
|
public function testConstruct()
|
||||||
{
|
{
|
||||||
@@ -106,7 +108,7 @@ LONGDESC;
|
|||||||
|
|
||||||
$parsedDescription = $parsedContents[1]->getParsedDescription();
|
$parsedDescription = $parsedContents[1]->getParsedDescription();
|
||||||
$this->assertCount(3, $parsedDescription);
|
$this->assertCount(3, $parsedDescription);
|
||||||
$this->assertSame("inline tag with\n", $parsedDescription[0]);
|
$this->assertSame("inline tag with", trim($parsedDescription[0]));
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
__NAMESPACE__ . '\Tag\LinkTag',
|
__NAMESPACE__ . '\Tag\LinkTag',
|
||||||
$parsedDescription[1]
|
$parsedDescription[1]
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* a link for the covers doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -31,7 +33,7 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exContent
|
* @param string $exContent
|
||||||
* @param string $exReference
|
* @param string $exReference
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\CoversTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* a link for the @deprecated doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +34,7 @@ class DeprecatedTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exDescription
|
* @param string $exDescription
|
||||||
* @param string $exVersion
|
* @param string $exVersion
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* understand the @source DocBlock.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -33,7 +35,7 @@ class ExampleTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exLineCount
|
* @param string $exLineCount
|
||||||
* @param string $exFilepath
|
* @param string $exFilepath
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\ExampleTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Ben Selby <benmatselby@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* a link for the @link doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +34,7 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exDescription
|
* @param string $exDescription
|
||||||
* @param string $exLink
|
* @param string $exLink
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\LinkTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+25
-5
@@ -10,17 +10,19 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class MethodTagTest extends \PHPUnit_Framework_TestCase
|
class MethodTagTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $signature The signature to test.
|
* @param string $signature The signature to test.
|
||||||
@@ -34,7 +36,7 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $description The short description mentioned in the
|
* @param string $description The short description mentioned in the
|
||||||
* signature.
|
* signature.
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\MethodTag
|
||||||
* @dataProvider getTestSignatures
|
* @dataProvider getTestSignatures
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -140,7 +142,25 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'static static foo()',
|
'static static foo()',
|
||||||
true, 'foo', 'static', true, 0, ''
|
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
-6
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* understand the @param DocBlock.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -33,7 +35,7 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $extractedVarName
|
* @param string $extractedVarName
|
||||||
* @param string $extractedDescription
|
* @param string $extractedDescription
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\ParamTag
|
||||||
* @dataProvider provideDataForConstructor
|
* @dataProvider provideDataForConstructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -112,7 +114,75 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('int'),
|
array('int'),
|
||||||
'$bob',
|
'$bob',
|
||||||
"Type on a new line"
|
"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',
|
||||||
|
''
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+28
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* understand the @return DocBlock.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +34,7 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $extractedTypes
|
* @param string $extractedTypes
|
||||||
* @param string $extractedDescription
|
* @param string $extractedDescription
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\ReturnTag
|
||||||
* @dataProvider provideDataForConstructor
|
* @dataProvider provideDataForConstructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -96,6 +98,27 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
'int',
|
'int',
|
||||||
array('int'),
|
array('int'),
|
||||||
"Number of Bobs"
|
"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
-4
@@ -10,17 +10,19 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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
|
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
||||||
@@ -31,7 +33,7 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exContent
|
* @param string $exContent
|
||||||
* @param string $exReference
|
* @param string $exReference
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* a link for the @since doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +34,7 @@ class SinceTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exDescription
|
* @param string $exDescription
|
||||||
* @param string $exVersion
|
* @param string $exVersion
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\SinceTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* understand the @source DocBlock.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +34,7 @@ class SourceTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exStartingLine
|
* @param string $exStartingLine
|
||||||
* @param string $exLineCount
|
* @param string $exLineCount
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\SourceTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor SuppressWarnings Tag Test
|
||||||
|
*
|
||||||
|
* 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 PHPUnit\Framework\Test;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
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)',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phpDocumentor Template Tag Test
|
||||||
|
*
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* @author Daniel O'Connor <[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 PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \Barryvdh\Reflection\DocBlock\Tag\TemplateTag
|
||||||
|
*
|
||||||
|
* @author Daniel O'Connor <[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
|
||||||
|
*/
|
||||||
|
class TemplateTagTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
||||||
|
* for the @see doc block.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $exContent
|
||||||
|
* @param string $exReference
|
||||||
|
*
|
||||||
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||||
|
* @dataProvider provideDataForConstuctor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exTemplateName,
|
||||||
|
$exBound
|
||||||
|
) {
|
||||||
|
$tag = new TemplateTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
|
$this->assertEquals($exTemplateName, $tag->getTemplateName());
|
||||||
|
$this->assertEquals($exBound, $tag->getBound());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstuctor()
|
||||||
|
{
|
||||||
|
// $type, $content, $exContent, $exDescription, $exTemplateName, $exBound
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'template',
|
||||||
|
'TValue',
|
||||||
|
'TValue',
|
||||||
|
'',
|
||||||
|
'TValue',
|
||||||
|
null,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'template',
|
||||||
|
'TValue of string',
|
||||||
|
'TValue of string',
|
||||||
|
'',
|
||||||
|
'TValue',
|
||||||
|
'string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* understand the @throws DocBlock.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +34,7 @@ class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $extractedTypes
|
* @param string $extractedTypes
|
||||||
* @param string $extractedDescription
|
* @param string $extractedDescription
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag
|
||||||
* @dataProvider provideDataForConstructor
|
* @dataProvider provideDataForConstructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+8
-5
@@ -10,20 +10,23 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* a link for the @uses doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -31,7 +34,7 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exContent
|
* @param string $exContent
|
||||||
* @param string $exReference
|
* @param string $exReference
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\UsesTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+8
-5
@@ -10,20 +10,23 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* understand the @var doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +35,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exVariable
|
* @param string $exVariable
|
||||||
* @param string $exDescription
|
* @param string $exDescription
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+7
-5
@@ -10,20 +10,22 @@
|
|||||||
* @link http://phpdoc.org
|
* @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>
|
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @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.
|
* a link for the @version doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@@ -32,7 +34,7 @@ class VersionTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @param string $exDescription
|
* @param string $exDescription
|
||||||
* @param string $exVersion
|
* @param string $exVersion
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VersionTag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag\VersionTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
+19
-18
@@ -10,34 +10,35 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
namespace Barryvdh\Reflection\DocBlock;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock;
|
use Barryvdh\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Context;
|
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>
|
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class TagTest extends \PHPUnit_Framework_TestCase
|
class TagTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testInvalidTagLine()
|
public function testInvalidTagLine()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
Tag::createInstance('Invalid tag line');
|
Tag::createInstance('Invalid tag line');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
*
|
*
|
||||||
* @return void
|
* @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
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testTagHandlerCorrectRegistration()
|
public function testTagHandlerCorrectRegistration()
|
||||||
{
|
{
|
||||||
if (0 == ini_get('allow_url_include')) {
|
if (!ini_get('allow_url_include')) {
|
||||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||||
}
|
}
|
||||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||||
@@ -93,7 +94,7 @@ class TagTest extends \PHPUnit_Framework_TestCase
|
|||||||
include 'data:text/plain;base64,'. base64_encode(
|
include 'data:text/plain;base64,'. base64_encode(
|
||||||
<<<TAG_HANDLER
|
<<<TAG_HANDLER
|
||||||
<?php
|
<?php
|
||||||
class MyTagHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
class MyTagHandler extends \Barryvdh\Reflection\DocBlock\Tag {}
|
||||||
TAG_HANDLER
|
TAG_HANDLER
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -118,8 +119,8 @@ TAG_HANDLER
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testTagHandlerCorrectRegistration
|
* @depends testTagHandlerCorrectRegistration
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
* @covers \Barryvdh\Reflection\DocBlock\Tag::createInstance
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -162,8 +163,8 @@ TAG_HANDLER
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testTagHandlerCorrectRegistration
|
* @depends testTagHandlerCorrectRegistration
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
* @covers \Barryvdh\Reflection\DocBlock\Tag::createInstance
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -201,7 +202,7 @@ TAG_HANDLER
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -232,7 +233,7 @@ TAG_HANDLER
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -265,14 +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.
|
* understand the @var doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $exDescription
|
* @param string $exDescription
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag
|
* @covers \Barryvdh\Reflection\DocBlock\Tag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -0,0 +1,350 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Collection Test
|
||||||
|
*
|
||||||
|
* 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\Type;
|
||||||
|
|
||||||
|
use Barryvdh\Reflection\DocBlock\Context;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \Barryvdh\Reflection\DocBlock\Type\Collection
|
||||||
|
*
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
class CollectionTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::getContext
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstruct()
|
||||||
|
{
|
||||||
|
$collection = new Collection();
|
||||||
|
$this->assertCount(0, $collection);
|
||||||
|
$this->assertEquals('', $collection->getContext()->getNamespace());
|
||||||
|
$this->assertCount(0, $collection->getContext()->getNamespaceAliases());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructWithTypes()
|
||||||
|
{
|
||||||
|
$collection = new Collection(array('integer', 'string'));
|
||||||
|
$this->assertCount(2, $collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructWithNamespace()
|
||||||
|
{
|
||||||
|
$collection = new Collection(array(), new Context('\My\Space'));
|
||||||
|
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
||||||
|
|
||||||
|
$collection = new Collection(array(), new Context('My\Space'));
|
||||||
|
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
||||||
|
|
||||||
|
$collection = new Collection(array(), null);
|
||||||
|
$this->assertEquals('', $collection->getContext()->getNamespace());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructWithNamespaceAliases()
|
||||||
|
{
|
||||||
|
$fixture = array('a' => 'b');
|
||||||
|
$collection = new Collection(array(), new Context(null, $fixture));
|
||||||
|
$this->assertEquals(
|
||||||
|
array('a' => '\b'),
|
||||||
|
$collection->getContext()->getNamespaceAliases()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $fixture
|
||||||
|
* @param array $expected
|
||||||
|
*
|
||||||
|
* @dataProvider provideTypesToExpand
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testAdd($fixture, $expected)
|
||||||
|
{
|
||||||
|
$collection = new Collection(
|
||||||
|
array(),
|
||||||
|
new Context('\My\Space', array('Alias' => '\My\Space\Aliasing'))
|
||||||
|
);
|
||||||
|
$collection->add($fixture);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $collection->getArrayCopy());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $fixture
|
||||||
|
* @param array $expected
|
||||||
|
*
|
||||||
|
* @dataProvider provideTypesToExpandWithoutNamespace
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testAddWithoutNamespace($fixture, $expected)
|
||||||
|
{
|
||||||
|
$collection = new Collection(
|
||||||
|
array(),
|
||||||
|
new Context(null, array('Alias' => '\My\Space\Aliasing'))
|
||||||
|
);
|
||||||
|
$collection->add($fixture);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $collection->getArrayCopy());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $fixture
|
||||||
|
* @param array $expected
|
||||||
|
*
|
||||||
|
* @dataProvider provideTypesToExpandWithGenerics
|
||||||
|
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testAddWithGenerics($fixture, $expected)
|
||||||
|
{
|
||||||
|
$collection = new Collection(
|
||||||
|
array(),
|
||||||
|
new Context('\My\Space', array('Alias' => '\My\Space\Aliasing'), '', array('TParent')),
|
||||||
|
array('TValue')
|
||||||
|
);
|
||||||
|
$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());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the types and their expected values to test the retrieval of
|
||||||
|
* types.
|
||||||
|
*
|
||||||
|
* @param string $method Name of the method consuming this data provider.
|
||||||
|
* @param string $namespace Name of the namespace to user as basis.
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function provideTypesToExpand($method, $namespace = '\My\Space\\')
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('', array()),
|
||||||
|
array(' ', array()),
|
||||||
|
array('int', array('int')),
|
||||||
|
array('int ', array('int')),
|
||||||
|
array('string', array('string')),
|
||||||
|
array('DocBlock', array($namespace.'DocBlock')),
|
||||||
|
array('DocBlock[]', array($namespace.'DocBlock[]')),
|
||||||
|
array(' DocBlock ', array($namespace.'DocBlock')),
|
||||||
|
array('\My\Space\DocBlock', array('\My\Space\DocBlock')),
|
||||||
|
array('Alias\DocBlock', array('\My\Space\Aliasing\DocBlock')),
|
||||||
|
array(
|
||||||
|
'DocBlock|Tag',
|
||||||
|
array($namespace .'DocBlock', $namespace .'Tag')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'DocBlock|null',
|
||||||
|
array($namespace.'DocBlock', 'null')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'\My\Space\DocBlock|Tag',
|
||||||
|
array('\My\Space\DocBlock', $namespace.'Tag')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'DocBlock[]|null',
|
||||||
|
array($namespace.'DocBlock[]', 'null')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'DocBlock[]|int[]',
|
||||||
|
array($namespace.'DocBlock[]', 'int[]')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'array<string>',
|
||||||
|
array('array<string>')
|
||||||
|
),
|
||||||
|
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()')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'int<0, 100>',
|
||||||
|
array('int<0, 100>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'non-empty-array<string>',
|
||||||
|
array('non-empty-array<string>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'non-empty-array<int, string>',
|
||||||
|
array('non-empty-array<int, string>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'list<string>',
|
||||||
|
array('list<string>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'non-empty-list<string>',
|
||||||
|
array('non-empty-list<string>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key-of<MyClass::ARRAY_CONST>',
|
||||||
|
array('key-of<MyClass::ARRAY_CONST>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'value-of<MyClass::ARRAY_CONST>',
|
||||||
|
array('value-of<MyClass::ARRAY_CONST>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'value-of<MyBackedEnum>',
|
||||||
|
array('value-of<MyBackedEnum>')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'iterable<string>',
|
||||||
|
array('iterable<string>')
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the types and their expected values to test the retrieval of
|
||||||
|
* types when no namespace is available.
|
||||||
|
*
|
||||||
|
* @param string $method Name of the method consuming this data provider.
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function provideTypesToExpandWithoutNamespace($method)
|
||||||
|
{
|
||||||
|
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')
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the types and their expected values to test the retrieval of
|
||||||
|
* types including generics.
|
||||||
|
*
|
||||||
|
* @param string $method Name of the method consuming this data provider.
|
||||||
|
* @param string $namespace Name of the namespace to user as basis.
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function provideTypesToExpandWithGenerics($method, $namespace = '\My\Space\\')
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('TValue', array('TValue')),
|
||||||
|
array('TValue[]', array('TValue[]')),
|
||||||
|
array('TValue|DocBlock', array('TValue', $namespace . 'DocBlock')),
|
||||||
|
array('TParent', array('TParent')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
-21
@@ -10,24 +10,25 @@
|
|||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection;
|
namespace Barryvdh\Reflection;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Context;
|
use Barryvdh\Reflection\DocBlock\Context;
|
||||||
use phpDocumentor\Reflection\DocBlock\Location;
|
use Barryvdh\Reflection\DocBlock\Location;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag\ReturnTag;
|
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>
|
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
class DocBlockTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock
|
* @covers \Barryvdh\Reflection\DocBlock
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +71,7 @@ DOCBLOCK;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::splitDocBlock
|
* @covers \Barryvdh\Reflection\DocBlock::splitDocBlock
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +93,7 @@ DOCBLOCK;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::isTemplateStart
|
* @covers \Barryvdh\Reflection\DocBlock::isTemplateStart
|
||||||
*/
|
*/
|
||||||
public function testIfStartOfTemplateIsDiscovered()
|
public function testIfStartOfTemplateIsDiscovered()
|
||||||
{
|
{
|
||||||
@@ -113,7 +114,7 @@ DOCBLOCK;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::isTemplateEnd
|
* @covers \Barryvdh\Reflection\DocBlock::isTemplateEnd
|
||||||
*/
|
*/
|
||||||
public function testIfEndOfTemplateIsDiscovered()
|
public function testIfEndOfTemplateIsDiscovered()
|
||||||
{
|
{
|
||||||
@@ -127,7 +128,7 @@ DOCBLOCK;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::cleanInput
|
* @covers \Barryvdh\Reflection\DocBlock::cleanInput
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -144,7 +145,7 @@ DOCBLOCK;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::__construct
|
* @covers \Barryvdh\Reflection\DocBlock::__construct
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -152,7 +153,7 @@ DOCBLOCK;
|
|||||||
{
|
{
|
||||||
$object = new DocBlock(new \ReflectionClass($this));
|
$object = new DocBlock(new \ReflectionClass($this));
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'Test class for phpDocumentor\Reflection\DocBlock',
|
'Test class for Barryvdh\Reflection\DocBlock',
|
||||||
$object->getShortDescription()
|
$object->getShortDescription()
|
||||||
);
|
);
|
||||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||||
@@ -165,12 +166,12 @@ DOCBLOCK;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExceptionOnInvalidObject()
|
public function testExceptionOnInvalidObject()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
new DocBlock($this);
|
new DocBlock($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,21 +197,22 @@ DOCBLOCK;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||||
* @expectedException \LogicException
|
* @expectedException \LogicException
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testInvalidTagBlock()
|
public function testInvalidTagBlock()
|
||||||
{
|
{
|
||||||
if (0 == ini_get('allow_url_include')) {
|
if (!ini_get('allow_url_include')) {
|
||||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
include 'data:text/plain;base64,'. base64_encode(
|
include 'data:text/plain;base64,'. base64_encode(
|
||||||
<<<DOCBLOCK_EXTENSION
|
<<<DOCBLOCK_EXTENSION
|
||||||
<?php
|
<?php
|
||||||
class MyReflectionDocBlock extends \phpDocumentor\Reflection\DocBlock {
|
class MyReflectionDocBlock extends \Barryvdh\Reflection\DocBlock {
|
||||||
protected function splitDocBlock(\$comment) {
|
protected function splitDocBlock(\$comment) {
|
||||||
return array('', '', 'Invalid tag block');
|
return array('', '', 'Invalid tag block');
|
||||||
}
|
}
|
||||||
@@ -262,7 +264,7 @@ DOCBLOCK;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testConstructFromReflector
|
* @depends testConstructFromReflector
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
* @covers \Barryvdh\Reflection\DocBlock::getTagsByName
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -275,7 +277,7 @@ DOCBLOCK;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testConstructWithTagsOnly
|
* @depends testConstructWithTagsOnly
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -293,7 +295,7 @@ DOCBLOCK;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testConstructWithTagsOnly
|
* @depends testConstructWithTagsOnly
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -316,7 +318,7 @@ DOCBLOCK;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testConstructWithTagsOnly
|
* @depends testConstructWithTagsOnly
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
* @covers \Barryvdh\Reflection\DocBlock::getTagsByName
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -334,4 +336,22 @@ DOCBLOCK;
|
|||||||
$this->assertCount(1, $object->getTagsByName('return'));
|
$this->assertCount(1, $object->getTagsByName('return'));
|
||||||
$this->assertCount(2, $object->getTagsByName('param'));
|
$this->assertCount(2, $object->getTagsByName('param'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testGenericsAreParsed()
|
||||||
|
{
|
||||||
|
$fixture = <<<DOCBLOCK
|
||||||
|
/**
|
||||||
|
* @template TValue
|
||||||
|
* @param TValue
|
||||||
|
* @return TValue
|
||||||
|
*/
|
||||||
|
DOCBLOCK;
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertSame(array('TValue'), $object->getGenerics());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of phpDocumentor.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @copyright 2010-2015 Mike van Riel<[email protected]>
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
|
||||||
* @link http://phpdoc.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock {
|
|
||||||
|
|
||||||
// Added imports on purpose as mock for the unit tests, please do not remove.
|
|
||||||
use Mockery as m;
|
|
||||||
use phpDocumentor\Reflection\DocBlock,
|
|
||||||
phpDocumentor\Reflection\DocBlock\Tag;
|
|
||||||
use \ReflectionClass; // yes, the slash is part of the test
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\ContextFactory
|
|
||||||
* @covers ::<private>
|
|
||||||
*/
|
|
||||||
class ContextFactoryTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @covers ::createFromClassReflector
|
|
||||||
* @covers ::createForNamespace
|
|
||||||
* @uses phpDocumentor\Reflection\DocBlock\Context
|
|
||||||
*/
|
|
||||||
public function testReadsNamespaceFromClassReflection()
|
|
||||||
{
|
|
||||||
$fixture = new ContextFactory();
|
|
||||||
$context = $fixture->createFromClassReflector(new ReflectionClass($this));
|
|
||||||
|
|
||||||
$this->assertSame(__NAMESPACE__, $context->getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::createFromClassReflector
|
|
||||||
* @covers ::createForNamespace
|
|
||||||
* @uses phpDocumentor\Reflection\DocBlock\Context
|
|
||||||
*/
|
|
||||||
public function testReadsAliasesFromClassReflection()
|
|
||||||
{
|
|
||||||
$fixture = new ContextFactory();
|
|
||||||
$expected = [
|
|
||||||
'm' => 'Mockery',
|
|
||||||
'DocBlock' => 'phpDocumentor\Reflection\DocBlock',
|
|
||||||
'Tag' => 'phpDocumentor\Reflection\DocBlock\Tag',
|
|
||||||
'ReflectionClass' => 'ReflectionClass'
|
|
||||||
];
|
|
||||||
$context = $fixture->createFromClassReflector(new ReflectionClass($this));
|
|
||||||
|
|
||||||
$this->assertSame($expected, $context->getNamespaceAliases());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::createForNamespace
|
|
||||||
* @uses phpDocumentor\Reflection\DocBlock\Context
|
|
||||||
*/
|
|
||||||
public function testReadsNamespaceFromProvidedNamespaceAndContent()
|
|
||||||
{
|
|
||||||
$fixture = new ContextFactory();
|
|
||||||
$context = $fixture->createForNamespace(__NAMESPACE__, file_get_contents(__FILE__));
|
|
||||||
|
|
||||||
$this->assertSame(__NAMESPACE__, $context->getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::createForNamespace
|
|
||||||
* @uses phpDocumentor\Reflection\DocBlock\Context
|
|
||||||
*/
|
|
||||||
public function testReadsAliasesFromProvidedNamespaceAndContent()
|
|
||||||
{
|
|
||||||
$fixture = new ContextFactory();
|
|
||||||
$expected = [
|
|
||||||
'm' => 'Mockery',
|
|
||||||
'DocBlock' => 'phpDocumentor\Reflection\DocBlock',
|
|
||||||
'Tag' => 'phpDocumentor\Reflection\DocBlock\Tag',
|
|
||||||
'ReflectionClass' => 'ReflectionClass'
|
|
||||||
];
|
|
||||||
$context = $fixture->createForNamespace(__NAMESPACE__, file_get_contents(__FILE__));
|
|
||||||
|
|
||||||
$this->assertSame($expected, $context->getNamespaceAliases());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Mock {
|
|
||||||
// the following import should not show in the tests above
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of phpDocumentor.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @copyright 2010-2015 Mike van Riel<[email protected]>
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
|
||||||
* @link http://phpdoc.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
|
||||||
|
|
||||||
use Mockery as m;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Context
|
|
||||||
*/
|
|
||||||
class ContextTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @covers ::__construct
|
|
||||||
* @covers ::getNamespace
|
|
||||||
*/
|
|
||||||
public function testProvidesANormalizedNamespace()
|
|
||||||
{
|
|
||||||
$fixture = new Context('\My\Space');
|
|
||||||
$this->assertSame('My\Space', $fixture->getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::__construct
|
|
||||||
* @covers ::getNamespace
|
|
||||||
*/
|
|
||||||
public function testInterpretsNamespaceNamedGlobalAsRootNamespace()
|
|
||||||
{
|
|
||||||
$fixture = new Context('global');
|
|
||||||
$this->assertSame('', $fixture->getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::__construct
|
|
||||||
* @covers ::getNamespace
|
|
||||||
*/
|
|
||||||
public function testInterpretsNamespaceNamedDefaultAsRootNamespace()
|
|
||||||
{
|
|
||||||
$fixture = new Context('default');
|
|
||||||
$this->assertSame('', $fixture->getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::__construct
|
|
||||||
* @covers ::getNamespaceAliases
|
|
||||||
*/
|
|
||||||
public function testProvidesNormalizedNamespaceAliases()
|
|
||||||
{
|
|
||||||
$fixture = new Context('', ['Space' => '\My\Space']);
|
|
||||||
$this->assertSame(['Space' => 'My\Space'], $fixture->getNamespaceAliases());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* phpDocumentor Collection Test
|
|
||||||
*
|
|
||||||
* 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\DocBlock\Type;
|
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test class for \phpDocumentor\Reflection\DocBlock\Type\Collection
|
|
||||||
*
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
class CollectionTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getContext
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testConstruct()
|
|
||||||
{
|
|
||||||
$collection = new Collection();
|
|
||||||
$this->assertCount(0, $collection);
|
|
||||||
$this->assertEquals('', $collection->getContext()->getNamespace());
|
|
||||||
$this->assertCount(0, $collection->getContext()->getNamespaceAliases());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testConstructWithTypes()
|
|
||||||
{
|
|
||||||
$collection = new Collection(array('integer', 'string'));
|
|
||||||
$this->assertCount(2, $collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testConstructWithNamespace()
|
|
||||||
{
|
|
||||||
$collection = new Collection(array(), new Context('\My\Space'));
|
|
||||||
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
|
||||||
|
|
||||||
$collection = new Collection(array(), new Context('My\Space'));
|
|
||||||
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
|
||||||
|
|
||||||
$collection = new Collection(array(), null);
|
|
||||||
$this->assertEquals('', $collection->getContext()->getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testConstructWithNamespaceAliases()
|
|
||||||
{
|
|
||||||
$fixture = array('a' => 'b');
|
|
||||||
$collection = new Collection(array(), new Context(null, $fixture));
|
|
||||||
$this->assertEquals(
|
|
||||||
array('a' => '\b'),
|
|
||||||
$collection->getContext()->getNamespaceAliases()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $fixture
|
|
||||||
* @param array $expected
|
|
||||||
*
|
|
||||||
* @dataProvider provideTypesToExpand
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testAdd($fixture, $expected)
|
|
||||||
{
|
|
||||||
$collection = new Collection(
|
|
||||||
array(),
|
|
||||||
new Context('\My\Space', array('Alias' => '\My\Space\Aliasing'))
|
|
||||||
);
|
|
||||||
$collection->add($fixture);
|
|
||||||
|
|
||||||
$this->assertSame($expected, $collection->getArrayCopy());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $fixture
|
|
||||||
* @param array $expected
|
|
||||||
*
|
|
||||||
* @dataProvider provideTypesToExpandWithoutNamespace
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testAddWithoutNamespace($fixture, $expected)
|
|
||||||
{
|
|
||||||
$collection = new Collection(
|
|
||||||
array(),
|
|
||||||
new Context(null, array('Alias' => '\My\Space\Aliasing'))
|
|
||||||
);
|
|
||||||
$collection->add($fixture);
|
|
||||||
|
|
||||||
$this->assertSame($expected, $collection->getArrayCopy());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
|
||||||
* @expectedException InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testAddWithInvalidArgument()
|
|
||||||
{
|
|
||||||
$collection = new Collection();
|
|
||||||
$collection->add(array());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the types and their expected values to test the retrieval of
|
|
||||||
* types.
|
|
||||||
*
|
|
||||||
* @param string $method Name of the method consuming this data provider.
|
|
||||||
* @param string $namespace Name of the namespace to user as basis.
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function provideTypesToExpand($method, $namespace = '\My\Space\\')
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('', array()),
|
|
||||||
array(' ', array()),
|
|
||||||
array('int', array('int')),
|
|
||||||
array('int ', array('int')),
|
|
||||||
array('string', array('string')),
|
|
||||||
array('DocBlock', array($namespace.'DocBlock')),
|
|
||||||
array('DocBlock[]', array($namespace.'DocBlock[]')),
|
|
||||||
array(' DocBlock ', array($namespace.'DocBlock')),
|
|
||||||
array('\My\Space\DocBlock', array('\My\Space\DocBlock')),
|
|
||||||
array('Alias\DocBlock', array('\My\Space\Aliasing\DocBlock')),
|
|
||||||
array(
|
|
||||||
'DocBlock|Tag',
|
|
||||||
array($namespace .'DocBlock', $namespace .'Tag')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'DocBlock|null',
|
|
||||||
array($namespace.'DocBlock', 'null')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'\My\Space\DocBlock|Tag',
|
|
||||||
array('\My\Space\DocBlock', $namespace.'Tag')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'DocBlock[]|null',
|
|
||||||
array($namespace.'DocBlock[]', 'null')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'DocBlock[]|int[]',
|
|
||||||
array($namespace.'DocBlock[]', 'int[]')
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the types and their expected values to test the retrieval of
|
|
||||||
* types when no namespace is available.
|
|
||||||
*
|
|
||||||
* @param string $method Name of the method consuming this data provider.
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function provideTypesToExpandWithoutNamespace($method)
|
|
||||||
{
|
|
||||||
return $this->provideTypesToExpand($method, '\\');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user