mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6ff9f9360 | ||
|
|
ffb733ef78 | ||
|
|
818be8de6a | ||
|
|
268ae0f584 | ||
|
|
6b3854ad25 | ||
|
|
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 | ||
|
|
d68dbdc53d | ||
|
|
fb5dfa51d4 | ||
|
|
ae02953010 | ||
|
|
fd0ac20074 | ||
|
|
21feb61eb5 | ||
|
|
280a3ce56d | ||
|
|
0604d62704 | ||
|
|
a66d783afd | ||
|
|
84de81c009 | ||
|
|
38743b6779 | ||
|
|
0d52cb6389 | ||
|
|
2281569ebc | ||
|
|
e0faa7f04f | ||
|
|
39a08094f1 | ||
|
|
07b195e1ee | ||
|
|
0bca477a34 | ||
|
|
66a7d3bf31 | ||
|
|
2331fc92f6 | ||
|
|
b1922e00de | ||
|
|
53ba484043 | ||
|
|
cfb3ebea55 | ||
|
|
c33820b04b | ||
|
|
280c4a1d44 | ||
|
|
66ae84e9d7 | ||
|
|
3023fb2220 | ||
|
|
a9b6edf3ce | ||
|
|
f3d1a28bf7 | ||
|
|
fd9e6bd26d | ||
|
|
d5e4b2ec73 | ||
|
|
bae8be0dcd | ||
|
|
3a5d30e027 | ||
|
|
d2414cd3dc | ||
|
|
6d705c1a0f | ||
|
|
ab0bcb8d31 |
@@ -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
|
||||
+3
-1
@@ -1,2 +1,4 @@
|
||||
.idea
|
||||
vendor
|
||||
.phpunit.result.cache
|
||||
composer.lock
|
||||
vendor
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
script:
|
||||
- vendor/phpunit/phpunit/composer/bin/phpunit
|
||||
|
||||
before_script:
|
||||
- sudo apt-get -qq update > /dev/null
|
||||
- phpenv rehash > /dev/null
|
||||
- composer selfupdate --quiet
|
||||
- composer install --dev
|
||||
- vendor/phpunit/phpunit/composer/bin/phpunit
|
||||
- composer update --dev
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#phpdocumentor"
|
||||
email:
|
||||
- [email protected]
|
||||
- [email protected]
|
||||
- [email protected]
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010 Mike van Riel
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,6 +1,9 @@
|
||||
The ReflectionDocBlock Component [](https://travis-ci.org/phpDocumentor/ReflectionDocBlock)
|
||||
The ReflectionDocBlock Component
|
||||
================================
|
||||
|
||||
> This is a fork of [phpDocumentor/ReflectionDocBlock 2.x](https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/2.x) combined with bits of [phpDocumentor/TypeResolver](https://github.com/phpDocumentor/TypeResolver) and various tweaks. The main reason for this fork is to add functionality for https://github.com/barryvdh/laravel-ide-helper
|
||||
> Any other use of this library is discouraged. You are probably better of using https://github.com/phpDocumentor/ReflectionDocBlock directly.
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
|
||||
+11
-5
@@ -6,15 +6,21 @@
|
||||
{"name": "Mike van Riel", "email": "[email protected]"}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"dflydev/markdown": "1.0.*"
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {"Barryvdh": ["src/"]}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*@stable"
|
||||
"phpunit/phpunit": "^8.5.14|^9"
|
||||
},
|
||||
"suggest": {
|
||||
"dflydev/markdown": "~1.0",
|
||||
"erusev/parsedown": "~1.0"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
-475
@@ -1,475 +0,0 @@
|
||||
{
|
||||
"hash": "c6115c20a4a284f6ca14e676e788b4d3",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dflydev/markdown",
|
||||
"version": "v1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dflydev/dflydev-markdown.git",
|
||||
"reference": "v1.0.2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/dflydev/dflydev-markdown/zipball/v1.0.2",
|
||||
"reference": "v1.0.2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"time": "2012-01-15 19:36:37",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"dflydev\\markdown": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"New BSD License"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dragonfly Development Inc.",
|
||||
"email": "[email protected]",
|
||||
"homepage": "http://dflydev.com"
|
||||
},
|
||||
{
|
||||
"name": "Beau Simensen",
|
||||
"email": "[email protected]",
|
||||
"homepage": "http://beausimensen.com"
|
||||
},
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"homepage": "http://michelf.com"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net"
|
||||
}
|
||||
],
|
||||
"description": "PHP Markdown & Extra",
|
||||
"homepage": "http://github.com/dflydev/dflydev-markdown",
|
||||
"keywords": [
|
||||
"markdown"
|
||||
]
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "1.2.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "1.2.7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage/archive/1.2.7.zip",
|
||||
"reference": "1.2.7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-file-iterator": ">=1.3.0@stable",
|
||||
"phpunit/php-token-stream": ">=1.1.3@stable",
|
||||
"phpunit/php-text-template": ">=1.1.1@stable"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-dom": "*",
|
||||
"ext-xdebug": ">=2.0.5"
|
||||
},
|
||||
"time": "2012-12-02 14:54:55",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHP/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"coverage",
|
||||
"xunit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
"version": "1.3.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sebastianbergmann/php-file-iterator.git",
|
||||
"reference": "1.3.3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/sebastianbergmann/php-file-iterator/zipball/1.3.3",
|
||||
"reference": "1.3.3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"time": "2012-10-11 04:44:38",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"File/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
|
||||
"homepage": "http://www.phpunit.de/",
|
||||
"keywords": [
|
||||
"filesystem",
|
||||
"iterator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-text-template",
|
||||
"version": "1.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sebastianbergmann/php-text-template.git",
|
||||
"reference": "1.1.4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/sebastianbergmann/php-text-template/zipball/1.1.4",
|
||||
"reference": "1.1.4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"time": "2012-10-31 11:15:28",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"Text/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Simple template engine.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
|
||||
"keywords": [
|
||||
"template"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
"version": "1.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "1.0.4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer/zipball/1.0.4",
|
||||
"reference": "1.0.4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"time": "2012-10-11 04:45:58",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHP/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Utility class for timing",
|
||||
"homepage": "http://www.phpunit.de/",
|
||||
"keywords": [
|
||||
"timer"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-token-stream",
|
||||
"version": "1.1.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sebastianbergmann/php-token-stream.git",
|
||||
"reference": "1.1.5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/sebastianbergmann/php-token-stream/zipball/1.1.5",
|
||||
"reference": "1.1.5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"time": "2012-10-11 04:47:14",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHP/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Wrapper around PHP's tokenizer extension.",
|
||||
"homepage": "http://www.phpunit.de/",
|
||||
"keywords": [
|
||||
"tokenizer"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "3.7.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "3.7.10"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit/archive/3.7.10.zip",
|
||||
"reference": "3.7.10",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-file-iterator": ">=1.3.1",
|
||||
"phpunit/php-text-template": ">=1.1.1",
|
||||
"phpunit/php-code-coverage": ">=1.2.1",
|
||||
"phpunit/php-timer": ">=1.0.2",
|
||||
"phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0",
|
||||
"symfony/yaml": ">=2.1.0",
|
||||
"ext-dom": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-reflection": "*",
|
||||
"ext-spl": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"phpunit/php-invoker": ">=1.1.0",
|
||||
"ext-json": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-tokenizer": "*"
|
||||
},
|
||||
"time": "2012-12-02 14:56:55",
|
||||
"bin": [
|
||||
"composer/bin/phpunit"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.7.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHPUnit/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
"",
|
||||
"../../symfony/yaml/"
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "The PHP Unit Testing framework.",
|
||||
"homepage": "http://www.phpunit.de/",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"phpunit",
|
||||
"xunit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "1.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "1.2.2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects/archive/1.2.2.zip",
|
||||
"reference": "1.2.2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-text-template": ">=1.1.1@stable"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
},
|
||||
"time": "2012-11-05 10:39:13",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHPUnit/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Mock Object library for PHPUnit",
|
||||
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
|
||||
"keywords": [
|
||||
"mock",
|
||||
"xunit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.1.4",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml",
|
||||
"reference": "v2.1.4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/symfony/Yaml/archive/v2.1.4.zip",
|
||||
"reference": "v2.1.4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"time": "2012-11-08 09:51:48",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Yaml": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com"
|
||||
}
|
||||
],
|
||||
"aliases": [
|
||||
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"phpunit/phpunit": 0
|
||||
}
|
||||
}
|
||||
+6
-7
@@ -1,14 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<phpunit colors="true" strict="true" bootstrap="vendor/autoload.php">
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="phpDocumentor\Reflection\DocBlock">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Barryvdh\Reflection;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock\Location;
|
||||
use Barryvdh\Reflection\DocBlock\Tag\TemplateTag;
|
||||
|
||||
/**
|
||||
* Parses the DocBlock for any structure.
|
||||
@@ -40,12 +41,21 @@ class DocBlock implements \Reflector
|
||||
*/
|
||||
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. */
|
||||
protected $context = null;
|
||||
|
||||
/** @var Location Information about the location of this DocBlock. */
|
||||
protected $location = null;
|
||||
|
||||
/** @var bool Is this DocBlock (the start of) a template? */
|
||||
protected $isTemplateStart = false;
|
||||
|
||||
/** @var bool Does this DocBlock signify the end of a DocBlock template? */
|
||||
protected $isTemplateEnd = false;
|
||||
|
||||
/**
|
||||
* Parses the given docblock and populates the member fields.
|
||||
*
|
||||
@@ -65,8 +75,8 @@ class DocBlock implements \Reflector
|
||||
*/
|
||||
public function __construct(
|
||||
$docblock,
|
||||
Context $context = null,
|
||||
Location $location = null
|
||||
?Context $context = null,
|
||||
?Location $location = null
|
||||
) {
|
||||
if (is_object($docblock)) {
|
||||
if (!method_exists($docblock, 'getDocComment')) {
|
||||
@@ -81,7 +91,9 @@ class DocBlock implements \Reflector
|
||||
|
||||
$docblock = $this->cleanInput($docblock);
|
||||
|
||||
list($short, $long, $tags) = $this->splitDocBlock($docblock);
|
||||
list($templateMarker, $short, $long, $tags) = $this->splitDocBlock($docblock);
|
||||
$this->isTemplateStart = $templateMarker === '#@+';
|
||||
$this->isTemplateEnd = $templateMarker === '#@-';
|
||||
$this->short_description = $short;
|
||||
$this->long_description = new DocBlock\Description($long, $this);
|
||||
$this->parseTags($tags);
|
||||
@@ -119,74 +131,86 @@ class DocBlock implements \Reflector
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the DocBlock into a short description, long description and
|
||||
* block of tags.
|
||||
* Splits the DocBlock into a template marker, summary, description and block of tags.
|
||||
*
|
||||
* @param string $comment Comment to split into the sub-parts.
|
||||
*
|
||||
* @author RichardJ Special thanks to RichardJ for the regex responsible
|
||||
* for the split.
|
||||
* @author Richard van Velzen (@_richardJ) Special thanks to Richard for the regex responsible for the split.
|
||||
* @author Mike van Riel <[email protected]> for extending the regex with template marker support.
|
||||
*
|
||||
* @return string[] containing the short-, long description and an element
|
||||
* containing the tags.
|
||||
* @return string[] containing the template marker (if any), summary, description and a string containing the tags.
|
||||
*/
|
||||
protected function splitDocBlock($comment)
|
||||
{
|
||||
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This
|
||||
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
|
||||
// performance impact of running a regular expression
|
||||
if (strpos($comment, '@') === 0) {
|
||||
$matches = array('', '', $comment);
|
||||
} else {
|
||||
// clears all extra horizontal whitespace from the line endings
|
||||
// to prevent parsing issues
|
||||
$comment = preg_replace('/\h*$/Sum', '', $comment);
|
||||
|
||||
/*
|
||||
* Splits the docblock into a short description, long description and
|
||||
* tags section
|
||||
* - The short description is started from the first character until
|
||||
* a dot is encountered followed by a newline OR
|
||||
* two consecutive newlines (horizontal whitespace is taken into
|
||||
* account to consider spacing errors)
|
||||
* - The long description, any character until a new line is
|
||||
* encountered followed by an @ and word characters (a tag).
|
||||
* This is optional.
|
||||
* - Tags; the remaining characters
|
||||
*
|
||||
* Big thanks to RichardJ for contributing this Regular Expression
|
||||
*/
|
||||
preg_match(
|
||||
'/
|
||||
\A (
|
||||
[^\n.]+
|
||||
(?:
|
||||
(?! \. \n | \n{2} ) # disallow the first seperator here
|
||||
[\n.] (?! [ \t]* @\pL ) # disallow second seperator
|
||||
[^\n.]+
|
||||
)*
|
||||
\.?
|
||||
)
|
||||
(?:
|
||||
\s* # first seperator (actually newlines but it\'s all whitespace)
|
||||
(?! @\pL ) # disallow the rest, to make sure this one doesn\'t match,
|
||||
#if it doesn\'t exist
|
||||
(
|
||||
[^\n]+
|
||||
(?: \n+
|
||||
(?! [ \t]* @\pL ) # disallow second seperator (@param)
|
||||
[^\n]+
|
||||
)*
|
||||
)
|
||||
)?
|
||||
(\s+ [\s\S]*)? # everything that follows
|
||||
/ux',
|
||||
$comment,
|
||||
$matches
|
||||
);
|
||||
array_shift($matches);
|
||||
return array('', '', '', $comment);
|
||||
}
|
||||
|
||||
while (count($matches) < 3) {
|
||||
// clears all extra horizontal whitespace from the line endings to prevent parsing issues
|
||||
$comment = preg_replace('/\h*$/Sum', '', $comment);
|
||||
|
||||
/*
|
||||
* Splits the docblock into a template marker, short description, long description and tags section
|
||||
*
|
||||
* - The template marker is empty, #@+ or #@- if the DocBlock starts with either of those (a newline may
|
||||
* occur after it and will be stripped).
|
||||
* - The short description is started from the first character until a dot is encountered followed by a
|
||||
* newline OR two consecutive newlines (horizontal whitespace is taken into account to consider spacing
|
||||
* errors). This is optional.
|
||||
* - The long description, any character until a new line is encountered followed by an @ and word
|
||||
* characters (a tag). This is optional.
|
||||
* - Tags; the remaining characters
|
||||
*
|
||||
* Big thanks to RichardJ for contributing this Regular Expression
|
||||
*/
|
||||
preg_match(
|
||||
'/
|
||||
\A
|
||||
# 1. Extract the template marker
|
||||
(?:(\#\@\+|\#\@\-)\n?)?
|
||||
|
||||
# 2. Extract the summary
|
||||
(?:
|
||||
(?! @\pL ) # The summary may not start with an @
|
||||
(
|
||||
[^\n.]+
|
||||
(?:
|
||||
(?! \. \n | \n{2} ) # End summary upon a dot followed by newline or two newlines
|
||||
[\n.] (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line
|
||||
[^\n.]+ # Include anything else
|
||||
)*
|
||||
\.?
|
||||
)?
|
||||
)
|
||||
|
||||
# 3. Extract the description
|
||||
(?:
|
||||
\s* # Some form of whitespace _must_ precede a description because a summary must be there
|
||||
(?! @\pL ) # The description may not start with an @
|
||||
(
|
||||
[^\n]+
|
||||
(?: \n+
|
||||
(?! [ \t]* @\pL ) # End description when an @ is found as first character on a new line
|
||||
[^\n]+ # Include anything else
|
||||
)*
|
||||
)
|
||||
)?
|
||||
|
||||
# 4. Extract the tags (anything that follows)
|
||||
(\s+ [\s\S]*)? # everything that follows
|
||||
/ux',
|
||||
$comment,
|
||||
$matches
|
||||
);
|
||||
array_shift($matches);
|
||||
|
||||
while (count($matches) < 4) {
|
||||
$matches[] = '';
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
@@ -209,20 +233,20 @@ class DocBlock implements \Reflector
|
||||
);
|
||||
}
|
||||
foreach (explode("\n", $tags) as $tag_line) {
|
||||
if (trim($tag_line) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
||||
$result[] = $tag_line;
|
||||
} else {
|
||||
$result[count($result) - 1] .= PHP_EOL . $tag_line;
|
||||
$result[count($result) - 1] .= "\n" . $tag_line;
|
||||
}
|
||||
}
|
||||
|
||||
// create proper Tag objects
|
||||
foreach ($result as $key => $tag_line) {
|
||||
$result[$key] = Tag::createInstance($tag_line, $this);
|
||||
$tag = Tag::createInstance(trim($tag_line), $this);
|
||||
if ($tag instanceof TemplateTag) {
|
||||
$this->generics[] = $tag->getTemplateName();
|
||||
}
|
||||
$result[$key] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +285,7 @@ class DocBlock implements \Reflector
|
||||
*/
|
||||
public function setText($comment)
|
||||
{
|
||||
list($short, $long) = $this->splitDocBlock($comment);
|
||||
list(,$short, $long) = $this->splitDocBlock($comment);
|
||||
$this->short_description = $short;
|
||||
$this->long_description = new DocBlock\Description($long, $this);
|
||||
return $this;
|
||||
@@ -286,6 +310,44 @@ class DocBlock implements \Reflector
|
||||
return $this->long_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this DocBlock is the start of a Template section.
|
||||
*
|
||||
* A Docblock may serve as template for a series of subsequent DocBlocks. This is indicated by a special marker
|
||||
* (`#@+`) that is appended directly after the opening `/**` of a DocBlock.
|
||||
*
|
||||
* An example of such an opening is:
|
||||
*
|
||||
* ```
|
||||
* /**#@+
|
||||
* * My DocBlock
|
||||
* * /
|
||||
* ```
|
||||
*
|
||||
* The description and tags (not the summary!) are copied onto all subsequent DocBlocks and also applied to all
|
||||
* elements that follow until another DocBlock is found that contains the closing marker (`#@-`).
|
||||
*
|
||||
* @see self::isTemplateEnd() for the check whether a closing marker was provided.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTemplateStart()
|
||||
{
|
||||
return $this->isTemplateStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this DocBlock is the end of a Template section.
|
||||
*
|
||||
* @see self::isTemplateStart() for a more complete description of the Docblock Template functionality.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTemplateEnd()
|
||||
{
|
||||
return $this->isTemplateEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current context.
|
||||
*
|
||||
@@ -385,6 +447,33 @@ class DocBlock implements \Reflector
|
||||
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.
|
||||
|
||||
@@ -29,7 +29,10 @@ class Context
|
||||
|
||||
/** @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
|
||||
@@ -42,13 +45,15 @@ class Context
|
||||
public function __construct(
|
||||
$namespace = '',
|
||||
array $namespace_aliases = array(),
|
||||
$lsen = ''
|
||||
$lsen = '',
|
||||
array $generics = array()
|
||||
) {
|
||||
if (!empty($namespace)) {
|
||||
$this->setNamespace($namespace);
|
||||
}
|
||||
$this->setNamespaceAliases($namespace_aliases);
|
||||
$this->setLSEN($lsen);
|
||||
$this->setGenerics($generics);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,6 +81,16 @@ class Context
|
||||
{
|
||||
return $this->lsen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of generics.
|
||||
*
|
||||
* @return string[] List of generics
|
||||
*/
|
||||
public function getGenerics()
|
||||
{
|
||||
return $this->generics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new namespace.
|
||||
@@ -151,4 +166,17 @@ class Context
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use ArrayIterator;
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
use ReflectionClassConstant;
|
||||
use ReflectionMethod;
|
||||
use ReflectionParameter;
|
||||
use ReflectionProperty;
|
||||
use Reflector;
|
||||
use RuntimeException;
|
||||
use UnexpectedValueException;
|
||||
|
||||
use function define;
|
||||
use function defined;
|
||||
use function file_exists;
|
||||
use function file_get_contents;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use function is_string;
|
||||
use function strrpos;
|
||||
use function substr;
|
||||
use function token_get_all;
|
||||
use function trim;
|
||||
|
||||
use const T_AS;
|
||||
use const T_CLASS;
|
||||
use const T_CURLY_OPEN;
|
||||
use const T_DOLLAR_OPEN_CURLY_BRACES;
|
||||
use const T_NAME_FULLY_QUALIFIED;
|
||||
use const T_NAME_QUALIFIED;
|
||||
use const T_NAMESPACE;
|
||||
use const T_NS_SEPARATOR;
|
||||
use const T_STRING;
|
||||
use const T_TRAIT;
|
||||
use const T_USE;
|
||||
|
||||
if (!defined('T_NAME_QUALIFIED')) {
|
||||
define('T_NAME_QUALIFIED', 10001);
|
||||
}
|
||||
|
||||
if (!defined('T_NAME_FULLY_QUALIFIED')) {
|
||||
define('T_NAME_FULLY_QUALIFIED', 10002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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. */
|
||||
private const T_LITERAL_END_OF_USE = ';';
|
||||
|
||||
/** The literal used between sets of use statements */
|
||||
private const T_LITERAL_USE_SEPARATOR = ',';
|
||||
|
||||
/**
|
||||
* Build a Context given a Class Reflection.
|
||||
*
|
||||
* @see Context for more information on Contexts.
|
||||
*/
|
||||
public function createFromReflector(Reflector $reflector): Context
|
||||
{
|
||||
if ($reflector instanceof ReflectionClass) {
|
||||
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
|
||||
/** @var ReflectionClass<object> $reflector */
|
||||
|
||||
return $this->createFromReflectionClass($reflector);
|
||||
}
|
||||
|
||||
if ($reflector instanceof ReflectionParameter) {
|
||||
return $this->createFromReflectionParameter($reflector);
|
||||
}
|
||||
|
||||
if ($reflector instanceof ReflectionMethod) {
|
||||
return $this->createFromReflectionMethod($reflector);
|
||||
}
|
||||
|
||||
if ($reflector instanceof ReflectionProperty) {
|
||||
return $this->createFromReflectionProperty($reflector);
|
||||
}
|
||||
|
||||
if ($reflector instanceof ReflectionClassConstant) {
|
||||
return $this->createFromReflectionClassConstant($reflector);
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException('Unhandled \Reflector instance given: ' . get_class($reflector));
|
||||
}
|
||||
|
||||
private function createFromReflectionParameter(ReflectionParameter $parameter): Context
|
||||
{
|
||||
$class = $parameter->getDeclaringClass();
|
||||
if (!$class) {
|
||||
throw new InvalidArgumentException('Unable to get class of ' . $parameter->getName());
|
||||
}
|
||||
|
||||
return $this->createFromReflectionClass($class);
|
||||
}
|
||||
|
||||
private function createFromReflectionMethod(ReflectionMethod $method): Context
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
|
||||
return $this->createFromReflectionClass($class);
|
||||
}
|
||||
|
||||
private function createFromReflectionProperty(ReflectionProperty $property): Context
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
|
||||
return $this->createFromReflectionClass($class);
|
||||
}
|
||||
|
||||
private function createFromReflectionClassConstant(ReflectionClassConstant $constant): Context
|
||||
{
|
||||
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
|
||||
/** @phpstan-var ReflectionClass<object> $class */
|
||||
$class = $constant->getDeclaringClass();
|
||||
|
||||
return $this->createFromReflectionClass($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param ReflectionClass<object> $class
|
||||
*/
|
||||
private function createFromReflectionClass(ReflectionClass $class): Context
|
||||
{
|
||||
$fileName = $class->getFileName();
|
||||
$namespace = $class->getNamespaceName();
|
||||
|
||||
if (is_string($fileName) && file_exists($fileName)) {
|
||||
$contents = file_get_contents($fileName);
|
||||
if ($contents === false) {
|
||||
throw new RuntimeException('Unable to read file "' . $fileName . '"');
|
||||
}
|
||||
|
||||
return $this->createForNamespace($namespace, $contents);
|
||||
}
|
||||
|
||||
return new Context($namespace, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Context for a namespace in the provided file contents.
|
||||
*
|
||||
* @see Context for more information on Contexts.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public function createForNamespace(string $namespace, string $fileContents): Context
|
||||
{
|
||||
$namespace = trim($namespace, '\\');
|
||||
$useStatements = [];
|
||||
$currentNamespace = '';
|
||||
$tokens = new ArrayIterator(token_get_all($fileContents));
|
||||
|
||||
while ($tokens->valid()) {
|
||||
$currentToken = $tokens->current();
|
||||
switch ($currentToken[0]) {
|
||||
case T_NAMESPACE:
|
||||
$currentNamespace = $this->parseNamespace($tokens);
|
||||
break;
|
||||
case T_CLASS:
|
||||
case T_TRAIT:
|
||||
// Fast-forward the iterator through the class so that any
|
||||
// T_USE tokens found within are skipped - these are not
|
||||
// valid namespace use statements so should be ignored.
|
||||
$braceLevel = 0;
|
||||
$firstBraceFound = false;
|
||||
while ($tokens->valid() && ($braceLevel > 0 || !$firstBraceFound)) {
|
||||
$currentToken = $tokens->current();
|
||||
if (
|
||||
$currentToken === '{'
|
||||
|| in_array($currentToken[0], [T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES], true)
|
||||
) {
|
||||
if (!$firstBraceFound) {
|
||||
$firstBraceFound = true;
|
||||
}
|
||||
|
||||
++$braceLevel;
|
||||
}
|
||||
|
||||
if ($currentToken === '}') {
|
||||
--$braceLevel;
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
}
|
||||
|
||||
break;
|
||||
case T_USE:
|
||||
if ($currentNamespace === $namespace) {
|
||||
$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<int, string|array{0:int,1:string,2:int}> $tokens
|
||||
*/
|
||||
private function parseNamespace(ArrayIterator $tokens): string
|
||||
{
|
||||
// skip to the first string or namespace separator
|
||||
$this->skipToNextStringOrNamespaceSeparator($tokens);
|
||||
|
||||
$name = '';
|
||||
$acceptedTokens = [T_STRING, T_NS_SEPARATOR, T_NAME_QUALIFIED];
|
||||
while ($tokens->valid() && in_array($tokens->current()[0], $acceptedTokens, true)) {
|
||||
$name .= $tokens->current()[1];
|
||||
$tokens->next();
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deduce the names of all imports when we are at the T_USE token.
|
||||
*
|
||||
* @param ArrayIterator<int, string|array{0:int,1:string,2:int}> $tokens
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
private function parseUseStatement(ArrayIterator $tokens): array
|
||||
{
|
||||
$uses = [];
|
||||
|
||||
while ($tokens->valid()) {
|
||||
$this->skipToNextStringOrNamespaceSeparator($tokens);
|
||||
|
||||
$uses += $this->extractUseStatements($tokens);
|
||||
$currentToken = $tokens->current();
|
||||
if ($currentToken[0] === self::T_LITERAL_END_OF_USE) {
|
||||
return $uses;
|
||||
}
|
||||
}
|
||||
|
||||
return $uses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fast-forwards the iterator as longs as we don't encounter a T_STRING or T_NS_SEPARATOR token.
|
||||
*
|
||||
* @param ArrayIterator<int, string|array{0:int,1:string,2:int}> $tokens
|
||||
*/
|
||||
private function skipToNextStringOrNamespaceSeparator(ArrayIterator $tokens): void
|
||||
{
|
||||
while ($tokens->valid()) {
|
||||
$currentToken = $tokens->current();
|
||||
if (in_array($currentToken[0], [T_STRING, T_NS_SEPARATOR], true)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($currentToken[0] === T_NAME_QUALIFIED) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (defined('T_NAME_FULLY_QUALIFIED') && $currentToken[0] === T_NAME_FULLY_QUALIFIED) {
|
||||
break;
|
||||
}
|
||||
|
||||
$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. This will return a key/value array of the alias => namespace.
|
||||
*
|
||||
* @param ArrayIterator<int, string|array{0:int,1:string,2:int}> $tokens
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return array<string, string>
|
||||
*
|
||||
* @psalm-suppress TypeDoesNotContainType
|
||||
*/
|
||||
private function extractUseStatements(ArrayIterator $tokens): array
|
||||
{
|
||||
$extractedUseStatements = [];
|
||||
$groupedNs = '';
|
||||
$currentNs = '';
|
||||
$currentAlias = '';
|
||||
$state = 'start';
|
||||
|
||||
while ($tokens->valid()) {
|
||||
$currentToken = $tokens->current();
|
||||
$tokenId = is_string($currentToken) ? $currentToken : $currentToken[0];
|
||||
$tokenValue = is_string($currentToken) ? null : $currentToken[1];
|
||||
switch ($state) {
|
||||
case 'start':
|
||||
switch ($tokenId) {
|
||||
case T_STRING:
|
||||
case T_NS_SEPARATOR:
|
||||
$currentNs .= (string) $tokenValue;
|
||||
$currentAlias = $tokenValue;
|
||||
break;
|
||||
case T_NAME_QUALIFIED:
|
||||
case T_NAME_FULLY_QUALIFIED:
|
||||
$currentNs .= (string) $tokenValue;
|
||||
$currentAlias = substr(
|
||||
(string) $tokenValue,
|
||||
(int) (strrpos((string) $tokenValue, '\\')) + 1
|
||||
);
|
||||
break;
|
||||
case T_CURLY_OPEN:
|
||||
case '{':
|
||||
$state = 'grouped';
|
||||
$groupedNs = $currentNs;
|
||||
break;
|
||||
case T_AS:
|
||||
$state = 'start-alias';
|
||||
break;
|
||||
case self::T_LITERAL_USE_SEPARATOR:
|
||||
case self::T_LITERAL_END_OF_USE:
|
||||
$state = 'end';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'start-alias':
|
||||
switch ($tokenId) {
|
||||
case T_STRING:
|
||||
$currentAlias = $tokenValue;
|
||||
break;
|
||||
case self::T_LITERAL_USE_SEPARATOR:
|
||||
case self::T_LITERAL_END_OF_USE:
|
||||
$state = 'end';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'grouped':
|
||||
switch ($tokenId) {
|
||||
case T_STRING:
|
||||
case T_NS_SEPARATOR:
|
||||
$currentNs .= (string) $tokenValue;
|
||||
$currentAlias = $tokenValue;
|
||||
break;
|
||||
case T_AS:
|
||||
$state = 'grouped-alias';
|
||||
break;
|
||||
case self::T_LITERAL_USE_SEPARATOR:
|
||||
$state = 'grouped';
|
||||
$extractedUseStatements[(string) $currentAlias] = $currentNs;
|
||||
$currentNs = $groupedNs;
|
||||
$currentAlias = '';
|
||||
break;
|
||||
case self::T_LITERAL_END_OF_USE:
|
||||
$state = 'end';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'grouped-alias':
|
||||
switch ($tokenId) {
|
||||
case T_STRING:
|
||||
$currentAlias = $tokenValue;
|
||||
break;
|
||||
case self::T_LITERAL_USE_SEPARATOR:
|
||||
$state = 'grouped';
|
||||
$extractedUseStatements[(string) $currentAlias] = $currentNs;
|
||||
$currentNs = $groupedNs;
|
||||
$currentAlias = '';
|
||||
break;
|
||||
case self::T_LITERAL_END_OF_USE:
|
||||
$state = 'end';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($state === 'end') {
|
||||
break;
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
}
|
||||
|
||||
if ($groupedNs !== $currentNs) {
|
||||
$extractedUseStatements[(string) $currentAlias] = $currentNs;
|
||||
}
|
||||
|
||||
return $extractedUseStatements;
|
||||
}
|
||||
}
|
||||
@@ -35,10 +35,10 @@ class Description implements \Reflector
|
||||
/**
|
||||
* Populates the fields of a description.
|
||||
*
|
||||
* @param string $content The description's conetnts.
|
||||
* @param string $content The description's contents.
|
||||
* @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);
|
||||
}
|
||||
@@ -55,15 +55,15 @@ class Description implements \Reflector
|
||||
|
||||
/**
|
||||
* Sets the text of this description.
|
||||
*
|
||||
*
|
||||
* @param string $content The new text of this description.
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->contents = trim($content);
|
||||
|
||||
|
||||
$this->parsedContents = null;
|
||||
return $this;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class Description implements \Reflector
|
||||
)
|
||||
\}/Sux',
|
||||
$this->contents,
|
||||
null,
|
||||
-1,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
|
||||
@@ -140,7 +140,7 @@ class Description implements \Reflector
|
||||
*
|
||||
* @todo this should become a more intelligent piece of code where the
|
||||
* configuration contains a setting what format long descriptions are.
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore Will be removed soon, in favor of adapters at
|
||||
* PhpDocumentor itself that will process text in various formats.
|
||||
*
|
||||
@@ -161,7 +161,10 @@ class Description implements \Reflector
|
||||
);
|
||||
}
|
||||
|
||||
if (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
||||
if (class_exists('Parsedown')) {
|
||||
$markdown = \Parsedown::instance();
|
||||
$result = $markdown->parse($result);
|
||||
} elseif (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
||||
$markdown = new \dflydev\markdown\MarkdownExtraParser();
|
||||
$result = $markdown->transformMarkdown($result);
|
||||
}
|
||||
@@ -171,7 +174,7 @@ class Description implements \Reflector
|
||||
|
||||
/**
|
||||
* Gets the docblock this tag belongs to.
|
||||
*
|
||||
*
|
||||
* @return DocBlock The docblock this description belongs to.
|
||||
*/
|
||||
public function getDocBlock()
|
||||
@@ -181,13 +184,13 @@ class Description implements \Reflector
|
||||
|
||||
/**
|
||||
* Sets the docblock this tag belongs to.
|
||||
*
|
||||
*
|
||||
* @param DocBlock $docblock The new docblock this description belongs to.
|
||||
* Setting NULL removes any association.
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocBlock(DocBlock $docblock = null)
|
||||
public function setDocBlock(?DocBlock $docblock = null)
|
||||
{
|
||||
$this->docblock = $docblock;
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ class Serializer
|
||||
/** @var int|null The max length of a line. */
|
||||
protected $lineLength = null;
|
||||
|
||||
/** @var bool Separate tag groups. */
|
||||
protected $separateTags = false;
|
||||
|
||||
/**
|
||||
* Create a Serializer instance.
|
||||
*
|
||||
@@ -45,17 +48,20 @@ class Serializer
|
||||
* @param bool $indentFirstLine Whether to indent the first line.
|
||||
* @param int|null $lineLength The max length of a line or NULL to
|
||||
* disable line wrapping.
|
||||
* @param bool $separateTags Separate tag groups.
|
||||
*/
|
||||
public function __construct(
|
||||
$indent = 0,
|
||||
$indentString = ' ',
|
||||
$indentFirstLine = true,
|
||||
$lineLength = null
|
||||
$lineLength = null,
|
||||
$separateTags = false
|
||||
) {
|
||||
$this->setIndentationString($indentString);
|
||||
$this->setIndent($indent);
|
||||
$this->setIsFirstLineIndented($indentFirstLine);
|
||||
$this->setLineLength($lineLength);
|
||||
$this->setSeparateTags($separateTags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,6 +164,29 @@ class Serializer
|
||||
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.
|
||||
*
|
||||
@@ -180,8 +209,12 @@ class Serializer
|
||||
|
||||
$comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
|
||||
|
||||
$tags = array_values($docblock->getTags());
|
||||
|
||||
/** @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;
|
||||
if ($this->lineLength) {
|
||||
$tagText = wordwrap($tagText, $wrapLength);
|
||||
@@ -189,6 +222,10 @@ class Serializer
|
||||
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
||||
|
||||
$comment .= "{$indent} * {$tagText}\n";
|
||||
|
||||
if ($this->separateTags && $nextTag !== null && ! $tag->inSameGroup($nextTag)) {
|
||||
$comment .= "{$indent} *\n";
|
||||
}
|
||||
}
|
||||
|
||||
$comment .= $indent . ' */';
|
||||
|
||||
@@ -95,7 +95,11 @@ class Tag implements \Reflector
|
||||
'var'
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\VarTag',
|
||||
'version'
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag'
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag',
|
||||
'SuppressWarnings'
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag',
|
||||
'template'
|
||||
=> '\Barryvdh\Reflection\DocBlock\Tag\TemplateTag'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -111,8 +115,8 @@ class Tag implements \Reflector
|
||||
*/
|
||||
final public static function createInstance(
|
||||
$tag_line,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
?DocBlock $docblock = null,
|
||||
?Location $location = null
|
||||
) {
|
||||
if (!preg_match(
|
||||
'/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us',
|
||||
@@ -192,8 +196,8 @@ class Tag implements \Reflector
|
||||
public function __construct(
|
||||
$name,
|
||||
$content,
|
||||
DocBlock $docblock = null,
|
||||
Location $location = null
|
||||
?DocBlock $docblock = null,
|
||||
?Location $location = null
|
||||
) {
|
||||
$this
|
||||
->setName($name)
|
||||
@@ -321,7 +325,7 @@ class Tag implements \Reflector
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocBlock(DocBlock $docblock = null)
|
||||
public function setDocBlock(?DocBlock $docblock = null)
|
||||
{
|
||||
$this->docblock = $docblock;
|
||||
|
||||
@@ -345,13 +349,46 @@ class Tag implements \Reflector
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocation(Location $location = null)
|
||||
public function setLocation(?Location $location = null)
|
||||
{
|
||||
$this->location = $location;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the given tags should be together or apart.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function inSameGroup(Tag $tag)
|
||||
{
|
||||
$firstName = $this->getName();
|
||||
$secondName = $tag->getName();
|
||||
|
||||
if ($firstName === $secondName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$groups = array(
|
||||
array('deprecated', 'link', 'see', 'since'),
|
||||
array('author', 'copyright', 'license'),
|
||||
array('category', 'package', 'subpackage'),
|
||||
array('property', 'property-read', 'property-write'),
|
||||
array('param', 'return'),
|
||||
);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
if (in_array($firstName, $group, true) && in_array($secondName, $group, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a string representation of this object.
|
||||
*
|
||||
|
||||
@@ -56,7 +56,7 @@ class ExampleTag extends SourceTag
|
||||
$filePath = '"' . $this->filePath . '"';
|
||||
}
|
||||
|
||||
$this->content = $filePath . ' ' . $this->getContent();
|
||||
$this->content = $filePath . ' ' . parent::getContent();
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
|
||||
@@ -76,7 +76,17 @@ class MethodTag extends ReturnTag
|
||||
)?
|
||||
# Return type
|
||||
(?:
|
||||
([\w\|_\\\\]+)
|
||||
(
|
||||
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
||||
|
|
||||
(?:
|
||||
(?:[\w\|_\\\\]+(?:<[\s\S]*>)?)
|
||||
# array notation
|
||||
(?:\[\])*
|
||||
)*
|
||||
|
|
||||
(?:\([\s\S]*\))?
|
||||
)
|
||||
\s+
|
||||
)?
|
||||
# Legacy method name (not captured)
|
||||
@@ -114,9 +124,6 @@ class MethodTag extends ReturnTag
|
||||
}
|
||||
}
|
||||
$this->parsedDescription = null;
|
||||
} else {
|
||||
echo date('c') . ' ERR (3): @method contained invalid contents: '
|
||||
. $this->content . PHP_EOL;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -23,11 +23,12 @@ use Barryvdh\Reflection\DocBlock\Tag;
|
||||
*/
|
||||
class ParamTag extends ReturnTag
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $variableName = '';
|
||||
|
||||
/** @var bool determines whether this is a variadic argument */
|
||||
protected $isVariadic = false;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -45,12 +46,36 @@ class ParamTag extends ReturnTag
|
||||
public function setContent($content)
|
||||
{
|
||||
Tag::setContent($content);
|
||||
$parts = preg_split(
|
||||
'/(\s+)/Su',
|
||||
$this->description,
|
||||
3,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
|
||||
$parts = [];
|
||||
$rest = $this->description;
|
||||
|
||||
// parsing generics and closures to detect types
|
||||
for($pos = 0, $stacks = []; $pos < strlen($rest); $pos++) {
|
||||
$char = $rest[$pos];
|
||||
|
||||
if(in_array($char, ['<', '(', '[', '{'])) {
|
||||
array_unshift($stacks, $char);
|
||||
}
|
||||
if(
|
||||
($char === '>' && isset($stacks[0]) && $stacks[0] === '<')
|
||||
|| ($char === ')' && isset($stacks[0]) && $stacks[0] === '(')
|
||||
|| ($char === ']' && isset($stacks[0]) && $stacks[0] === '[')
|
||||
|| ($char === '}' && isset($stacks[0]) && $stacks[0] === '{')
|
||||
) {
|
||||
array_shift($stacks);
|
||||
}
|
||||
|
||||
if(!$stacks && preg_match('/\A(\s+)(.*)/su', substr($rest, $pos), $matches)) {
|
||||
$parts[0] = substr($rest, 0, $pos);
|
||||
$parts[1] = $matches[1];
|
||||
$rest = $matches[2];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
array_push($parts, ...preg_split('/(\s+)/u', $rest, 2, PREG_SPLIT_DELIM_CAPTURE));
|
||||
|
||||
// if the first item that is encountered is not a variable; it is a type
|
||||
if (isset($parts[0])
|
||||
@@ -61,13 +86,18 @@ class ParamTag extends ReturnTag
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
// if the next item starts with a $ it must be the variable name
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0])
|
||||
&& (strlen($parts[0]) > 0)
|
||||
&& ($parts[0][0] == '$')
|
||||
&& ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')
|
||||
) {
|
||||
$this->variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
|
||||
if (substr($this->variableName, 0, 3) === '...') {
|
||||
$this->isVariadic = true;
|
||||
$this->variableName = substr($this->variableName, 3);
|
||||
}
|
||||
}
|
||||
|
||||
$this->setDescription(implode('', $parts));
|
||||
@@ -100,4 +130,14 @@ class ParamTag extends ReturnTag
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this tag is variadic.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVariadic()
|
||||
{
|
||||
return $this->isVariadic;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class ReturnTag extends Tag
|
||||
{
|
||||
/** @var string The raw type component. */
|
||||
protected $type = '';
|
||||
|
||||
|
||||
/** @var Collection The parsed type component. */
|
||||
protected $types = null;
|
||||
|
||||
@@ -36,7 +36,7 @@ class ReturnTag extends Tag
|
||||
public function getContent()
|
||||
{
|
||||
if (null === $this->content) {
|
||||
$this->content = "{$this->type} {$this->description}";
|
||||
$this->content = "{$this->getType()} {$this->description}";
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
@@ -49,7 +49,7 @@ class ReturnTag extends Tag
|
||||
{
|
||||
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
|
||||
$this->type = $parts[0];
|
||||
@@ -81,9 +81,38 @@ class ReturnTag extends Tag
|
||||
return (string) $this->getTypesCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type section of the variable
|
||||
*
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->types = null;
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a type to the type section of the variable
|
||||
*
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function addType($type)
|
||||
{
|
||||
$this->type = $this->type . Collection::OPERATOR_OR . $type;
|
||||
$this->types = null;
|
||||
$this->content = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type collection.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getTypesCollection()
|
||||
@@ -91,7 +120,8 @@ class ReturnTag extends Tag
|
||||
if (null === $this->types) {
|
||||
$this->types = new Collection(
|
||||
array($this->type),
|
||||
$this->docblock ? $this->docblock->getContext() : null
|
||||
$this->docblock ? $this->docblock->getContext() : null,
|
||||
$this->docblock ? $this->docblock->getGenerics() : array()
|
||||
);
|
||||
}
|
||||
return $this->types;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,14 @@ class Collection extends \ArrayObject
|
||||
protected static $keywords = array(
|
||||
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
|
||||
'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;
|
||||
|
||||
/**
|
||||
* List of generics types
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $generics = array();
|
||||
|
||||
/**
|
||||
* Registers the namespace and aliases; uses that to add and expand the
|
||||
* given types.
|
||||
@@ -60,9 +74,11 @@ class Collection extends \ArrayObject
|
||||
*/
|
||||
public function __construct(
|
||||
array $types = array(),
|
||||
Context $context = null
|
||||
?Context $context = null,
|
||||
array $generics = array()
|
||||
) {
|
||||
$this->context = null === $context ? new Context() : $context;
|
||||
$this->generics = array_merge($this->context->getGenerics(), $generics);
|
||||
|
||||
foreach ($types as $type) {
|
||||
$this->add($type);
|
||||
@@ -106,7 +122,7 @@ class Collection extends \ArrayObject
|
||||
}
|
||||
|
||||
// separate the type by the OR operator
|
||||
$type_parts = explode(self::OPERATOR_OR, $type);
|
||||
$type_parts = $this->explode($type);
|
||||
foreach ($type_parts as $part) {
|
||||
$expanded_type = $this->expand($part);
|
||||
if ($expanded_type) {
|
||||
@@ -114,10 +130,10 @@ class Collection extends \ArrayObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representation of the collection.
|
||||
*
|
||||
*
|
||||
* @return string The resolved types across the collection, separated with
|
||||
* {@link self::OPERATOR_OR}.
|
||||
*/
|
||||
@@ -126,6 +142,40 @@ class Collection extends \ArrayObject
|
||||
return implode(self::OPERATOR_OR, $this->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the given union of types and returns separated by OR operator
|
||||
* single types.
|
||||
*
|
||||
* @param string $type The type or union of types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function explode($type)
|
||||
{
|
||||
$type_parts = [];
|
||||
$curr_type = '';
|
||||
$nest_level = 0;
|
||||
|
||||
foreach (str_split($type) as $char) {
|
||||
if ($char === self::OPERATOR_OR && $nest_level === 0) {
|
||||
$type_parts[] = $curr_type;
|
||||
$curr_type = '';
|
||||
} else {
|
||||
if (in_array($char, ['<', '(', '[', '{'])) {
|
||||
$nest_level++;
|
||||
} else if (in_array($char, ['>', ')', ']', '}'])) {
|
||||
$nest_level--;
|
||||
}
|
||||
|
||||
$curr_type .= $char;
|
||||
}
|
||||
}
|
||||
|
||||
$type_parts[] = $curr_type;
|
||||
|
||||
return $type_parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the given type and returns the FQCN variant.
|
||||
*
|
||||
@@ -151,17 +201,42 @@ class Collection extends \ArrayObject
|
||||
return '';
|
||||
}
|
||||
|
||||
// Check for generics values and array shapes
|
||||
if (preg_match('/^[\w-]+(<.+>|\[.+\]|{.+})$/', $type)) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
// Check for callable types
|
||||
if (preg_match('/\(.*?(?=\:)/', $type)) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
if($type[0] === '(') {
|
||||
return $type;
|
||||
}
|
||||
|
||||
// Literal strings
|
||||
if ($type[0] === '"' || $type[0] === "'") {
|
||||
return $type;
|
||||
}
|
||||
|
||||
if ($this->isTypeAnArray($type)) {
|
||||
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);
|
||||
|
||||
$namespace_aliases = $this->context->getNamespaceAliases();
|
||||
// if the first segment is not an alias; prepend namespace name and
|
||||
// return
|
||||
if (!isset($namespace_aliases[$type_parts[0]])) {
|
||||
if (!isset($namespace_aliases[$type_parts[0]]) &&
|
||||
!isset($namespace_aliases[strstr($type_parts[0], '::', true)])) {
|
||||
$namespace = $this->context->getNamespace();
|
||||
if ('' !== $namespace) {
|
||||
$namespace .= self::OPERATOR_NAMESPACE;
|
||||
@@ -169,6 +244,12 @@ class Collection extends \ArrayObject
|
||||
return self::OPERATOR_NAMESPACE . $namespace . $type;
|
||||
}
|
||||
|
||||
if (strpos($type_parts[0], '::')) {
|
||||
$type_parts[] = strstr($type_parts[0], '::');
|
||||
$type_parts[0] = $namespace_aliases[strstr($type_parts[0], '::', true)];
|
||||
return implode('', $type_parts);
|
||||
}
|
||||
|
||||
$type_parts[0] = $namespace_aliases[$type_parts[0]];
|
||||
$type = implode(self::OPERATOR_NAMESPACE, $type_parts);
|
||||
}
|
||||
@@ -218,4 +299,29 @@ class Collection extends \ArrayObject
|
||||
return ($type[0] !== self::OPERATOR_NAMESPACE)
|
||||
|| $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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
// Added imports on purpose as mock for the unit tests, please do not remove.
|
||||
use Barryvdh\Reflection\DocBlock\Tag as m, Barryvdh;
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
// yes, the slash is part of the test
|
||||
use PHPUnit\Framework\{
|
||||
Assert,
|
||||
Exception as e
|
||||
};
|
||||
use \ReflectionClass;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\Types\ContextFactory
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class ContextFactoryTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::createFromReflector
|
||||
* @covers ::createForNamespace
|
||||
* @uses Barryvdh\Reflection\DocBlock\Context
|
||||
*/
|
||||
public function testReadsNamespaceFromClassReflection(): void
|
||||
{
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createFromReflector(new ReflectionClass($this));
|
||||
|
||||
$this->assertSame(__NAMESPACE__, $context->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createFromReflector
|
||||
* @covers ::createForNamespace
|
||||
* @uses Barryvdh\Reflection\DocBlock\Context
|
||||
*/
|
||||
public function testReadsAliasesFromClassReflection(): void
|
||||
{
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createFromReflector(new ReflectionClass($this));
|
||||
|
||||
$this->assertNamespaceAliasesFrom($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createForNamespace
|
||||
* @uses Barryvdh\Reflection\DocBlock\Context
|
||||
*/
|
||||
public function testReadsNamespaceFromProvidedNamespaceAndContent(): void
|
||||
{
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createForNamespace(__NAMESPACE__, file_get_contents(__FILE__));
|
||||
|
||||
$this->assertSame(__NAMESPACE__, $context->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createForNamespace
|
||||
* @uses Barryvdh\Reflection\DocBlock\Context
|
||||
*/
|
||||
public function testReadsAliasesFromProvidedNamespaceAndContent(): void
|
||||
{
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createForNamespace(__NAMESPACE__, file_get_contents(__FILE__));
|
||||
|
||||
$this->assertNamespaceAliasesFrom($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createForNamespace
|
||||
* @uses Barryvdh\Reflection\DocBlock\Context
|
||||
*/
|
||||
public function testTraitUseIsNotDetectedAsNamespaceUse(): void
|
||||
{
|
||||
$php = '<?php declare(strict_types=1);
|
||||
namespace Foo;
|
||||
|
||||
trait FooTrait {}
|
||||
|
||||
class FooClass {
|
||||
use FooTrait;
|
||||
}
|
||||
';
|
||||
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createForNamespace('Foo', $php);
|
||||
|
||||
$this->assertSame([], $context->getNamespaceAliases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createForNamespace
|
||||
* @uses Barryvdh\Reflection\DocBlock\Context
|
||||
*/
|
||||
public function testAllOpeningBracesAreCheckedWhenSearchingForEndOfClass(): void
|
||||
{
|
||||
$php = '<?php declare(strict_types=1);
|
||||
namespace Foo;
|
||||
|
||||
trait FooTrait {}
|
||||
trait BarTrait {}
|
||||
|
||||
class FooClass {
|
||||
use FooTrait;
|
||||
|
||||
public function bar()
|
||||
{
|
||||
echo "{$baz}";
|
||||
echo "${baz}";
|
||||
}
|
||||
}
|
||||
|
||||
class BarClass {
|
||||
use BarTrait;
|
||||
|
||||
public function bar()
|
||||
{
|
||||
echo "{$baz}";
|
||||
echo "${baz}";
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createForNamespace('Foo', $php);
|
||||
|
||||
$this->assertSame([], $context->getNamespaceAliases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createForNamespace
|
||||
* @uses Barryvdh\Reflection\DocBlock\Context
|
||||
*/
|
||||
public function testTraitContainsClosureWithUseStatement(): void
|
||||
{
|
||||
$php = '<?php declare(strict_types=1);
|
||||
namespace Foo;
|
||||
|
||||
trait FooTrait {
|
||||
protected function check(array $data, string $key) : void
|
||||
{
|
||||
array_walk($data, function(&$item) use ($key) {
|
||||
// update item based on the key
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class FooClass {
|
||||
use FooTrait;
|
||||
}
|
||||
';
|
||||
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createForNamespace('Foo', $php);
|
||||
|
||||
$this->assertSame([], $context->getNamespaceAliases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createFromReflector
|
||||
*/
|
||||
public function testEmptyFileName(): void
|
||||
{
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createFromReflector(new ReflectionClass(stdClass::class));
|
||||
|
||||
$this->assertSame([], $context->getNamespaceAliases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createFromReflector
|
||||
*/
|
||||
public function testEvalDClass(): void
|
||||
{
|
||||
eval(
|
||||
<<<PHP
|
||||
namespace Foo;
|
||||
|
||||
class Bar
|
||||
{
|
||||
}
|
||||
PHP
|
||||
);
|
||||
$fixture = new ContextFactory();
|
||||
$context = $fixture->createFromReflector(new ReflectionClass('Foo\Bar'));
|
||||
|
||||
$this->assertSame([], $context->getNamespaceAliases());
|
||||
}
|
||||
|
||||
public function assertNamespaceAliasesFrom(Context $context)
|
||||
{
|
||||
$expected = [
|
||||
'm' => '\\' . m::class,
|
||||
'DocBlock' => '\\' . DocBlock::class,
|
||||
'Tag' => '\\' . Tag::class,
|
||||
'Barryvdh' => '\\' . 'Barryvdh',
|
||||
'TestCase' => '\\' . TestCase::class,
|
||||
'Assert' => '\\' . Assert::class,
|
||||
'e' => '\\' . e::class,
|
||||
ReflectionClass::class => '\\' . ReflectionClass::class,
|
||||
\stdClass::class => '\\' . \stdClass::class,
|
||||
];
|
||||
|
||||
$actual = $context->getNamespaceAliases();
|
||||
|
||||
// sort so that order differences don't break it
|
||||
asort($expected);
|
||||
asort($actual);
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -10,17 +10,19 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Description
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Description
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
||||
class DescriptionTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
@@ -106,7 +108,7 @@ LONGDESC;
|
||||
|
||||
$parsedDescription = $parsedContents[1]->getParsedDescription();
|
||||
$this->assertCount(3, $parsedDescription);
|
||||
$this->assertSame("inline tag with\n", $parsedDescription[0]);
|
||||
$this->assertSame("inline tag with", trim($parsedDescription[0]));
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag\LinkTag',
|
||||
$parsedDescription[1]
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\CoversTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
class CoversTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\CoversTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\CoversTag can create
|
||||
* a link for the covers doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -31,7 +33,7 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\CoversTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DeprecatedTagTest extends \PHPUnit_Framework_TestCase
|
||||
class DeprecatedTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @deprecated doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class DeprecatedTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\ExampleTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ExampleTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ExampleTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
|
||||
* understand the @source DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -33,7 +35,7 @@ class ExampleTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exLineCount
|
||||
* @param string $exFilepath
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ExampleTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\LinkTag
|
||||
*
|
||||
* @author Ben Selby <benmatselby@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
class LinkTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @link doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exLink
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\LinkTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+30
-9
@@ -10,17 +10,19 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\MethodTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
class MethodTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $signature The signature to test.
|
||||
@@ -34,7 +36,7 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $description The short description mentioned in the
|
||||
* signature.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\MethodTag
|
||||
* @dataProvider getTestSignatures
|
||||
*
|
||||
* @return void
|
||||
@@ -72,10 +74,11 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
public function getTestSignatures()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'foo',
|
||||
false, 'foo', '', false, 0, ''
|
||||
),
|
||||
// TODO: Verify this case
|
||||
// array(
|
||||
// 'foo',
|
||||
// false, 'foo', '', false, 0, ''
|
||||
// ),
|
||||
array(
|
||||
'foo()',
|
||||
true, 'foo', 'void', false, 0, ''
|
||||
@@ -139,7 +142,25 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
array(
|
||||
'static static foo()',
|
||||
true, 'foo', 'static', true, 0, ''
|
||||
)
|
||||
),
|
||||
|
||||
// generic array
|
||||
array(
|
||||
'array<int, string> foo()',
|
||||
true, 'foo', 'array<int, string>', false, 0, ''
|
||||
),
|
||||
|
||||
// nested generics
|
||||
array(
|
||||
'array<int, array<string, mixed>> foo()',
|
||||
true, 'foo', 'array<int, array<string, mixed>>', false, 0, ''
|
||||
),
|
||||
|
||||
// closure
|
||||
array(
|
||||
'(\Closure(int, string): bool) foo()',
|
||||
true, 'foo', '(\Closure(int, string): bool)', false, 0, ''
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Param tag 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\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ParamTag
|
||||
*
|
||||
* @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 ParamTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ParamTag can
|
||||
* understand the @param DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedVarName
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ParamTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedVarName,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ParamTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedVarName, $tag->getVariableName());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParsesInputsIntoCorrectFields()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('param', 'int', 'int', array('int'), '', ''),
|
||||
array('param', '$bob', '', array(), '$bob', ''),
|
||||
array(
|
||||
'param',
|
||||
'int Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'int $bob',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'int $bob Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int Description \n on multiple lines",
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
"Description \n on multiple lines"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int \n\$bob Variable name on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Variable name on a new line"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"\nint \$bob Type on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Type on a new line"
|
||||
),
|
||||
|
||||
// generic array
|
||||
array(
|
||||
'param',
|
||||
'array<int, string> $names',
|
||||
'array<int, string>',
|
||||
array('array<int, string>'),
|
||||
'$names',
|
||||
''
|
||||
),
|
||||
|
||||
// nested generics
|
||||
array(
|
||||
'param',
|
||||
'array<int, array<string, mixed>> $arrays',
|
||||
'array<int, array<string, mixed>>',
|
||||
array('array<int, array<string, mixed>>'),
|
||||
'$arrays',
|
||||
''
|
||||
),
|
||||
|
||||
// closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(int, string): bool) $callback',
|
||||
'(\Closure(int, string): bool)',
|
||||
array('(\Closure(int, string): bool)'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// generic array in closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(array<int, string>): bool) $callback',
|
||||
'(\Closure(array<int, string>): bool)',
|
||||
array('(\Closure(array<int, string>): bool)'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// union types in closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(int|string): bool)|bool $callback',
|
||||
'(\Closure(int|string): bool)|bool',
|
||||
array('(\Closure(int|string): bool)', 'bool'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// example from Laravel Framework - Eloquent Builder)
|
||||
array(
|
||||
'param',
|
||||
'array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>|string $relations',
|
||||
'array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>|string',
|
||||
array('array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>', 'string'),
|
||||
'$relations',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string|null $callback',
|
||||
'(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string|null',
|
||||
array('(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)', 'string', 'null'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// array shapes
|
||||
array(
|
||||
'param',
|
||||
'array{foo: string, bar: int} $array',
|
||||
'array{foo: string, bar: int}',
|
||||
array('array{foo: string, bar: int}'),
|
||||
'$array',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'MyArray[\'key\'] $value',
|
||||
'MyArray[\'key\']',
|
||||
array('MyArray[\'key\']'),
|
||||
'$value',
|
||||
''
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
+36
-6
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Return tag test.
|
||||
*
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ReturnTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ReturnTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ReturnTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ReturnTag can
|
||||
* understand the @return DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ReturnTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
@@ -96,6 +98,34 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string> Types of Bobs',
|
||||
'array<int, string>',
|
||||
array('array<int, string>'),
|
||||
'Types of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string>|string Types of Bobs',
|
||||
'array<int, string>|string',
|
||||
array('array<int, string>', 'string'),
|
||||
'Types of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string|bool>|string Types of Bobs',
|
||||
'array<int, string|bool>|string',
|
||||
array('array<int, string|bool>', 'string'),
|
||||
'Types of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'MyArray[\'key\'] Type of Bobs',
|
||||
'MyArray[\'key\']',
|
||||
array('MyArray[\'key\']'),
|
||||
'Type of Bobs'
|
||||
)
|
||||
);
|
||||
}
|
||||
+6
-4
@@ -10,17 +10,19 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SeeTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
class SeeTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
||||
@@ -31,7 +33,7 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SinceTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SinceTagTest extends \PHPUnit_Framework_TestCase
|
||||
class SinceTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @since doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class SinceTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SinceTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SourceTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SourceTagTest extends \PHPUnit_Framework_TestCase
|
||||
class SourceTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
|
||||
* understand the @source DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class SourceTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exStartingLine
|
||||
* @param string $exLineCount
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SourceTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor SuppressWarnings Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Andrew Smith <[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
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ThrowsTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ThrowsTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ThrowsTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag can
|
||||
* understand the @throws DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
+8
-5
@@ -10,20 +10,23 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\UsesTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
class UsesTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\UsesTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\UsesTag can create
|
||||
* a link for the @uses doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -31,7 +34,7 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\UsesTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+8
-5
@@ -10,20 +10,23 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
class VarTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\VarTag can
|
||||
* understand the @var doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +35,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exVariable
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+7
-5
@@ -10,20 +10,22 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VersionTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VersionTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VersionTagTest extends \PHPUnit_Framework_TestCase
|
||||
class VersionTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @version doc block.
|
||||
*
|
||||
* @param string $type
|
||||
@@ -32,7 +34,7 @@ class VersionTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VersionTag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\VersionTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
+20
-19
@@ -10,34 +10,35 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class TagTest extends \PHPUnit_Framework_TestCase
|
||||
class TagTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagLine()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
Tag::createInstance('Invalid tag line');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -70,13 +71,13 @@ class TagTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagHandlerCorrectRegistration()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
if (!ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
}
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
@@ -93,7 +94,7 @@ class TagTest extends \PHPUnit_Framework_TestCase
|
||||
include 'data:text/plain;base64,'. base64_encode(
|
||||
<<<TAG_HANDLER
|
||||
<?php
|
||||
class MyTagHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
||||
class MyTagHandler extends \Barryvdh\Reflection\DocBlock\Tag {}
|
||||
TAG_HANDLER
|
||||
);
|
||||
|
||||
@@ -118,8 +119,8 @@ TAG_HANDLER
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::createInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -162,8 +163,8 @@ TAG_HANDLER
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::createInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -201,7 +202,7 @@ TAG_HANDLER
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -232,7 +233,7 @@ TAG_HANDLER
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -265,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.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -0,0 +1,374 @@
|
||||
<?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(
|
||||
'array{ 0: string, 1: string|int }',
|
||||
array('array{ 0: string, 1: string|int }')
|
||||
),
|
||||
array(
|
||||
"array{ 'key': string, 'value': string|int }",
|
||||
array("array{ 'key': string, 'value': string|int }")
|
||||
),
|
||||
array(
|
||||
"MyArray['bar']",
|
||||
array("MyArray['bar']")
|
||||
),
|
||||
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>')
|
||||
),
|
||||
array(
|
||||
'callable',
|
||||
array('callable')
|
||||
),
|
||||
array(
|
||||
'callable(int, string): int',
|
||||
array('callable(int, string): int')
|
||||
),
|
||||
array(
|
||||
"'text'",
|
||||
array("'text'")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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')),
|
||||
);
|
||||
}
|
||||
}
|
||||
+80
-21
@@ -10,23 +10,25 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
namespace Barryvdh\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use phpDocumentor\Reflection\DocBlock\Location;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock\Location;
|
||||
use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for phpDocumentor\Reflection\DocBlock
|
||||
* Test class for Barryvdh\Reflection\DocBlock
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
class DocBlockTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock
|
||||
* @covers \Barryvdh\Reflection\DocBlock
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -69,8 +71,8 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::splitDocBlock
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock::splitDocBlock
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithTagsOnly()
|
||||
@@ -91,7 +93,42 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::cleanInput
|
||||
* @covers \Barryvdh\Reflection\DocBlock::isTemplateStart
|
||||
*/
|
||||
public function testIfStartOfTemplateIsDiscovered()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**#@+
|
||||
* @see \MyClass
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(2, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
$this->assertTrue($object->hasTag('return'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
$this->assertTrue($object->isTemplateStart());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Barryvdh\Reflection\DocBlock::isTemplateEnd
|
||||
*/
|
||||
public function testIfEndOfTemplateIsDiscovered()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**#@-*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertTrue($object->isTemplateEnd());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Barryvdh\Reflection\DocBlock::cleanInput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -108,7 +145,7 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::__construct
|
||||
* @covers \Barryvdh\Reflection\DocBlock::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -116,7 +153,7 @@ DOCBLOCK;
|
||||
{
|
||||
$object = new DocBlock(new \ReflectionClass($this));
|
||||
$this->assertEquals(
|
||||
'Test class for phpDocumentor\Reflection\DocBlock',
|
||||
'Test class for Barryvdh\Reflection\DocBlock',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
@@ -129,12 +166,12 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionOnInvalidObject()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new DocBlock($this);
|
||||
}
|
||||
|
||||
@@ -160,21 +197,22 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||
* @expectedException \LogicException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagBlock()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
if (!ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
return;
|
||||
}
|
||||
|
||||
include 'data:text/plain;base64,'. base64_encode(
|
||||
<<<DOCBLOCK_EXTENSION
|
||||
<?php
|
||||
class MyReflectionDocBlock extends \phpDocumentor\Reflection\DocBlock {
|
||||
class MyReflectionDocBlock extends \Barryvdh\Reflection\DocBlock {
|
||||
protected function splitDocBlock(\$comment) {
|
||||
return array('', '', 'Invalid tag block');
|
||||
}
|
||||
@@ -226,7 +264,7 @@ DOCBLOCK;
|
||||
|
||||
/**
|
||||
* @depends testConstructFromReflector
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
* @covers \Barryvdh\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -239,7 +277,7 @@ DOCBLOCK;
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -257,7 +295,7 @@ DOCBLOCK;
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @covers \Barryvdh\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -272,12 +310,15 @@ DOCBLOCK;
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertCount(1, $object->getTags());
|
||||
$this->assertCount(1, $tags = $object->getTags());
|
||||
/** @var ReturnTag $tag */
|
||||
$tag = reset($tags);
|
||||
$this->assertEquals("Content on\n multiple lines.\n\n One more, after the break.", $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
* @covers \Barryvdh\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -295,4 +336,22 @@ DOCBLOCK;
|
||||
$this->assertCount(1, $object->getTagsByName('return'));
|
||||
$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,118 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Param tag 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\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ParamTag
|
||||
*
|
||||
* @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 ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ParamTag can
|
||||
* understand the @param DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedVarName
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedVarName,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ParamTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedVarName, $tag->getVariableName());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParsesInputsIntoCorrectFields()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('param', 'int', 'int', array('int'), '', ''),
|
||||
array('param', '$bob', '', array(), '$bob', ''),
|
||||
array(
|
||||
'param',
|
||||
'int Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'int $bob',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'int $bob Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int Description \n on multiple lines",
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
"Description \n on multiple lines"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int \n\$bob Variable name on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Variable name on a new line"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"\nint \$bob Type on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Type on a new line"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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