mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -0,0 +1,10 @@
|
||||
# Path-based git attributes
|
||||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
|
||||
|
||||
# Ignore all test and documentation with "export-ignore".
|
||||
/.gitignore export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/composer.lock export-ignore
|
||||
/phpunit.xml.dist export-ignore
|
||||
/tests export-ignore
|
||||
@@ -0,0 +1,43 @@
|
||||
name: Unit Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
php-tests:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
env:
|
||||
COMPOSER_NO_INTERACTION: 1
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php: [8.4, 8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2]
|
||||
dependency-version: [prefer-lowest, prefer-stable]
|
||||
|
||||
name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
|
||||
|
||||
- name: Execute Unit Tests
|
||||
run: vendor/bin/phpunit
|
||||
@@ -1,2 +1,4 @@
|
||||
.idea
|
||||
.phpunit.result.cache
|
||||
composer.lock
|
||||
vendor
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
- hhvm-nightly
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: hhvm-nightly
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit
|
||||
|
||||
before_script:
|
||||
- sudo apt-get -qq update > /dev/null
|
||||
- phpenv rehash > /dev/null
|
||||
- composer selfupdate --quiet
|
||||
- composer install --no-interaction --prefer-source --dev
|
||||
- vendor/bin/phpunit
|
||||
- composer update --no-interaction --prefer-source --dev
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#phpdocumentor"
|
||||
email:
|
||||
- [email protected]
|
||||
- [email protected]
|
||||
- [email protected]
|
||||
@@ -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
|
||||
------------
|
||||
|
||||
|
||||
+3
-3
@@ -6,13 +6,13 @@
|
||||
{"name": "Mike van Riel", "email": "[email protected]"}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {"Barryvdh": ["src/"]}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0,<4.5"
|
||||
"phpunit/phpunit": "^8.5.14|^9"
|
||||
},
|
||||
"suggest": {
|
||||
"dflydev/markdown": "~1.0",
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
"dev-master": "2.3.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
-864
@@ -1,864 +0,0 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "deff4b2e029043b60cdbe896c5b18d6d",
|
||||
"content-hash": "7b23fd3607c50c95f9d65e81785cf289",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
"version": "1.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/instantiator.git",
|
||||
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
|
||||
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3,<8.0-DEV"
|
||||
},
|
||||
"require-dev": {
|
||||
"athletic/athletic": "~0.1.8",
|
||||
"ext-pdo": "*",
|
||||
"ext-phar": "*",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"squizlabs/php_codesniffer": "~2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marco Pivetta",
|
||||
"email": "[email protected]",
|
||||
"homepage": "http://ocramius.github.com/"
|
||||
}
|
||||
],
|
||||
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
|
||||
"homepage": "https://github.com/doctrine/instantiator",
|
||||
"keywords": [
|
||||
"constructor",
|
||||
"instantiate"
|
||||
],
|
||||
"time": "2015-06-14 21:17:01"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "2.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
|
||||
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-file-iterator": "~1.3",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-token-stream": "~1.3",
|
||||
"sebastian/environment": "^1.3.2",
|
||||
"sebastian/version": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-xdebug": ">=2.1.4",
|
||||
"phpunit/phpunit": "~4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-dom": "*",
|
||||
"ext-xdebug": ">=2.2.1",
|
||||
"ext-xmlwriter": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"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": [
|
||||
"coverage",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-10-06 15:47:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
"version": "1.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"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": "https://github.com/sebastianbergmann/php-file-iterator/",
|
||||
"keywords": [
|
||||
"filesystem",
|
||||
"iterator"
|
||||
],
|
||||
"time": "2013-10-10 15:34:57"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-text-template",
|
||||
"version": "1.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
||||
"reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
|
||||
"reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"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"
|
||||
],
|
||||
"time": "2015-06-21 13:50:34"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
"version": "1.0.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260",
|
||||
"reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4|~5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Utility class for timing",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-timer/",
|
||||
"keywords": [
|
||||
"timer"
|
||||
],
|
||||
"time": "2016-05-12 18:03:57"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-token-stream",
|
||||
"version": "1.4.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
||||
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
|
||||
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "Wrapper around PHP's tokenizer extension.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
|
||||
"keywords": [
|
||||
"tokenizer"
|
||||
],
|
||||
"time": "2015-09-15 10:49:45"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "4.4.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2e8580deebb7d1ac92ac878595e6bffe01069c2a",
|
||||
"reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-reflection": "*",
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-code-coverage": "~2.0",
|
||||
"phpunit/php-file-iterator": "~1.3.2",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-timer": "~1.0.2",
|
||||
"phpunit/phpunit-mock-objects": "~2.3",
|
||||
"sebastian/comparator": "~1.0",
|
||||
"sebastian/diff": "~1.1",
|
||||
"sebastian/environment": "~1.1",
|
||||
"sebastian/exporter": "~1.1",
|
||||
"sebastian/global-state": "~1.0",
|
||||
"sebastian/recursion-context": "~1.0",
|
||||
"sebastian/version": "~1.0",
|
||||
"symfony/yaml": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"phpunit/php-invoker": "~1.1"
|
||||
},
|
||||
"bin": [
|
||||
"phpunit"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.4.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "The PHP Unit Testing framework.",
|
||||
"homepage": "https://phpunit.de/",
|
||||
"keywords": [
|
||||
"phpunit",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-01-27 16:06:15"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "2.3.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
|
||||
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "^1.0.2",
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"sebastian/exporter": "~1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"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"
|
||||
],
|
||||
"time": "2015-10-02 06:51:40"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "937efb279bd37a375bcadf584dec0726f84dbf22"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22",
|
||||
"reference": "937efb279bd37a375bcadf584dec0726f84dbf22",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"sebastian/diff": "~1.2",
|
||||
"sebastian/exporter": "~1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to compare PHP values for equality",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/comparator",
|
||||
"keywords": [
|
||||
"comparator",
|
||||
"compare",
|
||||
"equality"
|
||||
],
|
||||
"time": "2015-07-26 15:48:44"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
"version": "1.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e",
|
||||
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kore Nordmann",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "Diff implementation",
|
||||
"homepage": "https://github.com/sebastianbergmann/diff",
|
||||
"keywords": [
|
||||
"diff"
|
||||
],
|
||||
"time": "2015-12-08 07:14:41"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/environment",
|
||||
"version": "1.3.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||
"reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4e8f0da10ac5802913afc151413bc8c53b6c2716",
|
||||
"reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality to handle HHVM/PHP environments",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/environment",
|
||||
"keywords": [
|
||||
"Xdebug",
|
||||
"environment",
|
||||
"hhvm"
|
||||
],
|
||||
"time": "2016-05-17 03:18:57"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/exporter",
|
||||
"version": "1.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||
"reference": "7ae5513327cb536431847bcc0c10edba2701064e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e",
|
||||
"reference": "7ae5513327cb536431847bcc0c10edba2701064e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"sebastian/recursion-context": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Adam Harvey",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to export PHP variables for visualization",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/exporter",
|
||||
"keywords": [
|
||||
"export",
|
||||
"exporter"
|
||||
],
|
||||
"time": "2015-06-21 07:55:53"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/global-state",
|
||||
"version": "1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/global-state.git",
|
||||
"reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4",
|
||||
"reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-uopz": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "Snapshotting of global state",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/global-state",
|
||||
"keywords": [
|
||||
"global state"
|
||||
],
|
||||
"time": "2015-10-12 03:26:01"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/recursion-context",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/recursion-context.git",
|
||||
"reference": "913401df809e99e4f47b27cdd781f4a258d58791"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791",
|
||||
"reference": "913401df809e99e4f47b27cdd781f4a258d58791",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Adam Harvey",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality to recursively process PHP variables",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
|
||||
"time": "2015-11-11 19:50:13"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
"version": "1.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/version.git",
|
||||
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
|
||||
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "[email protected]",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
||||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"time": "2015-06-21 13:59:46"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.8.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "815fabf3f48c7d1df345a69d1ad1a88f59757b34"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/815fabf3f48c7d1df345a69d1ad1a88f59757b34",
|
||||
"reference": "815fabf3f48c7d1df345a69d1ad1a88f59757b34",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.8-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-06-06 11:11:27"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"platform-dev": []
|
||||
}
|
||||
+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,6 +41,9 @@ 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;
|
||||
|
||||
@@ -71,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')) {
|
||||
@@ -238,7 +242,11 @@ class DocBlock implements \Reflector
|
||||
|
||||
// create proper Tag objects
|
||||
foreach ($result as $key => $tag_line) {
|
||||
$result[$key] = Tag::createInstance(trim($tag_line), $this);
|
||||
$tag = Tag::createInstance(trim($tag_line), $this);
|
||||
if ($tag instanceof TemplateTag) {
|
||||
$this->generics[] = $tag->getTemplateName();
|
||||
}
|
||||
$result[$key] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +465,16 @@ class DocBlock implements \Reflector
|
||||
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);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class Description implements \Reflector
|
||||
)
|
||||
\}/Sux',
|
||||
$this->contents,
|
||||
null,
|
||||
-1,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
|
||||
@@ -190,7 +190,7 @@ class Description implements \Reflector
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
|
||||
@@ -80,10 +80,12 @@ class MethodTag extends ReturnTag
|
||||
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
||||
|
|
||||
(?:
|
||||
(?:[\w\|_\\\\]+)
|
||||
(?:[\w\|_\\\\]+(?:<[\s\S]*>)?)
|
||||
# array notation
|
||||
(?:\[\])*
|
||||
)*
|
||||
|
|
||||
(?:\([\s\S]*\))?
|
||||
)
|
||||
\s+
|
||||
)?
|
||||
|
||||
@@ -46,12 +46,37 @@ 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($char === '<') {
|
||||
array_unshift($stacks, $char);
|
||||
}
|
||||
if($char === '(') {
|
||||
array_unshift($stacks, $char);
|
||||
}
|
||||
if($char === '>' && isset($stacks[0]) && $stacks[0] === '<') {
|
||||
array_shift($stacks);
|
||||
}
|
||||
if($char === ')' && isset($stacks[0]) && $stacks[0] === '(') {
|
||||
array_shift($stacks);
|
||||
}
|
||||
|
||||
if(!$stacks && preg_match('/\A(\s+)(.*)/su', substr($rest, $pos), $matches)) {
|
||||
$parts[0] = substr($rest, 0, $pos);
|
||||
$parts[1] = $matches[1];
|
||||
$rest = $matches[2];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
array_push($parts, ...preg_split('/(\s+)/u', $rest, 2, PREG_SPLIT_DELIM_CAPTURE));
|
||||
|
||||
// if the first item that is encountered is not a variable; it is a type
|
||||
if (isset($parts[0])
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
@@ -112,7 +112,7 @@ class ReturnTag extends Tag
|
||||
|
||||
/**
|
||||
* Returns the type collection.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getTypesCollection()
|
||||
@@ -120,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 ($char === '<' || $char === '(') {
|
||||
$nest_level++;
|
||||
} else if ($char === '>' || $char === ')') {
|
||||
$nest_level--;
|
||||
}
|
||||
|
||||
$curr_type .= $char;
|
||||
}
|
||||
}
|
||||
|
||||
$type_parts[] = $curr_type;
|
||||
|
||||
return $type_parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the given type and returns the FQCN variant.
|
||||
*
|
||||
@@ -151,11 +201,19 @@ class Collection extends \ArrayObject
|
||||
return '';
|
||||
}
|
||||
|
||||
if (preg_match('/^[\w-]+<.*>$/', $type)) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
if($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;
|
||||
@@ -231,6 +289,19 @@ class Collection extends \ArrayObject
|
||||
|| $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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Description
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock;
|
||||
* @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]
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\CoversTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\CoversTag can create
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\ExampleTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\LinkTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\MethodTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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.
|
||||
@@ -140,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, ''
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ParamTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
class ParamTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ParamTag can
|
||||
@@ -112,7 +114,75 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Type on a new line"
|
||||
)
|
||||
),
|
||||
|
||||
// generic array
|
||||
array(
|
||||
'param',
|
||||
'array<int, string> $names',
|
||||
'array<int, string>',
|
||||
array('array<int, string>'),
|
||||
'$names',
|
||||
''
|
||||
),
|
||||
|
||||
// nested generics
|
||||
array(
|
||||
'param',
|
||||
'array<int, array<string, mixed>> $arrays',
|
||||
'array<int, array<string, mixed>>',
|
||||
array('array<int, array<string, mixed>>'),
|
||||
'$arrays',
|
||||
''
|
||||
),
|
||||
|
||||
// closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(int, string): bool) $callback',
|
||||
'(\Closure(int, string): bool)',
|
||||
array('(\Closure(int, string): bool)'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// generic array in closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(array<int, string>): bool) $callback',
|
||||
'(\Closure(array<int, string>): bool)',
|
||||
array('(\Closure(array<int, string>): bool)'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// union types in closure
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(int|string): bool)|bool $callback',
|
||||
'(\Closure(int|string): bool)|bool',
|
||||
array('(\Closure(int|string): bool)', 'bool'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
|
||||
// example from Laravel Framework - Eloquent Builder)
|
||||
array(
|
||||
'param',
|
||||
'array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>|string $relations',
|
||||
'array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>|string',
|
||||
array('array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>', 'string'),
|
||||
'$relations',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string|null $callback',
|
||||
'(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string|null',
|
||||
array('(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)', 'string', 'null'),
|
||||
'$callback',
|
||||
''
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Return tag test.
|
||||
*
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ReturnTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\ReturnTag can
|
||||
@@ -96,6 +98,27 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string> Types of Bobs',
|
||||
'array<int, string>',
|
||||
array('array<int, string>'),
|
||||
'Types of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string>|string Types of Bobs',
|
||||
'array<int, string>|string',
|
||||
array('array<int, string>', 'string'),
|
||||
'Types of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'array<int, string|bool>|string Types of Bobs',
|
||||
'array<int, string|bool>|string',
|
||||
array('array<int, string|bool>', 'string'),
|
||||
'Types of Bobs'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SinceTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SourceTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
|
||||
|
||||
@@ -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',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\ThrowsTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag can
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\UsesTag
|
||||
*
|
||||
@@ -20,7 +23,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\UsesTag can create
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
@@ -20,7 +23,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\VarTag can
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VersionTag
|
||||
*
|
||||
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Barryvdh\Reflection\DocBlock;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
|
||||
@@ -23,16 +24,16 @@ use Barryvdh\Reflection\DocBlock\Context;
|
||||
* @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');
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ class TagTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
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';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Collection Test
|
||||
*
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
@@ -13,10 +13,11 @@
|
||||
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 <mike.vanriel@naenius.com>
|
||||
@@ -24,12 +25,12 @@ use Barryvdh\Reflection\DocBlock\Context;
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
class CollectionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::getContext
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct()
|
||||
@@ -42,7 +43,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithTypes()
|
||||
@@ -53,7 +54,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithNamespace()
|
||||
@@ -70,7 +71,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithNamespaceAliases()
|
||||
@@ -89,7 +90,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @dataProvider provideTypesToExpand
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAdd($fixture, $expected)
|
||||
@@ -109,7 +110,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithoutNamespace
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddWithoutNamespace($fixture, $expected)
|
||||
@@ -144,13 +145,34 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithGenerics
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
* @expectedException InvalidArgumentException
|
||||
*
|
||||
*
|
||||
* @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());
|
||||
}
|
||||
@@ -197,6 +219,26 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
'DocBlock[]|int[]',
|
||||
array($namespace.'DocBlock[]', 'int[]')
|
||||
),
|
||||
array(
|
||||
'array<string>',
|
||||
array('array<string>')
|
||||
),
|
||||
array(
|
||||
'array<int, string>',
|
||||
array('array<int, string>')
|
||||
),
|
||||
array(
|
||||
'array<int, string>|string',
|
||||
array('array<int, string>', 'string')
|
||||
),
|
||||
array(
|
||||
'array<int, float|bool>|string',
|
||||
array('array<int, float|bool>', 'string')
|
||||
),
|
||||
array(
|
||||
'array<int, string|array<int, bool>>|array<int, float>|string',
|
||||
array('array<int, string|array<int, bool>>', 'array<int, float>', 'string')
|
||||
),
|
||||
array(
|
||||
'LinkDescriptor::setLink()',
|
||||
array($namespace.'LinkDescriptor::setLink()')
|
||||
@@ -205,6 +247,42 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
'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>')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -250,4 +328,23 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Barryvdh\Reflection;
|
||||
use Barryvdh\Reflection\DocBlock\Context;
|
||||
use Barryvdh\Reflection\DocBlock\Location;
|
||||
use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for Barryvdh\Reflection\DocBlock
|
||||
@@ -24,7 +25,7 @@ use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
|
||||
* @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 \Barryvdh\Reflection\DocBlock
|
||||
@@ -165,12 +166,12 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionOnInvalidObject()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new DocBlock($this);
|
||||
}
|
||||
|
||||
@@ -203,8 +204,9 @@ DOCBLOCK;
|
||||
*/
|
||||
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(
|
||||
@@ -334,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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user