Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -1,4 +0,0 @@
composer.phar
vendor/
build/

View File

@@ -3,6 +3,7 @@ php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- nightly

View File

@@ -1 +1,2 @@
# ReflectionCommon
[![Build Status](https://travis-ci.org/phpDocumentor/ReflectionCommon.svg?branch=master)](https://travis-ci.org/phpDocumentor/ReflectionCommon)

View File

@@ -1,974 +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": "49ee00389e4ccd00d7e93a147103b2ab",
"packages": [],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.0.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
"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.*@ALPHA"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Instantiator\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"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": "2014-10-13 12:58:55"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8",
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"suggest": {
"dflydev/markdown": "~1.0",
"erusev/parsedown": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-0": {
"phpDocumentor": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "mike.vanriel@naenius.com"
}
],
"time": "2015-02-03 12:10:50"
},
{
"name": "phpspec/prophecy",
"version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373",
"reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"phpdocumentor/reflection-docblock": "~2.0",
"sebastian/comparator": "~1.1"
},
"require-dev": {
"phpspec/phpspec": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"autoload": {
"psr-0": {
"Prophecy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
},
{
"name": "Marcello Duarte",
"email": "marcello.duarte@gmail.com"
}
],
"description": "Highly opinionated mocking framework for PHP 5.3+",
"homepage": "https://github.com/phpspec/prophecy",
"keywords": [
"Double",
"Dummy",
"fake",
"mock",
"spy",
"stub"
],
"time": "2015-04-27 22:15:08"
},
{
"name": "phpunit/php-code-coverage",
"version": "2.1.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "6b7d2094ca2a685a2cad846cb7cd7a30e8b9470f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6b7d2094ca2a685a2cad846cb7cd7a30e8b9470f",
"reference": "6b7d2094ca2a685a2cad846cb7cd7a30e8b9470f",
"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.0",
"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.1.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"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-06-01 07:35:26"
},
{
"name": "phpunit/php-file-iterator",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "a923bb15680d0089e2316f7a4af8f437046e96bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb",
"reference": "a923bb15680d0089e2316f7a4af8f437046e96bb",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"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": "2015-04-02 05:19:05"
},
{
"name": "phpunit/php-text-template",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"Text/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Simple template engine.",
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
"keywords": [
"template"
],
"time": "2014-01-30 17:20:04"
},
{
"name": "phpunit/php-timer",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"PHP/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Utility class for timing",
"homepage": "https://github.com/sebastianbergmann/php-timer/",
"keywords": [
"timer"
],
"time": "2013-08-02 07:42:54"
},
{
"name": "phpunit/php-token-stream",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "eab81d02569310739373308137284e0158424330"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330",
"reference": "eab81d02569310739373308137284e0158424330",
"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": "sebastian@phpunit.de"
}
],
"description": "Wrapper around PHP's tokenizer extension.",
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
"keywords": [
"tokenizer"
],
"time": "2015-04-08 04:46:07"
},
{
"name": "phpunit/phpunit",
"version": "4.6.9",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "816d12536a7a032adc3b68737f82cfbbf98b79c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/816d12536a7a032adc3b68737f82cfbbf98b79c1",
"reference": "816d12536a7a032adc3b68737f82cfbbf98b79c1",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpspec/prophecy": "~1.3,>=1.3.1",
"phpunit/php-code-coverage": "~2.0,>=2.0.11",
"phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2",
"phpunit/php-timer": "~1.0",
"phpunit/phpunit-mock-objects": "~2.3",
"sebastian/comparator": "~1.1",
"sebastian/diff": "~1.2",
"sebastian/environment": "~1.2",
"sebastian/exporter": "~1.2",
"sebastian/global-state": "~1.0",
"sebastian/version": "~1.0",
"symfony/yaml": "~2.1|~3.0"
},
"suggest": {
"phpunit/php-invoker": "~1.1"
},
"bin": [
"phpunit"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.6.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "The PHP Unit Testing framework.",
"homepage": "https://phpunit.de/",
"keywords": [
"phpunit",
"testing",
"xunit"
],
"time": "2015-05-29 06:00:03"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "2.3.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7",
"reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7",
"shasum": ""
},
"require": {
"doctrine/instantiator": "~1.0,>=1.0.2",
"php": ">=5.3.3",
"phpunit/php-text-template": "~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": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Mock Object library for PHPUnit",
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
"keywords": [
"mock",
"xunit"
],
"time": "2015-05-29 05:19:18"
},
{
"name": "sebastian/comparator",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "1dd8869519a225f7f2b9eb663e225298fade819e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e",
"reference": "1dd8869519a225f7f2b9eb663e225298fade819e",
"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.1.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "http://www.github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
"equality"
],
"time": "2015-01-29 16:28:08"
},
{
"name": "sebastian/diff",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "863df9687835c62aa423a22412d26fa2ebde3fd3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3",
"reference": "863df9687835c62aa423a22412d26fa2ebde3fd3",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Diff implementation",
"homepage": "http://www.github.com/sebastianbergmann/diff",
"keywords": [
"diff"
],
"time": "2015-02-22 15:13:53"
},
{
"name": "sebastian/environment",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "5a8c7d31914337b69923db26c4221b81ff5a196e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e",
"reference": "5a8c7d31914337b69923db26c4221b81ff5a196e",
"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": "sebastian@phpunit.de"
}
],
"description": "Provides functionality to handle HHVM/PHP environments",
"homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [
"Xdebug",
"environment",
"hhvm"
],
"time": "2015-01-01 10:01:08"
},
{
"name": "sebastian/exporter",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "84839970d05254c73cde183a721c7af13aede943"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943",
"reference": "84839970d05254c73cde183a721c7af13aede943",
"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": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"time": "2015-01-27 07:23:06"
},
{
"name": "sebastian/global-state",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
"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": "sebastian@phpunit.de"
}
],
"description": "Snapshotting of global state",
"homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [
"global state"
],
"time": "2014-10-06 09:23:50"
},
{
"name": "sebastian/recursion-context",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "3989662bbb30a29d20d9faa04a846af79b276252"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252",
"reference": "3989662bbb30a29d20d9faa04a846af79b276252",
"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": "whatthejeff@gmail.com"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2015-01-24 09:48:32"
},
{
"name": "sebastian/version",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
"reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4",
"reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2015-02-24 06:35:25"
},
{
"name": "symfony/yaml",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3",
"reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:21:08"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="tests/common/bootstrap.php" colors="true">
<testsuites>
<testsuite name="phpDocumentor">
<directory>./tests/unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html"
title="phpDocumentor Reflection Common"
target="build/coverage"
charset="UTF-8"
yui="true"
highlight="false"
lowUpperBound="35"
highLowerBound="70" />
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false" />
</logging>
</phpunit>

View File

@@ -38,7 +38,11 @@ final class Fqsen
public function __construct($fqsen)
{
$matches = array();
$result = preg_match('/^\\\\([\\w_\\\\]*)(?:[:]{2}\\$?([\\w_]+))?(?:\\(\\))?$/', $fqsen, $matches);
$result = preg_match(
'/^\\\\([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff\\\\]*)?(?:[:]{2}\\$?([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*))?(?:\\(\\))?$/',
$fqsen,
$matches
);
if ($result === 0) {
throw new \InvalidArgumentException(

View File

@@ -1,10 +0,0 @@
<?php
/**
* phpDocumentor
*
* PHP Version 5.4
*
* @copyright 2010-2014 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

View File

@@ -1,88 +0,0 @@
<?php
/**
* phpDocumentor
*
* PHP Version 5.5
*
* @copyright 2010-2015 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
/**
* Class FqsenTest
* @coversDefaultClass phpDocumentor\Reflection\Fqsen
*/
class FqsenTest extends \PHPUnit_Framework_TestCase
{
/**
* @param string $fqsen
* @covers ::__construct
* @dataProvider validFqsenProvider
*/
public function testValidFormats($fqsen, $name)
{
$instance = new Fqsen($fqsen);
$this->assertEquals($name, $instance->getName());
}
/**
* Data provider for ValidFormats tests. Contains a complete list from psr-5 draft.
*
* @return array
*/
public function validFqsenProvider()
{
return [
['\\', ''],
['\My\Space', 'Space'],
['\My\Space\myFunction()', 'myFunction'],
['\My\Space\MY_CONSTANT', 'MY_CONSTANT'],
['\My\Space\MY_CONSTANT2', 'MY_CONSTANT2'],
['\My\Space\MyClass', 'MyClass'],
['\My\Space\MyInterface', 'MyInterface'],
['\My\Space\MyTrait', 'MyTrait'],
['\My\Space\MyClass::myMethod()', 'myMethod'],
['\My\Space\MyClass::$my_property', 'my_property'],
['\My\Space\MyClass::MY_CONSTANT', 'MY_CONSTANT'],
];
}
/**
* @param string $fqsen
* @covers ::__construct
* @dataProvider invalidFqsenProvider
* @expectedException \InvalidArgumentException
*/
public function testInValidFormats($fqsen)
{
new Fqsen($fqsen);
}
/**
* Data provider for invalidFormats tests. Contains a complete list from psr-5 draft.
*
* @return array
*/
public function invalidFqsenProvider()
{
return [
['\My\*'],
['\My\Space\.()'],
['My\Space'],
];
}
/**
* @covers ::__construct
* @covers ::__toString
*/
public function testToString()
{
$className = new Fqsen('\\phpDocumentor\\Application');
$this->assertEquals('\\phpDocumentor\\Application', (string)$className);
}
}

View File

@@ -0,0 +1,3 @@
service_name: travis-ci
coverage_clover: coverage.xml
json_path: coverage.json

View File

@@ -1,2 +0,0 @@
.idea
vendor

View File

@@ -1,32 +0,0 @@
before_commands:
- "composer install --no-dev --prefer-source"
tools:
external_code_coverage: true
php_code_sniffer:
enabled: true
config:
standard: PSR2
filter:
paths: ["src/*", "tests/*"]
php_cpd:
enabled: true
excluded_dirs: ["tests", "vendor"]
php_loc:
enabled: true
excluded_dirs: ["tests", "vendor"]
php_mess_detector:
enabled: true
config:
ruleset: phpmd.xml.dist
design_rules: { eval_expression: false }
filter:
paths: ["src/*"]
php_pdepend:
enabled: true
excluded_dirs: ["tests", "vendor"]
php_analyzer:
enabled: true
filter:
paths: ["src/*", "tests/*"]
sensiolabs_security_checker: true

View File

@@ -1,36 +0,0 @@
language: php
php:
- 5.5
- 5.6
- 7.0
- hhvm
- nightly
matrix:
allow_failures:
- php:
- hhvm
- nightly
cache:
directories:
- $HOME/.composer/cache
script:
- vendor/bin/phpunit --coverage-clover=coverage.clover -v
- composer update --no-interaction --prefer-source
- vendor/bin/phpunit -v
before_script:
- composer install --no-interaction
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
notifications:
irc: "irc.freenode.org#phpdocumentor"
email:
- mike.vanriel@naenius.com
- ashnazg@php.net
- boen.robot@gmail.com

View File

@@ -10,16 +10,12 @@ that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest
With this component, a library can provide support for annotations via DocBlocks
or otherwise retrieve information that is embedded in a DocBlock.
> **Note**: *this is a core component of phpDocumentor and is constantly being
> optimized for performance.*
Installation
------------
You can install the component in the following ways:
* Use the official Github repository (https://github.com/phpDocumentor/ReflectionDocBlock)
* Via Composer (http://packagist.org/packages/phpdocumentor/reflection-docblock)
```bash
composer require phpdocumentor/reflection-docblock
```
Usage
-----
@@ -52,18 +48,20 @@ $docblock = $factory->create($docComment);
```
The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock`
whose methods can be queried as shown in the following example.
whose methods can be queried:
```php
// Should contain the summary for this DocBlock
// Contains the summary for this DocBlock
$summary = $docblock->getSummary();
// Contains an object of type \phpDocumentor\Reflection\DocBlock\Description;
// you can either cast it to string or use the render method to get a string
// representation of the Description.
// Contains \phpDocumentor\Reflection\DocBlock\Description object
$description = $docblock->getDescription();
// You can either cast it to string
$description = (string) $docblock->getDescription();
// Or use the render method to get a string representation of the Description.
$description = $docblock->getDescription()->render();
```
> For more examples it would be best to review the scripts in the `/examples`
> folder.
> For more examples it would be best to review the scripts in the [`/examples` folder](/examples).

View File

@@ -10,9 +10,9 @@
}
],
"require": {
"php": ">=5.5",
"phpdocumentor/reflection-common": "^1.0@dev",
"phpdocumentor/type-resolver": "^0.2.0",
"php": "^7.0",
"phpdocumentor/reflection-common": "^1.0.0",
"phpdocumentor/type-resolver": "^0.4.0",
"webmozart/assert": "^1.0"
},
"autoload": {
@@ -22,7 +22,13 @@
"psr-4": {"phpDocumentor\\Reflection\\": ["tests/unit"]}
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^4.4"
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^6.4",
"doctrine/instantiator": "~1.0.5"
},
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
includes:
- temp/ecs/config/clean-code.neon
- temp/ecs/config/psr2-checkers.neon
- temp/ecs/config/spaces.neon
- temp/ecs/config/common.neon
checkers:
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
spacing: one
parameters:
exclude_checkers:
# from temp/ecs/config/common.neon
- PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
- PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer
- PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer
# from temp/ecs/config/spaces.neon
- PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer
skip:
SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff:
# WIP code
- src/DocBlock/StandardTagFactory.php
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff:
# WIP code
- src/DocBlock/StandardTagFactory.php
PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff:
- src/DocBlock/Tags/Return_.php
- src/DocBlock/Tags/Var_.php
PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff:
- */tests/**

View File

@@ -1,27 +0,0 @@
<?php
require_once(__DIR__ . '/../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* This is a Description. A Summary and Description are separated by either
* two subsequent newlines (thus a whiteline in between as can be seen in this
* example), or when the Summary ends with a dot (`.`) and some form of
* whitespace.
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// Should contain the first line of the DocBlock
$summary = $docblock->getSummary();
// Contains an object of type Description; you can either cast it to string or use
// the render method to get a string representation of the Description.
//
// In subsequent examples we will be fiddling a bit more with the Description.
$description = $docblock->getDescription();

View File

@@ -1,24 +0,0 @@
<?php
require_once(__DIR__ . '/../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// You can check if a DocBlock has one or more see tags
$hasSeeTag = $docblock->hasTag('see');
// Or we can get a complete list of all tags
$tags = $docblock->getTags();
// But we can also grab all tags of a specific type, such as `see`
$seeTags = $docblock->getTagsByName('see');

View File

@@ -1,27 +0,0 @@
<?php
require_once(__DIR__ . '/../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlock\Serializer;
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* And here is an example of the description
* of a DocBlock that can span multiple lines.
*
* @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// Create the serializer that will reconstitute the DocBlock back to its original form.
$serializer = new Serializer();
// Reconstitution is performed by the `getDocComment()` method.
$reconstitutedDocComment = $serializer->getDocComment($docblock);

View File

@@ -1,135 +0,0 @@
<?php
/**
* In this example we demonstrate how you can add your own Tag using a Static Factory method in your Tag class.
*/
require_once(__DIR__ . '/../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlock\Serializer;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
use phpDocumentor\Reflection\DocBlockFactory;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tags\BaseTag;
use phpDocumentor\Reflection\Types\Context;
use Webmozart\Assert\Assert;
/**
* An example of a custom tag called `my-tag` with an optional description.
*
* A Custom Tag is a class that can consist of two parts:
*
* 1. a method `create` that is a static factory for this class.
* 2. methods and properties that have this object act as an immutable Value Object representing a Tag instance.
*
* The static factory `create` is used to convert a tag line (without the tag name) into an instance of the
* same tag object with the right constructor parameters set. This method has a dynamic list of parameters so that you
* can inject various dependencies, see the method's DocBlock for more information.
*
* An object of this class, and its methods and properties, represent a single instance of that tag in your
* documentation in the form of a Value Object whose properties should not be changed after instantiation (it should be
* immutable).
*
* > Important: Tag classes that act as Factories using the `create` method should implement the TagFactory interface.
*/
final class MyTag extends BaseTag implements StaticMethod
{
/**
* A required property that is used by Formatters to reconstitute the complete tag line.
*
* @see Formatter
*
* @var string
*/
protected $name = 'my-tag';
/**
* The constructor for this Tag; this should contain all properties for this object.
*
* @param Description $description An example of how to add a Description to the tag; the Description is often
* an optional variable so passing null is allowed in this instance (though you can
* also construct an empty description object).
*
* @see BaseTag for the declaration of the description property and getDescription method.
*/
public function __construct(Description $description = null)
{
$this->description = $description;
}
/**
* A static Factory that creates a new instance of the current Tag.
*
* In this example the MyTag tag can be created by passing a description text as $body. Because we have added
* a $descriptionFactory that is type-hinted as DescriptionFactory we can now construct a new Description object
* and pass that to the constructor.
*
* > You could directly instantiate a Description object here but that won't be parsed for inline tags and Types
* > won't be resolved. The DescriptionFactory will take care of those actions.
*
* The `create` method's interface states that this method only features a single parameter (`$body`) but the
* {@see TagFactory} will read the signature of this method and if it has more parameters then it will try
* to find declarations for it in the ServiceLocator of the TagFactory (see {@see TagFactory::$serviceLocator}).
*
* > Important: all properties following the `$body` should default to `null`, otherwise PHP will error because
* > it no longer matches the interface. This is why you often see the default tags check that an optional argument
* > is not null nonetheless.
*
* @param string $body
* @param DescriptionFactory $descriptionFactory
* @param Context|null $context The Context is used to resolve Types and FQSENs, although optional
* it is highly recommended to pass it. If you omit it then it is assumed that
* the DocBlock is in the global namespace and has no `use` statements.
*
* @see Tag for the interface declaration of the `create` method.
* @see Tag::create() for more information on this method's workings.
*
* @return MyTag
*/
public static function create($body, DescriptionFactory $descriptionFactory = null, Context $context = null)
{
Assert::string($body);
Assert::notNull($descriptionFactory);
return new static($descriptionFactory->create($body, $context));
}
/**
* Returns a rendition of the original tag line.
*
* This method is used to reconstitute a DocBlock into its original form by the {@see Serializer}. It should
* feature all parts of the tag so that the serializer can put it back together.
*
* @return string
*/
public function __toString()
{
return (string)$this->description;
}
}
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* @my-tag I have a description
*/
DOCCOMMENT;
// Make a mapping between the tag name `my-tag` and the Tag class containing the Factory Method `create`.
$customTags = ['my-tag' => MyTag::class];
// Do pass the list of custom tags to the Factory for the DocBlockFactory.
$factory = DocBlockFactory::createInstance($customTags);
// You can also add Tags later using `$factory->registerTagHandler()` with a tag name and Tag class name.
// Create the DocBlock
$docblock = $factory->create($docComment);
// Take a look: the $customTagObjects now contain an array with your newly added tag
$customTagObjects = $docblock->getTagsByName('my-tag');
// As an experiment: let's reconstitute the DocBlock and observe that because we added a __toString() method
// to the tag class that we can now also see it.
$serializer = new Serializer();
$reconstitutedDocComment = $serializer->getDocComment($docblock);

View File

@@ -1,47 +0,0 @@
<?php
require_once(__DIR__ . '/../../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
* inline tag by adding an opening brace in front of it like this: {}.
*
* Here are example texts where you can see how they could be used in a real life situation:
*
* This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
* Or an {@internal inline tag with a literal {{@}link{} in it}.
*
* Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// Escaping is automatic so this happens in the DescriptionFactory.
$description = $docblock->getDescription();
// This is the rendition that we will receive of the Description.
$receivedDocComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
* inline tag by adding an opening brace in front of it like this: {}.
*
* Here are example texts where you can see how they could be used in a real life situation:
*
* This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
* Or an {@internal inline tag with a literal {{@}link{} in it}.
*
* Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
*/
DOCCOMMENT;
// Render it using the default PassthroughFormatter
$foundDescription = $description->render();

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset
name="ProxyManager rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
>
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
<rule ref="rulesets/design.xml">
<!-- eval is needed to generate runtime classes -->
<exclude name="EvalExpression"/>
</rule>
<rule ref="rulesets/naming.xml">
<exclude name="LongVariable"/>
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<property name="minimum">40</property>
</properties>
</rule>
</ruleset>

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit
colors="true"
checkForUnintentionallyCoveredCode="true"
beStrictAboutOutputDuringTests="true"
forceCoversAnnotation="true"
verbose="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
<testsuite name="integration">
<directory>./tests/integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
<blacklist>
<directory>./vendor/</directory>
</blacklist>
</filter>
<listeners>
<listener
class="Mockery\Adapter\Phpunit\TestListener"
file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php"
/>
</listeners>
</phpunit>

View File

@@ -24,7 +24,7 @@ final class DocBlock
private $description = null;
/** @var Tag[] An array containing all the tags in this docblock; except inline. */
private $tags = array();
private $tags = [];
/** @var Types\Context Information about the context of this DocBlock. */
private $context = null;
@@ -55,8 +55,7 @@ final class DocBlock
Location $location = null,
$isTemplateStart = false,
$isTemplateEnd = false
)
{
) {
Assert::string($summary);
Assert::boolean($isTemplateStart);
Assert::boolean($isTemplateEnd);
@@ -171,11 +170,11 @@ final class DocBlock
{
Assert::string($name);
$result = array();
$result = [];
/** @var Tag $tag */
foreach ($this->getTags() as $tag) {
if ($tag->getName() != $name) {
if ($tag->getName() !== $name) {
continue;
}
@@ -198,7 +197,7 @@ final class DocBlock
/** @var Tag $tag */
foreach ($this->getTags() as $tag) {
if ($tag->getName() == $name) {
if ($tag->getName() === $name) {
return true;
}
}
@@ -206,6 +205,23 @@ final class DocBlock
return false;
}
/**
* Remove a tag from this DocBlock.
*
* @param Tag $tag The tag to remove.
*
* @return void
*/
public function removeTag(Tag $tagToRemove)
{
foreach ($this->tags as $key => $tag) {
if ($tag === $tagToRemove) {
unset($this->tags[$key]);
break;
}
}
}
/**
* Adds a tag to this DocBlock.
*

View File

@@ -70,6 +70,16 @@ class Description
$this->tags = $tags;
}
/**
* Returns the tags for this DocBlock.
*
* @return Tag[]
*/
public function getTags()
{
return $this->tags;
}
/**
* Renders this description as a string where the provided formatter will format the tags in the expected string
* format.
@@ -88,6 +98,7 @@ class Description
foreach ($this->tags as $tag) {
$tags[] = '{' . $formatter->format($tag) . '}';
}
return vsprintf($this->bodyTemplate, $tags);
}

View File

@@ -188,5 +188,4 @@ class DescriptionFactory
return implode("\n", $lines);
}
}

View File

@@ -10,7 +10,7 @@
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
namespace phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tags\Example;
@@ -23,7 +23,7 @@ class ExampleFinder
private $sourceDirectory = '';
/** @var string[] */
private $exampleDirectories = array();
private $exampleDirectories = [];
/**
* Attempts to find the example contents for the given descriptor.

View File

@@ -32,6 +32,9 @@ class Serializer
/** @var int|null The max length of a line. */
protected $lineLength = null;
/** @var DocBlock\Tags\Formatter A custom tag formatter. */
protected $tagFormatter = null;
/**
* Create a Serializer instance.
*
@@ -39,18 +42,21 @@ class Serializer
* @param string $indentString The string to indent the comment with.
* @param bool $indentFirstLine Whether to indent the first line.
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
* @param DocBlock\Tags\Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter.
*/
public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null)
public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null, $tagFormatter = null)
{
Assert::integer($indent);
Assert::string($indentString);
Assert::boolean($indentFirstLine);
Assert::nullOrInteger($lineLength);
Assert::nullOrIsInstanceOf($tagFormatter, 'phpDocumentor\Reflection\DocBlock\Tags\Formatter');
$this->indent = $indent;
$this->indentString = $indentString;
$this->isFirstLineIndented = $indentFirstLine;
$this->lineLength = $lineLength;
$this->tagFormatter = $tagFormatter ?: new DocBlock\Tags\Formatter\PassthroughFormatter();
}
/**
@@ -75,7 +81,12 @@ class Serializer
)
);
$comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
$comment = "{$firstIndent}/**\n";
if ($text) {
$comment .= "{$indent} * {$text}\n";
$comment .= "{$indent} *\n";
}
$comment = $this->addTagBlock($docblock, $wrapLength, $indent, $comment);
$comment .= $indent . ' */';
@@ -115,6 +126,7 @@ class Serializer
$text = wordwrap($text, $wrapLength);
return $text;
}
return $text;
}
@@ -128,11 +140,11 @@ class Serializer
private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment)
{
foreach ($docblock->getTags() as $tag) {
$formatter = new DocBlock\Tags\Formatter\PassthroughFormatter();
$tagText = $formatter->format($tag);
$tagText = $this->tagFormatter->format($tag);
if ($wrapLength !== null) {
$tagText = wordwrap($tagText, $wrapLength);
}
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
$comment .= "{$indent} * {$tagText}\n";

View File

@@ -113,6 +113,12 @@ final class StandardTagFactory implements TagFactory
list($tagName, $tagBody) = $this->extractTagParts($tagLine);
if ($tagBody !== '' && $tagBody[0] === '[') {
throw new \InvalidArgumentException(
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
);
}
return $this->createTag($tagBody, $tagName, $context);
}
@@ -160,8 +166,8 @@ final class StandardTagFactory implements TagFactory
*/
private function extractTagParts($tagLine)
{
$matches = array();
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us', $tagLine, $matches)) {
$matches = [];
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
throw new \InvalidArgumentException(
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
);
@@ -190,8 +196,7 @@ final class StandardTagFactory implements TagFactory
$arguments = $this->getArgumentsForParametersFromWiring(
$this->fetchParametersForHandlerFactoryMethod($handlerClassName),
$this->getServiceLocatorWithDynamicParameters($context, $name, $body)
)
;
);
return call_user_func_array([$handlerClassName, 'create'], $arguments);
}

View File

@@ -73,7 +73,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
*/
public function __toString()
{
return $this->authorName . '<' . $this->authorEmail . '>';
return $this->authorName . (strlen($this->authorEmail) ? ' <' . $this->authorEmail . '>' : '');
}
/**

View File

@@ -12,11 +12,11 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**
@@ -49,8 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
DescriptionFactory $descriptionFactory = null,
FqsenResolver $resolver = null,
TypeContext $context = null
)
{
) {
Assert::string($body);
Assert::notEmpty($body);

View File

@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**

View File

@@ -12,7 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tag;
use Webmozart\Assert\Assert;
/**
* Reflection class for a {@}example tag in a Docblock.
@@ -22,7 +24,7 @@ final class Example extends BaseTag
/**
* @var string Path to a file to use as an example. May also be an absolute URI.
*/
private $filePath = '';
private $filePath;
/**
* @var bool Whether the file path component represents an URI. This determines how the file portion
@@ -30,6 +32,33 @@ final class Example extends BaseTag
*/
private $isURI = false;
/**
* @var int
*/
private $startingLine;
/**
* @var int
*/
private $lineCount;
public function __construct($filePath, $isURI, $startingLine, $lineCount, $description)
{
Assert::notEmpty($filePath);
Assert::integer($startingLine);
Assert::greaterThanEq($startingLine, 0);
$this->filePath = $filePath;
$this->startingLine = $startingLine;
$this->lineCount = $lineCount;
$this->name = 'example';
if ($description !== null) {
$this->description = trim($description);
}
$this->isURI = $isURI;
}
/**
* {@inheritdoc}
*/
@@ -43,7 +72,7 @@ final class Example extends BaseTag
:$this->filePath;
}
$this->description = $filePath . ' ' . parent::getContent();
return trim($filePath . ' ' . parent::getDescription());
}
return $this->description;
@@ -71,16 +100,29 @@ final class Example extends BaseTag
$lineCount = null;
$description = null;
// Starting line / Number of lines / Description
if (preg_match('/^([1-9]\d*)\s*(?:((?1))\s+)?(.*)$/sux', $matches[3], $matches)) {
$startingLine = (int)$matches[1];
if (isset($matches[2]) && $matches[2] !== '') {
$lineCount = (int)$matches[2];
}
if (array_key_exists(3, $matches)) {
$description = $matches[3];
// Starting line / Number of lines / Description
if (preg_match('/^([1-9]\d*)(?:\s+((?1))\s*)?(.*)$/sux', $matches[3], $contentMatches)) {
$startingLine = (int)$contentMatches[1];
if (isset($contentMatches[2]) && $contentMatches[2] !== '') {
$lineCount = (int)$contentMatches[2];
}
if (array_key_exists(3, $contentMatches)) {
$description = $contentMatches[3];
}
}
}
return new static($filePath, $fileUri, $startingLine, $lineCount, $description);
return new static(
$filePath !== null?$filePath:$fileUri,
$fileUri !== null,
$startingLine,
$lineCount,
$description
);
}
/**
@@ -94,46 +136,6 @@ final class Example extends BaseTag
return $this->filePath;
}
/**
* Sets the file path.
*
* @param string $filePath The new file path to use for the example.
*
* @return $this
*/
public function setFilePath($filePath)
{
$this->isURI = false;
$this->filePath = trim($filePath);
$this->description = null;
return $this;
}
/**
* Sets the file path as an URI.
*
* This function is equivalent to {@link setFilePath()}, except that it
* converts an URI to a file path before that.
*
* There is no getFileURI(), as {@link getFilePath()} is compatible.
*
* @param string $uri The new file URI to use as an example.
*
* @return $this
*/
public function setFileURI($uri)
{
$this->isURI = true;
$this->description = null;
$this->filePath = $this->isUriRelative($uri)
? rawurldecode(str_replace(array('/', '\\'), '%2F', $uri))
: $this->filePath = $uri;
return $this;
}
/**
* Returns a string representation for this tag.
*
@@ -141,7 +143,7 @@ final class Example extends BaseTag
*/
public function __toString()
{
return $this->filePath . ($this->description ? ' ' . $this->description->render() : '');
return $this->filePath . ($this->description ? ' ' . $this->description : '');
}
/**
@@ -155,4 +157,20 @@ final class Example extends BaseTag
{
return false === strpos($uri, ':');
}
/**
* @return int
*/
public function getStartingLine()
{
return $this->startingLine;
}
/**
* @return int
*/
public function getLineCount()
{
return $this->lineCount;
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jan Schneider <jan@horde.org>
* @copyright 2017 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
class AlignFormatter implements Formatter
{
/** @var int The maximum tag name length. */
protected $maxLen = 0;
/**
* Constructor.
*
* @param Tag[] $tags All tags that should later be aligned with the formatter.
*/
public function __construct(array $tags)
{
foreach ($tags as $tag) {
$this->maxLen = max($this->maxLen, strlen($tag->getName()));
}
}
/**
* Formats the given tag to return a simple plain text version.
*
* @param Tag $tag
*
* @return string
*/
public function format(Tag $tag)
{
return '@' . $tag->getName() . str_repeat(' ', $this->maxLen - strlen($tag->getName()) + 1) . (string)$tag;
}
}

View File

@@ -26,6 +26,6 @@ class PassthroughFormatter implements Formatter
*/
public function format(Tag $tag)
{
return '@' . $tag->getName() . ' ' . (string)$tag;
return trim('@' . $tag->getName() . ' ' . (string)$tag);
}
}

View File

@@ -91,11 +91,15 @@ final class Method extends BaseTag implements Factory\StaticMethod
)?
# Return type
(?:
(
(?:[\w\|_\\\\]+)
# array notation
(?:\[\])*
)?
(
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
(?:
(?:[\w\|_\\\\]+)
# array notation
(?:\[\])*
)*
)
\s+
)?
# Legacy method name (not captured)
@@ -121,12 +125,17 @@ final class Method extends BaseTag implements Factory\StaticMethod
list(, $static, $returnType, $methodName, $arguments, $description) = $matches;
$static = $static === 'static';
if ($returnType === '') {
$returnType = 'void';
}
$returnType = $typeResolver->resolve($returnType, $context);
$description = $descriptionFactory->create($description, $context);
if ('' !== $arguments) {
if (is_string($arguments) && strlen($arguments) > 0) {
$arguments = explode(',', $arguments);
foreach($arguments as &$argument) {
foreach ($arguments as &$argument) {
$argument = explode(' ', self::stripRestArg(trim($argument)), 2);
if ($argument[0][0] === '$') {
$argumentName = substr($argument[0], 1);
@@ -192,11 +201,11 @@ final class Method extends BaseTag implements Factory\StaticMethod
$arguments[] = $argument['type'] . ' $' . $argument['name'];
}
return ($this->isStatic() ? 'static ' : '')
return trim(($this->isStatic() ? 'static ' : '')
. (string)$this->returnType . ' '
. $this->methodName
. '(' . implode(', ', $arguments) . ')'
. ($this->description ? ' ' . $this->description->render() : '');
. ($this->description ? ' ' . $this->description->render() : ''));
}
private function filterArguments($arguments)
@@ -205,10 +214,13 @@ final class Method extends BaseTag implements Factory\StaticMethod
if (is_string($argument)) {
$argument = [ 'name' => $argument ];
}
if (! isset($argument['type'])) {
$argument['type'] = new Void_();
}
$keys = array_keys($argument);
sort($keys);
if ($keys !== [ 'name', 'type' ]) {
throw new \InvalidArgumentException(
'Arguments can only have the "name" and "type" fields, found: ' . var_export($keys, true)

View File

@@ -77,7 +77,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$')) {
$variableName = array_shift($parts);
array_shift($parts);

View File

@@ -70,7 +70,7 @@ class Property extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);

View File

@@ -70,7 +70,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);

View File

@@ -70,7 +70,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);

View File

@@ -0,0 +1,42 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2017 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
use phpDocumentor\Reflection\Fqsen as RealFqsen;
/**
* Fqsen reference used by {@see phpDocumentor\Reflection\DocBlock\Tags\See}
*/
final class Fqsen implements Reference
{
/**
* @var RealFqsen
*/
private $fqsen;
/**
* Fqsen constructor.
*/
public function __construct(RealFqsen $fqsen)
{
$this->fqsen = $fqsen;
}
/**
* @return string string representation of the referenced fqsen
*/
public function __toString()
{
return (string)$this->fqsen;
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2017 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
/**
* Interface for references in {@see phpDocumentor\Reflection\DocBlock\Tags\See}
*/
interface Reference
{
public function __toString();
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2017 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
use Webmozart\Assert\Assert;
/**
* Url reference used by {@see phpDocumentor\Reflection\DocBlock\Tags\See}
*/
final class Url implements Reference
{
/**
* @var string
*/
private $uri;
/**
* Url constructor.
*/
public function __construct($uri)
{
Assert::stringNotEmpty($uri);
$this->uri = $uri;
}
public function __toString()
{
return $this->uri;
}
}

View File

@@ -43,8 +43,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
TypeResolver $typeResolver = null,
DescriptionFactory $descriptionFactory = null,
TypeContext $context = null
)
{
) {
Assert::string($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]);

View File

@@ -12,11 +12,13 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Reference;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use Webmozart\Assert\Assert;
/**
@@ -26,16 +28,16 @@ class See extends BaseTag implements Factory\StaticMethod
{
protected $name = 'see';
/** @var Fqsen */
/** @var Reference */
protected $refers = null;
/**
* Initializes this tag.
*
* @param Fqsen $refers
* @param Reference $refers
* @param Description $description
*/
public function __construct(Fqsen $refers, Description $description = null)
public function __construct(Reference $refers, Description $description = null)
{
$this->refers = $refers;
$this->description = $description;
@@ -56,13 +58,18 @@ class See extends BaseTag implements Factory\StaticMethod
$parts = preg_split('/\s+/Su', $body, 2);
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
return new static($resolver->resolve($parts[0], $context), $description);
// https://tools.ietf.org/html/rfc2396#section-3
if (preg_match('/\w:\/\/\w/i', $parts[0])) {
return new static(new Url($parts[0]), $description);
}
return new static(new FqsenRef($resolver->resolve($parts[0], $context)), $description);
}
/**
* Returns the structural element this tag refers to.
* Returns the ref of this tag.
*
* @return Fqsen
* @return Reference
*/
public function getReference()
{

View File

@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**

View File

@@ -59,6 +59,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
if (isset($matches[2]) && $matches[2] !== '') {
$lineCount = (int)$matches[2];
}
$description = $matches[3];
}

View File

@@ -70,7 +70,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
@@ -112,7 +112,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
public function __toString()
{
return ($this->type ? $this->type . ' ' : '')
. '$' . $this->variableName
. ($this->description ? ' ' . $this->description : '');
. (empty($this->variableName) ? null : ('$' . $this->variableName))
. ($this->description ? ' ' . $this->description : '');
}
}

View File

@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**

View File

@@ -93,7 +93,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
return new DocBlock(
$summary,
$description ? $this->descriptionFactory->create($description, $context) : null,
array_filter($this->parseTagBlock($tags, $context), function($tag) {
array_filter($this->parseTagBlock($tags, $context), function ($tag) {
return $tag instanceof Tag;
}),
$context,
@@ -120,11 +120,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
// reg ex above is not able to remove */ from a single line docblock
if (substr($comment, -2) == '*/') {
if (substr($comment, -2) === '*/') {
$comment = trim(substr($comment, 0, -2));
}
return str_replace(array("\r\n", "\r"), "\n", $comment);
return str_replace(["\r\n", "\r"], "\n", $comment);
}
/**
@@ -143,7 +143,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
// performance impact of running a regular expression
if (strpos($comment, '@') === 0) {
return array('', '', '', $comment);
return ['', '', '', $comment];
}
// clears all extra horizontal whitespace from the line endings to prevent parsing issues
@@ -241,7 +241,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*/
private function splitTagBlockIntoTagLines($tags)
{
$result = array();
$result = [];
foreach (explode("\n", $tags) as $tag_line) {
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
$result[] = $tag_line;

View File

@@ -1,97 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\See;
/**
* @coversNothing
*/
class InterpretingDocBlocksTest extends \PHPUnit_Framework_TestCase
{
public function testInterpretingASimpleDocBlock()
{
/**
* @var DocBlock $docblock
* @var string $summary
* @var Description $description
*/
include(__DIR__ . '/../../examples/01-interpreting-a-simple-docblock.php');
$descriptionText = <<<DESCRIPTION
This is a Description. A Summary and Description are separated by either
two subsequent newlines (thus a whiteline in between as can be seen in this
example), or when the Summary ends with a dot (`.`) and some form of
whitespace.
DESCRIPTION;
$this->assertInstanceOf(DocBlock::class, $docblock);
$this->assertSame('This is an example of a summary.', $summary);
$this->assertInstanceOf(Description::class, $description);
$this->assertSame($descriptionText, $description->render());
$this->assertEmpty($docblock->getTags());
}
public function testInterpretingTags()
{
/**
* @var DocBlock $docblock
* @var boolean $hasSeeTag
* @var Tag[] $tags
* @var See[] $seeTags
*/
include(__DIR__ . '/../../examples/02-interpreting-tags.php');
$this->assertTrue($hasSeeTag);
$this->assertCount(1, $tags);
$this->assertCount(1, $seeTags);
$this->assertInstanceOf(See::class, $tags[0]);
$this->assertInstanceOf(See::class, $seeTags[0]);
$seeTag = $seeTags[0];
$this->assertSame('\\' . StandardTagFactory::class, (string)$seeTag->getReference());
$this->assertSame('', (string)$seeTag->getDescription());
}
public function testDescriptionsCanEscapeAtSignsAndClosingBraces()
{
/**
* @var string $docComment
* @var DocBlock $docblock
* @var Description $description
* @var string $receivedDocComment
* @var string $foundDescription
*/
include(__DIR__ . '/../../examples/playing-with-descriptions/02-escaping.php');
$this->assertSame(<<<'DESCRIPTION'
You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
inline tag by adding an opening brace in front of it like this: }.
Here are example texts where you can see how they could be used in a real life situation:
This is a text with an {@internal inline tag where a closing brace (}) is shown}.
Or an {@internal inline tag with a literal {@link} in it}.
Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
DESCRIPTION
,
$foundDescription
)
;
}
}

View File

@@ -1,35 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\See;
/**
* @coversNothing
*/
class ReconstitutingADocBlockTest extends \PHPUnit_Framework_TestCase
{
public function testReconstituteADocBlock()
{
/**
* @var string $docComment
* @var string $reconstitutedDocComment
*/
include(__DIR__ . '/../../examples/03-reconstituting-a-docblock.php');
$this->assertSame($docComment, $reconstitutedDocComment);
}
}

View File

@@ -1,39 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\See;
/**
* @coversNothing
*/
class UsingTagsTest extends \PHPUnit_Framework_TestCase
{
public function testAddingYourOwnTagUsingAStaticMethodAsFactory()
{
/**
* @var object[] $customTagObjects
* @var string $docComment
* @var string $reconstitutedDocComment
*/
include(__DIR__ . '/../../examples/04-adding-your-own-tag.php');
$this->assertInstanceOf(\MyTag::class, $customTagObjects[0]);
$this->assertSame('my-tag', $customTagObjects[0]->getName());
$this->assertSame('I have a description', (string)$customTagObjects[0]->getDescription());
$this->assertSame($docComment, $reconstitutedDocComment);
}
}

View File

@@ -1,174 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Tags\Link;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @covers ::<private>
*/
class DescriptionFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
* @dataProvider provideSimpleExampleDescriptions
*/
public function testDescriptionCanParseASimpleString($contents)
{
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')->never();
$factory = new DescriptionFactory($tagFactory);
$description = $factory->create($contents, new Context(''));
$this->assertSame($contents, $description->render());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
* @dataProvider provideEscapeSequences
*/
public function testEscapeSequences($contents, $expected)
{
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')->never();
$factory = new DescriptionFactory($tagFactory);
$description = $factory->create($contents, new Context(''));
$this->assertSame($expected, $description->render());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\DocBlock\Tags\Link
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses phpDocumentor\Reflection\Types\Context
*/
public function testDescriptionCanParseAStringWithInlineTag()
{
$contents = 'This is text for a {@link http://phpdoc.org/ description} that uses an inline tag.';
$context = new Context('');
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')
->once()
->with('@link http://phpdoc.org/ description', $context)
->andReturn(new Link('http://phpdoc.org/', new Description('description')))
;
$factory = new DescriptionFactory($tagFactory);
$description = $factory->create($contents, $context);
$this->assertSame($contents, $description->render());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\DocBlock\Tags\Link
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses phpDocumentor\Reflection\Types\Context
*/
public function testDescriptionCanParseAStringStartingWithInlineTag()
{
$contents = '{@link http://phpdoc.org/ This} is text for a description that starts with an inline tag.';
$context = new Context('');
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')
->once()
->with('@link http://phpdoc.org/ This', $context)
->andReturn(new Link('http://phpdoc.org/', new Description('This')))
;
$factory = new DescriptionFactory($tagFactory);
$description = $factory->create($contents, $context);
$this->assertSame($contents, $description->render());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testIfSuperfluousStartingSpacesAreRemoved()
{
$factory = new DescriptionFactory(m::mock(TagFactory::class));
$descriptionText = <<<DESCRIPTION
This is a multiline
description that you commonly
see with tags.
It does have a multiline code sample
that should align, no matter what
All spaces superfluous spaces on the
second and later lines should be
removed but the code sample should
still be indented.
DESCRIPTION;
$expectedDescription = <<<DESCRIPTION
This is a multiline
description that you commonly
see with tags.
It does have a multiline code sample
that should align, no matter what
All spaces superfluous spaces on the
second and later lines should be
removed but the code sample should
still be indented.
DESCRIPTION;
$description = $factory->create($descriptionText, new Context(''));
$this->assertSame($expectedDescription, $description->render());
}
/**
* Provides a series of example strings that the parser should correctly interpret and return.
*
* @return string[][]
*/
public function provideSimpleExampleDescriptions()
{
return [
['This is text for a description.'],
['This is text for a description containing { that is literal.'],
['This is text for a description containing } that is literal.'],
['This is text for a description with {just a text} that is not a tag.'],
];
}
public function provideEscapeSequences()
{
return [
['This is text for a description with a {@}.', 'This is text for a description with a @.'],
['This is text for a description with a {}.', 'This is text for a description with a }.'],
];
}
}

View File

@@ -1,75 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Description
*/
class DescriptionTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::render
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
*/
public function testDescriptionCanRenderUsingABodyWithPlaceholdersAndTags()
{
$body = 'This is a %1$s body.';
$expected = 'This is a {@internal significant } body.';
$tags = [new Generic('internal', new Description('significant '))];
$fixture = new Description($body, $tags);
// without formatter (thus the PassthroughFormatter by default)
$this->assertSame($expected, $fixture->render());
// with a custom formatter
$formatter = m::mock(PassthroughFormatter::class);
$formatter->shouldReceive('format')->with($tags[0])->andReturn('@internal significant ');
$this->assertSame($expected, $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::render
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
*/
public function testDescriptionCanBeCastToString()
{
$body = 'This is a %1$s body.';
$expected = 'This is a {@internal significant } body.';
$tags = [new Generic('internal', new Description('significant '))];
$fixture = new Description($body, $tags);
$this->assertSame($expected, (string)$fixture);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testBodyTemplateMustBeAString()
{
new Description([]);
}
}

View File

@@ -1,201 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Serializer
* @covers ::<private>
*/
class SerializerTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::getDocComment
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses phpDocumentor\Reflection\DocBlock
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
*/
public function testReconstructsADocCommentFromADocBlock()
{
$expected = <<<'DOCCOMMENT'
/**
* This is a summary
*
* This is a description
*
* @unknown-tag Test description for the unknown tag
*/
DOCCOMMENT;
$fixture = new Serializer();
$docBlock = new DocBlock(
'This is a summary',
new Description('This is a description'),
[
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
]
);
$this->assertSame($expected, $fixture->getDocComment($docBlock));
}
/**
* @covers ::__construct
* @covers ::getDocComment
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses phpDocumentor\Reflection\DocBlock
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
*/
public function testAddPrefixToDocBlock()
{
$expected = <<<'DOCCOMMENT'
aa/**
aa * This is a summary
aa *
aa * This is a description
aa *
aa * @unknown-tag Test description for the unknown tag
aa */
DOCCOMMENT;
$fixture = new Serializer(2, 'a');
$docBlock = new DocBlock(
'This is a summary',
new Description('This is a description'),
[
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
]
);
$this->assertSame($expected, $fixture->getDocComment($docBlock));
}
/**
* @covers ::__construct
* @covers ::getDocComment
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses phpDocumentor\Reflection\DocBlock
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
*/
public function testAddPrefixToDocBlockExceptFirstLine()
{
$expected = <<<'DOCCOMMENT'
/**
aa * This is a summary
aa *
aa * This is a description
aa *
aa * @unknown-tag Test description for the unknown tag
aa */
DOCCOMMENT;
$fixture = new Serializer(2, 'a', false);
$docBlock = new DocBlock(
'This is a summary',
new Description('This is a description'),
[
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
]
);
$this->assertSame($expected, $fixture->getDocComment($docBlock));
}
/**
* @covers ::__construct
* @covers ::getDocComment
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses phpDocumentor\Reflection\DocBlock
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
*/
public function testWordwrapsAroundTheGivenAmountOfCharacters()
{
$expected = <<<'DOCCOMMENT'
/**
* This is a
* summary
*
* This is a
* description
*
* @unknown-tag
* Test
* description
* for the
* unknown tag
*/
DOCCOMMENT;
$fixture = new Serializer(0, '', true, 15);
$docBlock = new DocBlock(
'This is a summary',
new Description('This is a description'),
[
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
]
);
$this->assertSame($expected, $fixture->getDocComment($docBlock));
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfIndentIsNotAnInteger()
{
new Serializer([]);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfIndentStringIsNotAString()
{
new Serializer(0, []);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfIndentFirstLineIsNotABoolean()
{
new Serializer(0, '', []);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfLineLengthIsNotNullNorAnInteger()
{
new Serializer(0, '', false, []);
}
}

View File

@@ -1,361 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Tags\Author;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use phpDocumentor\Reflection\DocBlock\Tags\See;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass phpDocumentor\Reflection\DocBlock\StandardTagFactory
* @covers ::<private>
*/
class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testCreatingAGenericTag()
{
$expectedTagName = 'unknown-tag';
$expectedDescriptionText = 'This is a description';
$expectedDescription = new Description($expectedDescriptionText);
$context = new Context('');
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory
->shouldReceive('create')
->once()
->with($expectedDescriptionText, $context)
->andReturn($expectedDescription)
;
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
/** @var Generic $tag */
$tag = $tagFactory->create('@' . $expectedTagName . ' This is a description', $context);
$this->assertInstanceOf(Generic::class, $tag);
$this->assertSame($expectedTagName, $tag->getName());
$this->assertSame($expectedDescription, $tag->getDescription());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses phpDocumentor\Reflection\DocBlock\Tags\Author
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testCreatingASpecificTag()
{
$context = new Context('');
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
/** @var Author $tag */
$tag = $tagFactory->create('@author Mike van Riel <me@mikevanriel.com>', $context);
$this->assertInstanceOf(Author::class, $tag);
$this->assertSame('author', $tag->getName());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses phpDocumentor\Reflection\DocBlock\Tags\See
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testAnEmptyContextIsCreatedIfNoneIsProvided()
{
$fqsen = '\Tag';
$resolver = m::mock(FqsenResolver::class)
->shouldReceive('resolve')
->with('Tag', m::type(Context::class))
->andReturn(new Fqsen($fqsen))
->getMock()
;
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory->shouldIgnoreMissing();
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
/** @var See $tag */
$tag = $tagFactory->create('@see Tag');
$this->assertInstanceOf(See::class, $tag);
$this->assertSame($fqsen, (string)$tag->getReference());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses phpDocumentor\Reflection\DocBlock\Tags\Author
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testPassingYourOwnSetOfTagHandlers()
{
$context = new Context('');
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class), ['user' => Author::class]);
/** @var Author $tag */
$tag = $tagFactory->create('@user Mike van Riel <me@mikevanriel.com>', $context);
$this->assertInstanceOf(Author::class, $tag);
$this->assertSame('author', $tag->getName());
}
/**
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The tag "@user/myuser" does not seem to be wellformed, please check it for errors
*/
public function testExceptionIsThrownIfProvidedTagIsNotWellformed()
{
$this->markTestIncomplete(
'For some reason this test fails; once I have access to a RegEx analyzer I will have to test the regex'
)
;
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
$tagFactory->create('@user[myuser');
}
/**
* @covers ::__construct
* @covers ::addParameter
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
*/
public function testAddParameterToServiceLocator()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->addParameter('myParam', 'myValue');
$this->assertAttributeSame(
[FqsenResolver::class => $resolver, 'myParam' => 'myValue'],
'serviceLocator',
$tagFactory
)
;
}
/**
* @covers ::addService
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
*/
public function testAddServiceToServiceLocator()
{
$service = new PassthroughFormatter();
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->addService($service);
$this->assertAttributeSame(
[FqsenResolver::class => $resolver, PassthroughFormatter::class => $service],
'serviceLocator',
$tagFactory
)
;
}
/**
* @covers ::addService
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
*/
public function testInjectConcreteServiceForInterfaceToServiceLocator()
{
$interfaceName = Formatter::class;
$service = new PassthroughFormatter();
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->addService($service, $interfaceName);
$this->assertAttributeSame(
[FqsenResolver::class => $resolver, $interfaceName => $service],
'serviceLocator',
$tagFactory
)
;
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::create
* @uses phpDocumentor\Reflection\DocBlock\Tags\Author
*/
public function testRegisteringAHandlerForANewTag()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler('my-tag', Author::class);
// Assert by trying to create one
$tag = $tagFactory->create('@my-tag Mike van Riel <me@mikevanriel.com>');
$this->assertInstanceOf(Author::class, $tag);
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
*/
public function testHandlerRegistrationFailsIfProvidedTagNameIsNotAString()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler([], Author::class);
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
*/
public function testHandlerRegistrationFailsIfProvidedTagNameIsEmpty()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler('', Author::class);
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
*/
public function testHandlerRegistrationFailsIfProvidedTagNameIsNamespaceButNotFullyQualified()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler('Name\Spaced\Tag', Author::class);
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
*/
public function testHandlerRegistrationFailsIfProvidedHandlerIsNotAString()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler('my-tag', []);
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
*/
public function testHandlerRegistrationFailsIfProvidedHandlerIsEmpty()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler('my-tag', '');
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
*/
public function testHandlerRegistrationFailsIfProvidedHandlerIsNotAnExistingClassName()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler('my-tag', 'IDoNotExist');
}
/**
* @covers ::registerTagHandler
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @expectedException \InvalidArgumentException
*/
public function testHandlerRegistrationFailsIfProvidedHandlerDoesNotImplementTheTagInterface()
{
$resolver = m::mock(FqsenResolver::class);
$tagFactory = new StandardTagFactory($resolver);
$tagFactory->registerTagHandler('my-tag', 'stdClass');
}
/**
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses phpDocumentor\Reflection\Docblock\Description
* @uses phpDocumentor\Reflection\Docblock\Tags\Return_
* @uses phpDocumentor\Reflection\Docblock\Tags\BaseTag
*/
public function testReturntagIsMappedCorrectly()
{
$context = new Context('');
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory
->shouldReceive('create')
->once()
->with('', $context)
->andReturn(new Description(''))
;
$typeResolver = new TypeResolver();
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
$tagFactory->addService($typeResolver, TypeResolver::class);
/** @var Return_ $tag */
$tag = $tagFactory->create('@return mixed', $context);
$this->assertInstanceOf(Return_::class, $tag);
$this->assertSame('return', $tag->getName());
}
}

View File

@@ -1,148 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Author
* @covers ::<private>
*/
class AuthorTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
$this->assertSame('author', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
$this->assertSame('@author Mike van Riel<mike@phpdoc.org>', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getAuthorName
*/
public function testHasTheAuthorName()
{
$expected = 'Mike van Riel';
$fixture = new Author($expected, 'mike@phpdoc.org');
$this->assertSame($expected, $fixture->getAuthorName());
}
/**
* @covers ::__construct
* @covers ::getAuthorName
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfAuthorNameIsNotAString()
{
new Author([], 'mike@phpdoc.org');
}
/**
* @covers ::__construct
* @covers ::getEmail
*/
public function testHasTheAuthorMailAddress()
{
$expected = 'mike@phpdoc.org';
$fixture = new Author('Mike van Riel', $expected);
$this->assertSame($expected, $fixture->getEmail());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfEmailIsNotAString()
{
new Author('Mike van Riel', []);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfEmailIsNotValid()
{
new Author('Mike van Riel', 'mike');
}
/**
* @covers ::__construct
* @covers ::__toString
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
$this->assertSame('Mike van Riel<mike@phpdoc.org>', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::<public>
*/
public function testFactoryMethod()
{
$fixture = Author::create('Mike van Riel <mike@phpdoc.org>');
$this->assertSame('Mike van Riel<mike@phpdoc.org>', (string)$fixture);
$this->assertSame('Mike van Riel', $fixture->getAuthorName());
$this->assertSame('mike@phpdoc.org', $fixture->getEmail());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::<public>
*/
public function testFactoryMethodReturnsNullIfItCouldNotReadBody()
{
$this->assertNull(Author::create('dfgr<'));
}
}

View File

@@ -1,155 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Covers
* @covers ::<private>
*/
class CoversTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('covers', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('@covers \DateTime Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getReference
*/
public function testHasReferenceToFqsen()
{
$expected = new Fqsen('\DateTime');
$fixture = new Covers($expected);
$this->assertSame($expected, $fixture->getReference());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Covers(new Fqsen('\DateTime'), $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('\DateTime Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Fqsen
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = m::mock(FqsenResolver::class);
$context = new Context('');
$fqsen = new Fqsen('\DateTime');
$description = new Description('My Description');
$descriptionFactory
->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$resolver->shouldReceive('resolve')->with('DateTime', $context)->andReturn($fqsen);
$fixture = Covers::create('DateTime My Description', $descriptionFactory, $resolver, $context);
$this->assertSame('\DateTime My Description', (string)$fixture);
$this->assertSame($fqsen, $fixture->getReference());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
$this->assertNull(Covers::create([]));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotEmpty()
{
$this->assertNull(Covers::create(''));
}
}

View File

@@ -1,166 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Deprecated
* @covers ::<private>
*/
class DeprecatedTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Deprecated('1.0', new Description('Description'));
$this->assertSame('deprecated', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Deprecated('1.0', new Description('Description'));
$this->assertSame('@deprecated 1.0 Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Deprecated('1.0', new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVersion
*/
public function testHasVersionNumber()
{
$expected = '1.0';
$fixture = new Deprecated($expected);
$this->assertSame($expected, $fixture->getVersion());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Deprecated('1.0', $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Deprecated('1.0', new Description('Description'));
$this->assertSame('1.0 Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$version = '1.0';
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Deprecated::create('1.0 My Description', $descriptionFactory, $context);
$this->assertSame('1.0 My Description', (string)$fixture);
$this->assertSame($version, $fixture->getVersion());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethodCreatesEmptyDeprecatedTag()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory->shouldReceive('create')->never();
$fixture = Deprecated::create('', $descriptionFactory, new Context(''));
$this->assertSame('', (string)$fixture);
$this->assertSame(null, $fixture->getVersion());
$this->assertSame(null, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfVersionIsNotString()
{
$this->assertNull(Deprecated::create([]));
}
/**
* @covers ::create
*/
public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex()
{
$this->assertEquals(new Deprecated(), Deprecated::create('dkhf<'));
}
}

View File

@@ -1,41 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
*/
class PassthroughFormatterTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::format
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
*/
public function testFormatterCallsToStringAndReturnsAStandardRepresentation()
{
$expected = '@unknown-tag This is a description';
$fixture = new PassthroughFormatter();
$this->assertSame(
$expected,
$fixture->format(new Generic('unknown-tag', new Description('This is a description')))
);
}
}

View File

@@ -1,146 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @generic http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Generic
* @covers ::<private>
*/
class GenericTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Generic('generic', new Description('Description'));
$this->assertSame('generic', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Generic('generic', new Description('Description'));
$this->assertSame('@generic Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Generic('generic', new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Generic('generic', $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Generic('generic', new Description('Description'));
$this->assertSame('Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$generics = 'generic';
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Generic::create('My Description', 'generic', $descriptionFactory, $context);
$this->assertSame('My Description', (string)$fixture);
$this->assertSame($generics, $fixture->getName());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfNameIsNotString()
{
Generic::create('', []);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfNameIsNotEmpty()
{
Generic::create('', '');
}
/**
* @covers ::create
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfNameContainsIllegalCharacters()
{
Generic::create('', 'name/myname');
}
}

View File

@@ -1,158 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Link
* @covers ::<private>
*/
class LinkTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Link('http://this.is.my/link', new Description('Description'));
$this->assertSame('link', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Link('http://this.is.my/link', new Description('Description'));
$this->assertSame('@link http://this.is.my/link Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Link('http://this.is.my/link', new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getLink
*/
public function testHasLinkUrl()
{
$expected = 'http://this.is.my/link';
$fixture = new Link($expected);
$this->assertSame($expected, $fixture->getLink());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Link('http://this.is.my/link', $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Link('http://this.is.my/link', new Description('Description'));
$this->assertSame('http://this.is.my/link Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$links = 'http://this.is.my/link';
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Link::create('http://this.is.my/link My Description', $descriptionFactory, $context);
$this->assertSame('http://this.is.my/link My Description', (string)$fixture);
$this->assertSame($links, $fixture->getLink());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethodCreatesEmptyLinkTag()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory->shouldReceive('create')->never();
$fixture = Link::create('', $descriptionFactory, new Context(''));
$this->assertSame('', (string)$fixture);
$this->assertSame('', $fixture->getLink());
$this->assertSame(null, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfVersionIsNotString()
{
$this->assertNull(Link::create([]));
}
}

View File

@@ -1,437 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Array_;
use phpDocumentor\Reflection\Types\Compound;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\Integer;
use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\String_;
use phpDocumentor\Reflection\Types\Void_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Method
* @covers ::<private>
*/
class MethodTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Method('myMethod');
$this->assertSame('method', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::isStatic
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$arguments = [
['name' => 'argument1', 'type' => new String_()],
['name' => 'argument2', 'type' => new Object_()]
];
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
$this->assertSame(
'@method static void myMethod(string $argument1, object $argument2) My Description',
$fixture->render()
);
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Method('myMethod');
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getMethodName
*/
public function testHasMethodName()
{
$expected = 'myMethod';
$fixture = new Method($expected);
$this->assertSame($expected, $fixture->getMethodName());
}
/**
* @covers ::__construct
* @covers ::getArguments
*/
public function testHasArguments()
{
$arguments = [
[ 'name' => 'argument1', 'type' => new String_() ]
];
$fixture = new Method('myMethod', $arguments);
$this->assertSame($arguments, $fixture->getArguments());
}
/**
* @covers ::__construct
* @covers ::getArguments
*/
public function testArgumentsMayBePassedAsString()
{
$arguments = ['argument1'];
$expected = [
[ 'name' => $arguments[0], 'type' => new Void_() ]
];
$fixture = new Method('myMethod', $arguments);
$this->assertEquals($expected, $fixture->getArguments());
}
/**
* @covers ::__construct
* @covers ::getArguments
*/
public function testArgumentTypeCanBeInferredAsVoid()
{
$arguments = [ [ 'name' => 'argument1' ] ];
$expected = [
[ 'name' => $arguments[0]['name'], 'type' => new Void_() ]
];
$fixture = new Method('myMethod', $arguments);
$this->assertEquals($expected, $fixture->getArguments());
}
/**
* @covers ::create
*/
public function testRestArgumentIsParsedAsRegularArg()
{
$expected = [
[ 'name' => 'arg1', 'type' => new Void_() ],
[ 'name' => 'rest', 'type' => new Void_() ],
[ 'name' => 'rest2', 'type' => new Array_() ],
];
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = new TypeResolver();
$context = new Context('');
$description = new Description('');
$descriptionFactory->shouldReceive('create')->with('', $context)->andReturn($description);
$fixture = Method::create(
'void myMethod($arg1, ...$rest, array ... $rest2)',
$resolver,
$descriptionFactory,
$context
);
$this->assertEquals($expected, $fixture->getArguments());
}
/**
* @covers ::__construct
* @covers ::getReturnType
*/
public function testHasReturnType()
{
$expected = new String_();
$fixture = new Method('myMethod', [], $expected);
$this->assertSame($expected, $fixture->getReturnType());
}
/**
* @covers ::__construct
* @covers ::getReturnType
*/
public function testReturnTypeCanBeInferredAsVoid()
{
$fixture = new Method('myMethod', []);
$this->assertEquals(new Void_(), $fixture->getReturnType());
}
/**
* @covers ::__construct
* @covers ::isStatic
*/
public function testMethodCanBeStatic()
{
$expected = false;
$fixture = new Method('myMethod', [], null, $expected);
$this->assertSame($expected, $fixture->isStatic());
$expected = true;
$fixture = new Method('myMethod', [], null, $expected);
$this->assertSame($expected, $fixture->isStatic());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Method('myMethod', [], null, false, $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::isStatic
*/
public function testStringRepresentationIsReturned()
{
$arguments = [
['name' => 'argument1', 'type' => new String_()],
['name' => 'argument2', 'type' => new Object_()]
];
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
$this->assertSame(
'static void myMethod(string $argument1, object $argument2) My Description',
(string)$fixture
);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Fqsen
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = new TypeResolver();
$context = new Context('');
$description = new Description('My Description');
$expectedArguments = [
[ 'name' => 'argument1', 'type' => new String_() ],
[ 'name' => 'argument2', 'type' => new Void_() ]
];
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Method::create(
'static void myMethod(string $argument1, $argument2) My Description',
$resolver,
$descriptionFactory,
$context
);
$this->assertSame('static void myMethod(string $argument1, void $argument2) My Description', (string)$fixture);
$this->assertSame('myMethod', $fixture->getMethodName());
$this->assertEquals($expectedArguments, $fixture->getArguments());
$this->assertInstanceOf(Void_::class, $fixture->getReturnType());
$this->assertSame($description, $fixture->getDescription());
}
public function collectionReturnTypesProvider()
{
return [
['int[]', Array_::class, Integer::class, Compound::class],
['int[][]', Array_::class, Array_::class, Compound::class],
['Object[]', Array_::class, Object_::class, Compound::class],
['array[]', Array_::class, Array_::class, Compound::class],
];
}
/**
* @dataProvider collectionReturnTypesProvider
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\Types\Array_
* @uses \phpDocumentor\Reflection\Types\Compound
* @uses \phpDocumentor\Reflection\Types\Integer
* @uses \phpDocumentor\Reflection\Types\Object_
* @param string $returnType
* @param string $expectedType
* @param string $expectedValueType
* @param string null $expectedKeyType
*/
public function testCollectionReturnTypes(
$returnType,
$expectedType,
$expectedValueType = null,
$expectedKeyType = null
) { $resolver = new TypeResolver();
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory->shouldReceive('create')->with('', null)->andReturn(new Description(''));
$fixture = Method::create("$returnType myMethod(\$arg)", $resolver, $descriptionFactory);
$returnType = $fixture->getReturnType();
$this->assertInstanceOf($expectedType, $returnType);
if ($returnType instanceof Array_) {
$this->assertInstanceOf($expectedValueType, $returnType->getValueType());
$this->assertInstanceOf($expectedKeyType, $returnType->getKeyType());
}
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
Method::create([]);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsEmpty()
{
Method::create('');
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodReturnsNullIfBodyIsIncorrect()
{
$this->assertNull(Method::create('body('));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
Method::create('body');
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Method::create('body', new TypeResolver());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testCreationFailsIfBodyIsNotString()
{
new Method([]);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testCreationFailsIfBodyIsEmpty()
{
new Method('');
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testCreationFailsIfStaticIsNotBoolean()
{
new Method('body', [], null, []);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testCreationFailsIfArgumentRecordContainsInvalidEntry()
{
new Method('body', [ [ 'name' => 'myName', 'unknown' => 'nah' ] ]);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Fqsen
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testCreateMethodParenthesisMissing()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = new TypeResolver();
$context = new Context('');
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Method::create(
'static void myMethod My Description',
$resolver,
$descriptionFactory,
$context
);
$this->assertSame('static void myMethod() My Description', (string)$fixture);
$this->assertSame('myMethod', $fixture->getMethodName());
$this->assertEquals([], $fixture->getArguments());
$this->assertInstanceOf(Void_::class, $fixture->getReturnType());
$this->assertSame($description, $fixture->getDescription());
}
}

View File

@@ -1,228 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Param
* @covers ::<private>
*/
class ParamTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Param('myParameter', null, false, new Description('Description'));
$this->assertSame('param', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::isVariadic
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Param('myParameter', new String_(), true, new Description('Description'));
$this->assertSame('@param string ...$myParameter Description', $fixture->render());
$fixture = new Param('myParameter', new String_(), false, new Description('Description'));
$this->assertSame('@param string $myParameter Description', $fixture->render());
$fixture = new Param('myParameter', null, false, new Description('Description'));
$this->assertSame('@param $myParameter Description', $fixture->render());
$fixture = new Param('myParameter');
$this->assertSame('@param $myParameter', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Param('myParameter');
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVariableName
*/
public function testHasVariableName()
{
$expected = 'myParameter';
$fixture = new Param($expected);
$this->assertSame($expected, $fixture->getVariableName());
}
/**
* @covers ::__construct
* @covers ::getType
*/
public function testHasType()
{
$expected = new String_();
$fixture = new Param('myParameter', $expected);
$this->assertSame($expected, $fixture->getType());
}
/**
* @covers ::__construct
* @covers ::isVariadic
*/
public function testIfParameterIsVariadic()
{
$fixture = new Param('myParameter', new String_(), false);
$this->assertFalse($fixture->isVariadic());
$fixture = new Param('myParameter', new String_(), true);
$this->assertTrue($fixture->isVariadic());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Param('1.0', null, false, $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::isVariadic
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Param('myParameter', new String_(), true, new Description('Description'));
$this->assertSame('string ...$myParameter Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$typeResolver = new TypeResolver();
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Param::create('string ...$myParameter My Description', $typeResolver, $descriptionFactory, $context);
$this->assertSame('string ...$myParameter My Description', (string)$fixture);
$this->assertSame('myParameter', $fixture->getVariableName());
$this->assertInstanceOf(String_::class, $fixture->getType());
$this->assertTrue($fixture->isVariadic());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
Param::create('', new TypeResolver(), $descriptionFactory);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
Param::create([]);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
Param::create('body');
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\TypeResolver
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Param::create('body', new TypeResolver());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfVariableNameIsNotString()
{
new Param([]);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfVariadicIsNotBoolean()
{
new Param('', null, []);
}
}

View File

@@ -1,201 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead
* @covers ::<private>
*/
class PropertyReadTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new PropertyRead('myProperty', null, new Description('Description'));
$this->assertSame('property-read', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new PropertyRead('myProperty', new String_(), new Description('Description'));
$this->assertSame('@property-read string $myProperty Description', $fixture->render());
$fixture = new PropertyRead('myProperty', null, new Description('Description'));
$this->assertSame('@property-read $myProperty Description', $fixture->render());
$fixture = new PropertyRead('myProperty');
$this->assertSame('@property-read $myProperty', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new PropertyRead('myProperty');
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVariableName
*/
public function testHasVariableName()
{
$expected = 'myProperty';
$fixture = new PropertyRead($expected);
$this->assertSame($expected, $fixture->getVariableName());
}
/**
* @covers ::__construct
* @covers ::getType
*/
public function testHasType()
{
$expected = new String_();
$fixture = new PropertyRead('myProperty', $expected);
$this->assertSame($expected, $fixture->getType());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new PropertyRead('1.0', null, $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
*/
public function testStringRepresentationIsReturned()
{
$fixture = new PropertyRead('myProperty', new String_(), new Description('Description'));
$this->assertSame('string $myProperty Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$typeResolver = new TypeResolver();
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = PropertyRead::create('string $myProperty My Description', $typeResolver, $descriptionFactory,
$context);
$this->assertSame('string $myProperty My Description', (string)$fixture);
$this->assertSame('myProperty', $fixture->getVariableName());
$this->assertInstanceOf(String_::class, $fixture->getType());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
PropertyRead::create('', new TypeResolver(), $descriptionFactory);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
PropertyRead::create([]);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
PropertyRead::create('body');
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\TypeResolver
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
PropertyRead::create('body', new TypeResolver());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfVariableNameIsNotString()
{
new PropertyRead([]);
}
}

View File

@@ -1,200 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Property
* @covers ::<private>
*/
class PropertyTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Property('myProperty', null, new Description('Description'));
$this->assertSame('property', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Property('myProperty', new String_(), new Description('Description'));
$this->assertSame('@property string $myProperty Description', $fixture->render());
$fixture = new Property('myProperty', null, new Description('Description'));
$this->assertSame('@property $myProperty Description', $fixture->render());
$fixture = new Property('myProperty');
$this->assertSame('@property $myProperty', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Property('myProperty');
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVariableName
*/
public function testHasVariableName()
{
$expected = 'myProperty';
$fixture = new Property($expected);
$this->assertSame($expected, $fixture->getVariableName());
}
/**
* @covers ::__construct
* @covers ::getType
*/
public function testHasType()
{
$expected = new String_();
$fixture = new Property('myProperty', $expected);
$this->assertSame($expected, $fixture->getType());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Property('1.0', null, $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Property('myProperty', new String_(), new Description('Description'));
$this->assertSame('string $myProperty Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$typeResolver = new TypeResolver();
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Property::create('string $myProperty My Description', $typeResolver, $descriptionFactory, $context);
$this->assertSame('string $myProperty My Description', (string)$fixture);
$this->assertSame('myProperty', $fixture->getVariableName());
$this->assertInstanceOf(String_::class, $fixture->getType());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
Property::create('', new TypeResolver(), $descriptionFactory);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
Property::create([]);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
Property::create('body');
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\TypeResolver
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Property::create('body', new TypeResolver());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfVariableNameIsNotString()
{
new Property([]);
}
}

View File

@@ -1,201 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite
* @covers ::<private>
*/
class PropertyWriteTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new PropertyWrite('myProperty', null, new Description('Description'));
$this->assertSame('property-write', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new PropertyWrite('myProperty', new String_(), new Description('Description'));
$this->assertSame('@property-write string $myProperty Description', $fixture->render());
$fixture = new PropertyWrite('myProperty', null, new Description('Description'));
$this->assertSame('@property-write $myProperty Description', $fixture->render());
$fixture = new PropertyWrite('myProperty');
$this->assertSame('@property-write $myProperty', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new PropertyWrite('myProperty');
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVariableName
*/
public function testHasVariableName()
{
$expected = 'myProperty';
$fixture = new PropertyWrite($expected);
$this->assertSame($expected, $fixture->getVariableName());
}
/**
* @covers ::__construct
* @covers ::getType
*/
public function testHasType()
{
$expected = new String_();
$fixture = new PropertyWrite('myProperty', $expected);
$this->assertSame($expected, $fixture->getType());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new PropertyWrite('1.0', null, $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
*/
public function testStringRepresentationIsReturned()
{
$fixture = new PropertyWrite('myProperty', new String_(), new Description('Description'));
$this->assertSame('string $myProperty Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$typeResolver = new TypeResolver();
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = PropertyWrite::create('string $myProperty My Description', $typeResolver, $descriptionFactory,
$context);
$this->assertSame('string $myProperty My Description', (string)$fixture);
$this->assertSame('myProperty', $fixture->getVariableName());
$this->assertInstanceOf(String_::class, $fixture->getType());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
PropertyWrite::create('', new TypeResolver(), $descriptionFactory);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
PropertyWrite::create([]);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
PropertyWrite::create('body');
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\TypeResolver
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
PropertyWrite::create('body', new TypeResolver());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfVariableNameIsNotString()
{
new PropertyWrite([]);
}
}

View File

@@ -1,170 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Return_
* @covers ::<private>
*/
class ReturnTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Return_(new String_(), new Description('Description'));
$this->assertSame('return', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Return_(new String_(), new Description('Description'));
$this->assertSame('@return string Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Return_(new String_(), new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getType
*/
public function testHasType()
{
$expected = new String_();
$fixture = new Return_($expected);
$this->assertSame($expected, $fixture->getType());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Return_(new String_(), $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Return_(new String_(), new Description('Description'));
$this->assertSame('string Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = new TypeResolver();
$context = new Context('');
$type = new String_();
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Return_::create('string My Description', $resolver, $descriptionFactory, $context);
$this->assertSame('string My Description', (string)$fixture);
$this->assertEquals($type, $fixture->getType());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
$this->assertNull(Return_::create([]));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotEmpty()
{
$this->assertNull(Return_::create(''));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
Return_::create('body');
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Return_::create('body', new TypeResolver());
}
}

View File

@@ -1,173 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\See
* @covers ::<private>
*/
class SeeTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('see', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('@see \DateTime Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getReference
*/
public function testHasReferenceToFqsen()
{
$expected = new Fqsen('\DateTime');
$fixture = new See($expected);
$this->assertSame($expected, $fixture->getReference());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new See(new Fqsen('\DateTime'), $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('\DateTime Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Fqsen
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = m::mock(FqsenResolver::class);
$context = new Context('');
$fqsen = new Fqsen('\DateTime');
$description = new Description('My Description');
$descriptionFactory
->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$resolver->shouldReceive('resolve')->with('DateTime', $context)->andReturn($fqsen);
$fixture = See::create('DateTime My Description', $resolver, $descriptionFactory, $context);
$this->assertSame('\DateTime My Description', (string)$fixture);
$this->assertSame($fqsen, $fixture->getReference());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
$this->assertNull(See::create([]));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotEmpty()
{
$this->assertNull(See::create(''));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
See::create('body');
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
See::create('body', new FqsenResolver());
}
}

View File

@@ -1,166 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Since
* @covers ::<private>
*/
class SinceTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Since('1.0', new Description('Description'));
$this->assertSame('since', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Since('1.0', new Description('Description'));
$this->assertSame('@since 1.0 Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Since('1.0', new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVersion
*/
public function testHasVersionNumber()
{
$expected = '1.0';
$fixture = new Since($expected);
$this->assertSame($expected, $fixture->getVersion());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Since('1.0', $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Since('1.0', new Description('Description'));
$this->assertSame('1.0 Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$version = '1.0';
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Since::create('1.0 My Description', $descriptionFactory, $context);
$this->assertSame('1.0 My Description', (string)$fixture);
$this->assertSame($version, $fixture->getVersion());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethodCreatesEmptySinceTag()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory->shouldReceive('create')->never();
$fixture = Since::create('', $descriptionFactory, new Context(''));
$this->assertSame('', (string)$fixture);
$this->assertSame(null, $fixture->getVersion());
$this->assertSame(null, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfSinceIsNotString()
{
$this->assertNull(Since::create([]));
}
/**
* @covers ::create
*/
public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex()
{
$this->assertNull(Since::create('dkhf<'));
}
}

View File

@@ -1,199 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Source
* @covers ::<private>
*/
class SourceTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Source(1, null, new Description('Description'));
$this->assertSame('source', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Source(1, 10, new Description('Description'));
$this->assertSame('@source 1 10 Description', $fixture->render());
$fixture = new Source(1, null, new Description('Description'));
$this->assertSame('@source 1 Description', $fixture->render());
$fixture = new Source(1);
$this->assertSame('@source 1', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Source(1);
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getStartingLine
*/
public function testHasStartingLine()
{
$expected = 1;
$fixture = new Source($expected);
$this->assertSame($expected, $fixture->getStartingLine());
}
/**
* @covers ::__construct
* @covers ::getLineCount
*/
public function testHasLineCount()
{
$expected = 2;
$fixture = new Source(1, $expected);
$this->assertSame($expected, $fixture->getLineCount());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Source('1', null, $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Source(1, 10, new Description('Description'));
$this->assertSame('1 10 Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Source::create('1 10 My Description', $descriptionFactory, $context);
$this->assertSame('1 10 My Description', (string)$fixture);
$this->assertSame(1, $fixture->getStartingLine());
$this->assertSame(10, $fixture->getLineCount());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
Source::create('', $descriptionFactory);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
Source::create([]);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\TypeResolver
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Source::create('1');
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfStartingLineIsNotInteger()
{
new Source('blabla');
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfLineCountIsNotIntegerOrNull()
{
new Source('1', []);
}
}

View File

@@ -1,170 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Throws
* @covers ::<private>
*/
class ThrowsTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Throws(new String_(), new Description('Description'));
$this->assertSame('throws', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Throws(new String_(), new Description('Description'));
$this->assertSame('@throws string Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Throws(new String_(), new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getType
*/
public function testHasType()
{
$expected = new String_();
$fixture = new Throws($expected);
$this->assertSame($expected, $fixture->getType());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Throws(new String_(), $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Throws(new String_(), new Description('Description'));
$this->assertSame('string Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = new TypeResolver();
$context = new Context('');
$type = new String_();
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Throws::create('string My Description', $resolver, $descriptionFactory, $context);
$this->assertSame('string My Description', (string)$fixture);
$this->assertEquals($type, $fixture->getType());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
$this->assertNull(Throws::create([]));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotEmpty()
{
$this->assertNull(Throws::create(''));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
Throws::create('body');
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Throws::create('body', new TypeResolver());
}
}

View File

@@ -1,174 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Uses
* @covers ::<private>
*/
class UsesTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('uses', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('@uses \DateTime Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getReference
*/
public function testHasReferenceToFqsen()
{
$expected = new Fqsen('\DateTime');
$fixture = new Uses($expected);
$this->assertSame($expected, $fixture->getReference());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Uses(new Fqsen('\DateTime'), $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
$this->assertSame('\DateTime Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Fqsen
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$resolver = m::mock(FqsenResolver::class);
$context = new Context('');
$fqsen = new Fqsen('\DateTime');
$description = new Description('My Description');
$descriptionFactory
->shouldReceive('create')->with('My Description', $context)->andReturn($description)
;
$resolver->shouldReceive('resolve')->with('DateTime', $context)->andReturn($fqsen);
$fixture = Uses::create('DateTime My Description', $resolver, $descriptionFactory, $context);
$this->assertSame('\DateTime My Description', (string)$fixture);
$this->assertSame($fqsen, $fixture->getReference());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
$this->assertNull(Uses::create([]));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotEmpty()
{
$this->assertNull(Uses::create(''));
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
Uses::create('body');
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Uses::create('body', new FqsenResolver());
}
}

View File

@@ -1,200 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Var_
* @covers ::<private>
*/
class VarTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Var_('myVariable', null, new Description('Description'));
$this->assertSame('var', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Var_('myVariable', new String_(), new Description('Description'));
$this->assertSame('@var string $myVariable Description', $fixture->render());
$fixture = new Var_('myVariable', null, new Description('Description'));
$this->assertSame('@var $myVariable Description', $fixture->render());
$fixture = new Var_('myVariable');
$this->assertSame('@var $myVariable', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Var_('myVariable');
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVariableName
*/
public function testHasVariableName()
{
$expected = 'myVariable';
$fixture = new Var_($expected);
$this->assertSame($expected, $fixture->getVariableName());
}
/**
* @covers ::__construct
* @covers ::getType
*/
public function testHasType()
{
$expected = new String_();
$fixture = new Var_('myVariable', $expected);
$this->assertSame($expected, $fixture->getType());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Var_('1.0', null, $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\String_
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Var_('myVariable', new String_(), new Description('Description'));
$this->assertSame('string $myVariable Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$typeResolver = new TypeResolver();
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Var_::create('string $myVariable My Description', $typeResolver, $descriptionFactory, $context);
$this->assertSame('string $myVariable My Description', (string)$fixture);
$this->assertSame('myVariable', $fixture->getVariableName());
$this->assertInstanceOf(String_::class, $fixture->getType());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
* @uses \phpDocumentor\Reflection\TypeResolver
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
Var_::create('', new TypeResolver(), $descriptionFactory);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfBodyIsNotString()
{
Var_::create([]);
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfResolverIsNull()
{
Var_::create('body');
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\TypeResolver
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
{
Var_::create('body', new TypeResolver());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfVariableNameIsNotString()
{
new Var_([]);
}
}

View File

@@ -1,166 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Version
* @covers ::<private>
*/
class VersionTest extends \PHPUnit_Framework_TestCase
{
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfCorrectTagNameIsReturned()
{
$fixture = new Version('1.0', new Description('Description'));
$this->assertSame('version', $fixture->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
public function testIfTagCanBeRenderedUsingDefaultFormatter()
{
$fixture = new Version('1.0', new Description('Description'));
$this->assertSame('@version 1.0 Description', $fixture->render());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__construct
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
*/
public function testIfTagCanBeRenderedUsingSpecificFormatter()
{
$fixture = new Version('1.0', new Description('Description'));
$formatter = m::mock(Formatter::class);
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
$this->assertSame('Rendered output', $fixture->render($formatter));
}
/**
* @covers ::__construct
* @covers ::getVersion
*/
public function testHasVersionNumber()
{
$expected = '1.0';
$fixture = new Version($expected);
$this->assertSame($expected, $fixture->getVersion());
}
/**
* @covers ::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testHasDescription()
{
$expected = new Description('Description');
$fixture = new Version('1.0', $expected);
$this->assertSame($expected, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::__toString
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Version('1.0', new Description('Description'));
$this->assertSame('1.0 Description', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethod()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$context = new Context('');
$version = '1.0';
$description = new Description('My Description');
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
$fixture = Version::create('1.0 My Description', $descriptionFactory, $context);
$this->assertSame('1.0 My Description', (string)$fixture);
$this->assertSame($version, $fixture->getVersion());
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testFactoryMethodCreatesEmptyVersionTag()
{
$descriptionFactory = m::mock(DescriptionFactory::class);
$descriptionFactory->shouldReceive('create')->never();
$fixture = Version::create('', $descriptionFactory, new Context(''));
$this->assertSame('', (string)$fixture);
$this->assertSame(null, $fixture->getVersion());
$this->assertSame(null, $fixture->getDescription());
}
/**
* @covers ::create
* @expectedException \InvalidArgumentException
*/
public function testFactoryMethodFailsIfVersionIsNotString()
{
$this->assertNull(Version::create([]));
}
/**
* @covers ::create
*/
public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex()
{
$this->assertNull(Version::create('dkhf<'));
}
}

View File

@@ -1,290 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass phpDocumentor\Reflection\DocBlockFactory
* @covers ::<private>
* @uses \Webmozart\Assert\Assert
* @uses phpDocumentor\Reflection\DocBlock
*/
class DocBlockFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::createInstance
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
*/
public function testCreateFactoryUsingFactoryMethod()
{
$fixture = DocBlockFactory::createInstance();
$this->assertInstanceOf(DocBlockFactory::class, $fixture);
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testCreateDocBlockFromReflection()
{
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
$docBlock = '/** This is a DocBlock */';
$classReflector = m::mock(\ReflectionClass::class);
$classReflector->shouldReceive('getDocComment')->andReturn($docBlock);
$docblock = $fixture->create($classReflector);
$this->assertInstanceOf(DocBlock::class, $docblock);
$this->assertSame('This is a DocBlock', $docblock->getSummary());
$this->assertEquals(new Description(''), $docblock->getDescription());
$this->assertSame([], $docblock->getTags());
$this->assertEquals(new Context(''), $docblock->getContext());
$this->assertNull($docblock->getLocation());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testCreateDocBlockFromStringWithDocComment()
{
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
$docblock = $fixture->create('/** This is a DocBlock */');
$this->assertInstanceOf(DocBlock::class, $docblock);
$this->assertSame('This is a DocBlock', $docblock->getSummary());
$this->assertEquals(new Description(''), $docblock->getDescription());
$this->assertSame([], $docblock->getTags());
$this->assertEquals(new Context(''), $docblock->getContext());
$this->assertNull($docblock->getLocation());
}
/**
* @covers ::create
* @covers ::__construct
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testCreateDocBlockFromStringWithoutDocComment()
{
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
$docblock = $fixture->create('This is a DocBlock');
$this->assertInstanceOf(DocBlock::class, $docblock);
$this->assertSame('This is a DocBlock', $docblock->getSummary());
$this->assertEquals(new Description(''), $docblock->getDescription());
$this->assertSame([], $docblock->getTags());
$this->assertEquals(new Context(''), $docblock->getContext());
$this->assertNull($docblock->getLocation());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
* @dataProvider provideSummaryAndDescriptions
*/
public function testSummaryAndDescriptionAreSeparated($given, $summary, $description)
{
$tagFactory = m::mock(TagFactory::class);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$docblock = $fixture->create($given);
$this->assertSame($summary, $docblock->getSummary());
$this->assertEquals(new Description($description), $docblock->getDescription());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testDescriptionsRetainFormatting()
{
$tagFactory = m::mock(TagFactory::class);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$given = <<<DOCBLOCK
/**
* This is a summary.
* This is a multiline Description
* that contains a code block.
*
* See here: a CodeBlock
*/
DOCBLOCK;
$description = <<<DESCRIPTION
This is a multiline Description
that contains a code block.
See here: a CodeBlock
DESCRIPTION;
$docblock = $fixture->create($given);
$this->assertEquals(new Description($description), $docblock->getDescription());
}
/**
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testTagsAreInterpretedUsingFactory()
{
$tagString = <<<TAG
@author Mike van Riel <me@mikevanriel.com> This is with
multiline description.
TAG;
$tag = m::mock(Tag::class);
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')->with($tagString, m::type(Context::class))->andReturn($tag);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$given = <<<DOCBLOCK
/**
* This is a summary.
*
* @author Mike van Riel <me@mikevanriel.com> This is with
* multiline description.
*/
DOCBLOCK;
$docblock = $fixture->create($given, new Context(''));
$this->assertEquals([$tag], $docblock->getTags());
}
public function provideSummaryAndDescriptions()
{
return [
['This is a DocBlock', 'This is a DocBlock', ''],
[
'This is a DocBlock. This should still be summary.',
'This is a DocBlock. This should still be summary.',
''
],
[
<<<DOCBLOCK
This is a DocBlock.
This should be a Description.
DOCBLOCK
,
'This is a DocBlock.',
'This should be a Description.'
],
[
<<<DOCBLOCK
This is a
multiline Summary.
This should be a Description.
DOCBLOCK
,
"This is a\nmultiline Summary.",
'This should be a Description.'
],
[
<<<DOCBLOCK
This is a Summary without dot but with a whiteline
This should be a Description.
DOCBLOCK
,
'This is a Summary without dot but with a whiteline',
'This should be a Description.'
],
[
<<<DOCBLOCK
This is a Summary with dot and with a whiteline.
This should be a Description.
DOCBLOCK
,
'This is a Summary with dot and with a whiteline.',
'This should be a Description.'
],
];
}
/**
* @covers ::__construct
* @covers ::create
*
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\Types\Context
* @uses phpDocumentor\Reflection\DocBlock\Tags\Param
*/
public function testTagsWithContextNamespace()
{
$tagFactoryMock = m::mock(TagFactory::class);
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), $tagFactoryMock);
$context = new Context('MyNamespace');
$tagFactoryMock->shouldReceive('create')->with(m::any(), $context)->andReturn(new Param('param'));
$docblock = $fixture->create('/** @param MyType $param */', $context);
}
/**
* @covers ::__construct
* @covers ::create
*
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testTagsAreFilteredForNullValues()
{
$tagString = <<<TAG
@author Mike van Riel <me@mikevanriel.com> This is with
multiline description.
TAG;
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')->with($tagString, m::any())->andReturn(null);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$given = <<<DOCBLOCK
/**
* This is a summary.
*
* @author Mike van Riel <me@mikevanriel.com> This is with
* multiline description.
*/
DOCBLOCK;
$docblock = $fixture->create($given, new Context(''));
$this->assertEquals([], $docblock->getTags());
}
}

View File

@@ -1,252 +0,0 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use Mockery as m;
use phpDocumentor\Reflection\Types\Context;
/**
* @coversDefaultClass phpDocumentor\Reflection\DocBlock
* @covers ::<private>
* @uses \Webmozart\Assert\Assert
*/
class DocBlockTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::getSummary
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testDocBlockCanHaveASummary()
{
$summary = 'This is a summary';
$fixture = new DocBlock($summary);
$this->assertSame($summary, $fixture->getSummary());
}
/**
* @covers ::__construct
*
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfSummaryIsNotAString()
{
new DocBlock([]);
}
/**
* @covers ::__construct
*
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfTemplateStartIsNotABoolean()
{
new DocBlock('', null, [], null, null, ['is not boolean']);
}
/**
* @covers ::__construct
*
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfTemplateEndIsNotABoolean()
{
new DocBlock('', null, [], null, null, false, ['is not boolean']);
}
/**
* @covers ::__construct
* @covers ::getDescription
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testDocBlockCanHaveADescription()
{
$description = new DocBlock\Description('');
$fixture = new DocBlock('', $description);
$this->assertSame($description, $fixture->getDescription());
}
/**
* @covers ::__construct
* @covers ::getTags
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tag
*/
public function testDocBlockCanHaveTags()
{
$tags = [
m::mock(DocBlock\Tag::class)
];
$fixture = new DocBlock('', null, $tags);
$this->assertSame($tags, $fixture->getTags());
}
/**
* @covers ::__construct
* @covers ::getTags
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tag
*
* @expectedException \InvalidArgumentException
*/
public function testDocBlockAllowsOnlyTags()
{
$tags = [
null
];
$fixture = new DocBlock('', null, $tags);
}
/**
* @covers ::__construct
* @covers ::getTagsByName
*
* @uses \phpDocumentor\Reflection\DocBlock::getTags
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tag
*/
public function testFindTagsInDocBlockByName()
{
$tag1 = m::mock(DocBlock\Tag::class);
$tag2 = m::mock(DocBlock\Tag::class);
$tag3 = m::mock(DocBlock\Tag::class);
$tags = [$tag1, $tag2, $tag3];
$tag1->shouldReceive('getName')->andReturn('abc');
$tag2->shouldReceive('getName')->andReturn('abcd');
$tag3->shouldReceive('getName')->andReturn('ab');
$fixture = new DocBlock('', null, $tags);
$this->assertSame([$tag2], $fixture->getTagsByName('abcd'));
$this->assertSame([], $fixture->getTagsByName('Ebcd'));
}
/**
* @covers ::__construct
* @covers ::getTagsByName
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfNameForTagsIsNotString()
{
$fixture = new DocBlock();
$fixture->getTagsByName([]);
}
/**
* @covers ::__construct
* @covers ::hasTag
*
* @uses \phpDocumentor\Reflection\DocBlock::getTags
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tag
*/
public function testCheckIfThereAreTagsWithAGivenName()
{
$tag1 = m::mock(DocBlock\Tag::class);
$tag2 = m::mock(DocBlock\Tag::class);
$tag3 = m::mock(DocBlock\Tag::class);
$tags = [$tag1, $tag2, $tag3];
$tag1->shouldReceive('getName')->twice()->andReturn('abc');
$tag2->shouldReceive('getName')->twice()->andReturn('abcd');
$tag3->shouldReceive('getName')->once();
$fixture = new DocBlock('', null, $tags);
$this->assertTrue($fixture->hasTag('abcd'));
$this->assertFalse($fixture->hasTag('Ebcd'));
}
/**
* @covers ::__construct
* @covers ::hasTag
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @expectedException \InvalidArgumentException
*/
public function testExceptionIsThrownIfNameForCheckingTagsIsNotString()
{
$fixture = new DocBlock();
$fixture->hasTag([]);
}
/**
* @covers ::__construct
* @covers ::getContext
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*/
public function testDocBlockKnowsInWhichNamespaceItIsAndWhichAliasesThereAre()
{
$context = new Context('');
$fixture = new DocBlock('', null, [], $context);
$this->assertSame($context, $fixture->getContext());
}
/**
* @covers ::__construct
* @covers ::getLocation
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Location
*/
public function testDocBlockKnowsAtWhichLineItIs()
{
$location = new Location(10);
$fixture = new DocBlock('', null, [], null, $location);
$this->assertSame($location, $fixture->getLocation());
}
/**
* @covers ::__construct
* @covers ::isTemplateStart
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testDocBlockKnowsIfItIsTheStartOfADocBlockTemplate()
{
$fixture = new DocBlock('', null, [], null, null, true);
$this->assertTrue($fixture->isTemplateStart());
}
/**
* @covers ::__construct
* @covers ::isTemplateEnd
*
* @uses \phpDocumentor\Reflection\DocBlock\Description
*/
public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate()
{
$fixture = new DocBlock('', null, [], null, null, false, true);
$this->assertTrue($fixture->isTemplateEnd());
}
}

View File

@@ -1,3 +0,0 @@
.idea
composer.lock
vendor

View File

@@ -1,31 +0,0 @@
before_commands:
- "composer install --no-dev --prefer-source"
tools:
external_code_coverage: true
php_code_sniffer:
config:
standard: PSR2
filter:
paths: ["src/*", "tests/*"]
php_cpd:
enabled: true
excluded_dirs: ["tests", "vendor"]
php_loc:
enabled: true
excluded_dirs: ["tests", "vendor"]
php_mess_detector:
enabled: true
config:
ruleset: phpmd.xml.dist
design_rules: { eval_expression: false }
filter:
paths: ["src/*"]
php_pdepend:
enabled: true
excluded_dirs: ["tests", "vendor"]
php_analyzer:
enabled: true
filter:
paths: ["src/*", "tests/*"]
sensiolabs_security_checker: true

View File

@@ -61,8 +61,10 @@ Where the FqsenResolver can resolve:
In order to resolve a type you will have to instantiate the class `\phpDocumentor\Reflection\TypeResolver`
and call its `resolve` method like this:
$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
$type = $typeResolver->resolve('string|integer');
```php
$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
$type = $typeResolver->resolve('string|integer');
```
In this example you will receive a Value Object of class `\phpDocumentor\Reflection\Types\Compound` that has two
elements, one of type `\phpDocumentor\Reflection\Types\String_` and one of type
@@ -77,8 +79,10 @@ in which namespace the given expression occurs and which namespace aliases (or i
A Fully Qualified Structural Element Name is a reference to another element in your code bases and can be resolved using
the `\phpDocumentor\Reflection\FqsenResolver` class' `resolve` method, like this:
$fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
$fqsen = $fqsenResolver->resolve('\phpDocumentor\Reflection\FqsenResolver::resolve()');
```php
$fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
$fqsen = $fqsenResolver->resolve('\phpDocumentor\Reflection\FqsenResolver::resolve()');
```
In this example we resolve a Fully Qualified Structural Element Name (meaning that it includes the full namespace, class
name and element name) and receive a Value Object of type `\phpDocumentor\Reflection\Fqsen`.
@@ -95,7 +99,6 @@ names.
For example, you have this file:
```php
<?php
namespace My\Example;
use phpDocumentor\Reflection\Types;
@@ -121,22 +124,28 @@ play.
You can do this by manually creating a Context like this:
$context = new \phpDocumentor\Reflection\Types\Context(
'\My\Example',
[ 'Types' => '\phpDocumentor\Reflection\Types']
);
```php
$context = new \phpDocumentor\Reflection\Types\Context(
'\My\Example',
[ 'Types' => '\phpDocumentor\Reflection\Types']
);
```
Or by using the `\phpDocumentor\Reflection\Types\ContextFactory` to instantiate a new context based on a Reflector
object or by providing the namespace that you'd like to extract and the source code of the file in which the given
type expression occurs.
$contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
$context = $contextFactory->createFromReflector(new ReflectionMethod('\My\Example\Classy', '__construct'));
```php
$contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
$context = $contextFactory->createFromReflector(new ReflectionMethod('\My\Example\Classy', '__construct'));
```
or
$contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
$context = $contextFactory->createForNamespace('\My\Example', file_get_contents('My/Example/Classy.php'));
```php
$contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
$context = $contextFactory->createForNamespace('\My\Example', file_get_contents('My/Example/Classy.php'));
```
### Using the Context
@@ -145,8 +154,10 @@ class as second argument and the Resolvers will take this into account when reso
To obtain the resolved class name for the `@var` tag in the example above you can do:
$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
$type = $typeResolver->resolve('Types\Context', $context);
```php
$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
$type = $typeResolver->resolve('Types\Context', $context);
```
When you do this you will receive an object of class `\phpDocumentor\Reflection\Types\Object_` for which you can call
the `getFqsen` method to receive a Value Object that represents the complete FQSEN. So that would be
@@ -161,8 +172,10 @@ the `getFqsen` method to receive a Value Object that represents the complete FQS
Another example is on how to resolve the FQSEN of a method as can be seen with the `@see` tag in the example above. To
resolve that you can do the following:
$fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
$type = $fqsenResolver->resolve('Classy::otherFunction()', $context);
```php
$fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
$type = $fqsenResolver->resolve('Classy::otherFunction()', $context);
```
Because Classy is a Class in the current namespace its FQSEN will have the `My\Example` namespace and by calling the
`resolve` method of the FQSEN Resolver you will receive an `Fqsen` object that refers to

View File

@@ -6,7 +6,7 @@
{"name": "Mike van Riel", "email": "me@mikevanriel.com"}
],
"require": {
"php": ">=5.5",
"php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0"
},
"autoload": {

View File

@@ -1,13 +0,0 @@
<?php
use phpDocumentor\Reflection\TypeResolver;
require '../vendor/autoload.php';
$typeResolver = new TypeResolver();
// Will yield an object of type phpDocumentor\Types\Compound
var_export($typeResolver->resolve('string|integer'));
// Will return the string "string|int"
var_dump((string)$typeResolver->resolve('string|integer'));

View File

@@ -1,12 +0,0 @@
<?php
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\TypeResolver;
require '../vendor/autoload.php';
$typeResolver = new TypeResolver();
// Will use the namespace and aliases to resolve to \phpDocumentor\Types\Resolver|Mockery\MockInterface
$context = new Context('\phpDocumentor', [ 'm' => 'Mockery' ]);
var_dump((string)$typeResolver->resolve('Types\Resolver|m\MockInterface', $context));

View File

@@ -1,17 +0,0 @@
<?php
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\FqsenResolver;
require '../vendor/autoload.php';
$fqsenResolver = new FqsenResolver();
// Will use the namespace and aliases to resolve to a Fqsen object
$context = new Context('\phpDocumentor\Types');
// Method named: \phpDocumentor\Types\Types\Resolver::resolveFqsen()
var_dump((string)$fqsenResolver->resolve('Types\Resolver::resolveFqsen()', $context));
// Property named: \phpDocumentor\Types\Types\Resolver::$keyWords
var_dump((string)$fqsenResolver->resolve('Types\Resolver::$keyWords', $context));

View File

@@ -1,30 +0,0 @@
<?php
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\ContextFactory;
require '../vendor/autoload.php';
require 'Classy.php';
$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();
$contextFactory = new ContextFactory();
$context = $contextFactory->createFromReflector(new ReflectionClass('My\\Example\\Classy'));
// Class named: \phpDocumentor\Reflection\Types\Resolver
var_dump((string)$typeResolver->resolve('Types\Resolver', $context));
// String
var_dump((string)$typeResolver->resolve('string', $context));
// Property named: \phpDocumentor\Reflection\Types\Resolver::$keyWords
var_dump((string)$fqsenResolver->resolve('Types\Resolver::$keyWords', $context));
// Class named: \My\Example\string
// - Shows the difference between the FqsenResolver and TypeResolver; the FqsenResolver will assume
// that the given value is not a type but most definitely a reference to another element. This is
// because conflicts between type keywords and class names can exist and if you know a reference
// is not a type but an element you can force that keywords are resolved.
var_dump((string)$fqsenResolver->resolve('string', $context));

View File

@@ -1,30 +0,0 @@
<?php
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\ContextFactory;
require '../vendor/autoload.php';
require 'Classy.php';
$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();
$contextFactory = new ContextFactory();
$context = $contextFactory->createFromReflector(new ReflectionMethod('My\\Example\\Classy', '__construct'));
// Class named: \phpDocumentor\Reflection\Types\Resolver
var_dump((string)$typeResolver->resolve('Types\Resolver', $context));
// String
var_dump((string)$typeResolver->resolve('string', $context));
// Property named: \phpDocumentor\Reflection\Types\Resolver::$keyWords
var_dump((string)$fqsenResolver->resolve('Types\Resolver::$keyWords', $context));
// Class named: \My\Example\string
// - Shows the difference between the FqsenResolver and TypeResolver; the FqsenResolver will assume
// that the given value is not a type but most definitely a reference to another element. This is
// because conflicts between type keywords and class names can exist and if you know a reference
// is not a type but an element you can force that keywords are resolved.
var_dump((string)$fqsenResolver->resolve('string', $context));

View File

@@ -1,22 +0,0 @@
<?php
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\ContextFactory;
require '../vendor/autoload.php';
$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();
$contextFactory = new ContextFactory();
$context = $contextFactory->createForNamespace('My\Example', file_get_contents('Classy.php'));
// Class named: \phpDocumentor\Reflection\Types\Resolver
var_dump((string)$typeResolver->resolve('Types\Resolver', $context));
// String
var_dump((string)$typeResolver->resolve('string', $context));
// Property named: \phpDocumentor\Reflection\Types\Resolver::$keyWords
var_dump((string)$fqsenResolver->resolve('Types\Resolver::$keyWords', $context));

View File

@@ -1,16 +0,0 @@
<?php
namespace My\Example;
use Mockery as m;
use phpDocumentor\Reflection\Types;
class Classy
{
/**
* @var Types\Context
*/
public function __construct($context)
{
}
}

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset
name="ProxyManager rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
>
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
<rule ref="rulesets/design.xml">
<!-- eval is needed to generate runtime classes -->
<exclude name="EvalExpression"/>
</rule>
<rule ref="rulesets/naming.xml">
<exclude name="LongVariable"/>
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<property name="minimum">40</property>
</properties>
</rule>
</ruleset>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit
colors="true"
checkForUnintentionallyCoveredCode="true"
beStrictAboutOutputDuringTests="true"
forceCoversAnnotation="true"
verbose="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
<blacklist>
<directory>./examples/</directory>
<directory>./vendor/</directory>
</blacklist>
</filter>
<listeners>
<listener
class="Mockery\Adapter\Phpunit\TestListener"
file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php"
/>
</listeners>
</phpunit>

View File

@@ -52,6 +52,7 @@ class FqsenResolver
* @param Context $context
*
* @return Fqsen
* @throws \InvalidArgumentException when type is not a valid FQSEN.
*/
private function resolvePartialStructuralElementName($type, Context $context)
{

View File

@@ -15,6 +15,8 @@ namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\Types\Array_;
use phpDocumentor\Reflection\Types\Compound;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\Iterable_;
use phpDocumentor\Reflection\Types\Nullable;
use phpDocumentor\Reflection\Types\Object_;
final class TypeResolver
@@ -27,27 +29,29 @@ final class TypeResolver
/** @var string[] List of recognized keywords and unto which Value Object they map */
private $keywords = array(
'string' => 'phpDocumentor\Reflection\Types\String_',
'int' => 'phpDocumentor\Reflection\Types\Integer',
'integer' => 'phpDocumentor\Reflection\Types\Integer',
'bool' => 'phpDocumentor\Reflection\Types\Boolean',
'boolean' => 'phpDocumentor\Reflection\Types\Boolean',
'float' => 'phpDocumentor\Reflection\Types\Float_',
'double' => 'phpDocumentor\Reflection\Types\Float_',
'object' => 'phpDocumentor\Reflection\Types\Object_',
'mixed' => 'phpDocumentor\Reflection\Types\Mixed',
'array' => 'phpDocumentor\Reflection\Types\Array_',
'resource' => 'phpDocumentor\Reflection\Types\Resource',
'void' => 'phpDocumentor\Reflection\Types\Void_',
'null' => 'phpDocumentor\Reflection\Types\Null_',
'scalar' => 'phpDocumentor\Reflection\Types\Scalar',
'callback' => 'phpDocumentor\Reflection\Types\Callable_',
'callable' => 'phpDocumentor\Reflection\Types\Callable_',
'false' => 'phpDocumentor\Reflection\Types\Boolean',
'true' => 'phpDocumentor\Reflection\Types\Boolean',
'self' => 'phpDocumentor\Reflection\Types\Self_',
'$this' => 'phpDocumentor\Reflection\Types\This',
'static' => 'phpDocumentor\Reflection\Types\Static_'
'string' => Types\String_::class,
'int' => Types\Integer::class,
'integer' => Types\Integer::class,
'bool' => Types\Boolean::class,
'boolean' => Types\Boolean::class,
'float' => Types\Float_::class,
'double' => Types\Float_::class,
'object' => Object_::class,
'mixed' => Types\Mixed_::class,
'array' => Array_::class,
'resource' => Types\Resource_::class,
'void' => Types\Void_::class,
'null' => Types\Null_::class,
'scalar' => Types\Scalar::class,
'callback' => Types\Callable_::class,
'callable' => Types\Callable_::class,
'false' => Types\Boolean::class,
'true' => Types\Boolean::class,
'self' => Types\Self_::class,
'$this' => Types\This::class,
'static' => Types\Static_::class,
'parent' => Types\Parent_::class,
'iterable' => Iterable_::class,
);
/** @var FqsenResolver */
@@ -100,6 +104,8 @@ final class TypeResolver
}
switch (true) {
case $this->isNullableType($type):
return $this->resolveNullableType($type, $context);
case $this->isKeyword($type):
return $this->resolveKeyword($type);
case ($this->isCompoundType($type)):
@@ -206,6 +212,18 @@ final class TypeResolver
return strpos($type, '|') !== false;
}
/**
* Test whether the given type is a nullable type (i.e. `?string`)
*
* @param string $type
*
* @return bool
*/
private function isNullableType($type)
{
return $type[0] === '?';
}
/**
* Resolves the given typed array string (i.e. `string[]`) into an Array object with the right types set.
*
@@ -237,6 +255,7 @@ final class TypeResolver
* Resolves the given FQSEN string into an FQSEN object.
*
* @param string $type
* @param Context|null $context
*
* @return Object_
*/
@@ -263,4 +282,17 @@ final class TypeResolver
return new Compound($types);
}
/**
* Resolve nullable types (i.e. `?string`) into a Nullable type wrapper
*
* @param string $type
* @param Context $context
*
* @return Nullable
*/
private function resolveNullableType($type, Context $context)
{
return new Nullable($this->resolve(ltrim($type, '?'), $context));
}
}

View File

@@ -12,7 +12,6 @@
namespace phpDocumentor\Reflection\Types;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\Type;
/**
@@ -20,7 +19,7 @@ use phpDocumentor\Reflection\Type;
*
* An array can be represented in two forms:
*
* 1. Untyped (`array`), where the key and value type is unknown and hence classified as 'Mixed'.
* 1. Untyped (`array`), where the key and value type is unknown and hence classified as 'Mixed_'.
* 2. Types (`string[]`), where the value type is provided by preceding an opening and closing square bracket with a
* type name.
*/
@@ -44,7 +43,7 @@ final class Array_ implements Type
$keyType = new Compound([ new String_(), new Integer() ]);
}
if ($valueType === null) {
$valueType = new Mixed();
$valueType = new Mixed_();
}
$this->valueType = $valueType;
@@ -78,7 +77,7 @@ final class Array_ implements Type
*/
public function __toString()
{
if ($this->valueType instanceof Mixed) {
if ($this->valueType instanceof Mixed_) {
return 'array';
}

View File

@@ -12,6 +12,8 @@
namespace phpDocumentor\Reflection\Types;
use ArrayIterator;
use IteratorAggregate;
use phpDocumentor\Reflection\Type;
/**
@@ -21,15 +23,16 @@ use phpDocumentor\Reflection\Type;
* using an OR operator (`|`). This combination of types signifies that whatever is associated with this compound type
* may contain a value with any of the given types.
*/
final class Compound implements Type
final class Compound implements Type, IteratorAggregate
{
/** @var Type[] */
private $types = [];
private $types;
/**
* Initializes a compound type (i.e. `string|int`) and tests if the provided types all implement the Type interface.
*
* @param Type[] $types
* @throws \InvalidArgumentException when types are not all instance of Type
*/
public function __construct(array $types)
{
@@ -79,4 +82,12 @@ final class Compound implements Type
{
return implode('|', $this->types);
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
return new ArrayIterator($this->types);
}
}

View File

@@ -29,10 +29,10 @@ namespace phpDocumentor\Reflection\Types;
final class Context
{
/** @var string The current namespace. */
private $namespace = '';
private $namespace;
/** @var array List of namespace aliases => Fully Qualified Namespace. */
private $namespaceAliases = [];
private $namespaceAliases;
/**
* Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN)
@@ -51,7 +51,7 @@ final class Context
if ($fqnn[0] === '\\') {
$fqnn = substr($fqnn, 1);
}
if ($fqnn[count($fqnn)-1] === '\\') {
if ($fqnn[strlen($fqnn) - 1] === '\\') {
$fqnn = substr($fqnn, 0, -1);
}

View File

@@ -32,7 +32,7 @@ final class ContextFactory
/**
* Build a Context given a Class Reflection.
*
* @param \ReflectionClass $reflector
* @param \Reflector $reflector
*
* @see Context for more information on Contexts.
*

View File

@@ -0,0 +1,31 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2017 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Types;
use phpDocumentor\Reflection\Type;
/**
* Value Object representing iterable type
*/
final class Iterable_ implements Type
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*
* @return string
*/
public function __toString()
{
return 'iterable';
}
}

View File

@@ -17,7 +17,7 @@ use phpDocumentor\Reflection\Type;
/**
* Value Object representing an unknown, or mixed, type.
*/
final class Mixed implements Type
final class Mixed_ implements Type
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.

View File

@@ -0,0 +1,56 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2017 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Types;
use phpDocumentor\Reflection\Type;
/**
* Value Object representing a nullable type. The real type is wrapped.
*/
final class Nullable implements Type
{
/**
* @var Type
*/
private $realType;
/**
* Initialises this nullable type using the real type embedded
*
* @param Type $realType
*/
public function __construct(Type $realType)
{
$this->realType = $realType;
}
/**
* Provide access to the actual type directly, if needed.
*
* @return Type
*/
public function getActualType()
{
return $this->realType;
}
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*
* @return string
*/
public function __toString()
{
return '?' . $this->realType->__toString();
}
}

Some files were not shown because too many files have changed in this diff Show More