pax_global_header00006660000000000000000000000064136007452370014521gustar00rootroot0000000000000052 comment=65f4ef719ef436f4e976eb43d626fad0d052daf3 php-phpdocumentor-reflection-docblock-4.3.3/000077500000000000000000000000001360074523700211125ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/.coveralls.yml000066400000000000000000000001171360074523700237040ustar00rootroot00000000000000service_name: travis-ci coverage_clover: coverage.xml json_path: coverage.json php-phpdocumentor-reflection-docblock-4.3.3/.gitignore000066400000000000000000000000321360074523700230750ustar00rootroot00000000000000.idea vendor /build /temp php-phpdocumentor-reflection-docblock-4.3.3/.travis.yml000066400000000000000000000023711360074523700232260ustar00rootroot00000000000000language: php env: global: - COMPOSER_FLAGS="--no-interaction" matrix: include: - php: 7.0 env: # Test commited lock file - COMPOSER_LOCK=true - php: 7.1 env: # Test lowest dependencies - COMPOSER_FLAGS="--no-interaction --prefer-lowest" # Test code standard - STATIC_ANALYSIS=true # Test with updated dependencies - php: 7.2 - php: 7.3 - php: 7.4 fast_finish: true cache: directories: - $HOME/.composer/cache install: - | if [[ $COMPOSER_LOCK = true ]]; then composer install $COMPOSER_FLAGS else composer update $COMPOSER_FLAGS fi - composer $COMPOSER # coding style - if [[ $STATIC_ANALYSIS != "" ]]; then composer create-project symplify/easy-coding-standard:v2.5.9 temp/ecs; fi script: - vendor/bin/phpunit --coverage-clover=coverage.xml -v # coding style - if [[ $STATIC_ANALYSIS != "" ]]; then temp/ecs/bin/ecs check src tests; fi after_script: - wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; - php coveralls.phar --verbose; notifications: irc: "irc.freenode.org#phpdocumentor" email: - mike.vanriel@naenius.com - ashnazg@php.net - boen.robot@gmail.com php-phpdocumentor-reflection-docblock-4.3.3/LICENSE000066400000000000000000000020701360074523700221160ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2010 Mike van Riel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. php-phpdocumentor-reflection-docblock-4.3.3/README.md000066400000000000000000000041651360074523700223770ustar00rootroot00000000000000The ReflectionDocBlock Component [![Build Status](https://secure.travis-ci.org/phpDocumentor/ReflectionDocBlock.png)](https://travis-ci.org/phpDocumentor/ReflectionDocBlock) ================================ Introduction ------------ The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest). With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock. Installation ------------ ```bash composer require phpdocumentor/reflection-docblock ``` Usage ----- In order to parse the DocBlock one needs a DocBlockFactory that can be instantiated using its `createInstance` factory method like this: ```php $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); ``` Then we can use the `create` method of the factory to interpret the DocBlock. Please note that it is also possible to provide a class that has the `getDocComment()` method, such as an object of type `ReflectionClass`, the create method will read that if it exists. ```php $docComment = <<create($docComment); ``` The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock` whose methods can be queried: ```php // Contains the summary for this DocBlock $summary = $docblock->getSummary(); // 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](/examples). php-phpdocumentor-reflection-docblock-4.3.3/appveyor.yml000066400000000000000000000035541360074523700235110ustar00rootroot00000000000000build: false clone_folder: c:\reflectiondocblock max_jobs: 3 platform: x86 pull_requests: do_not_increment_build_number: true version: '{build}.{branch}' skip_tags: true branches: only: - master environment: matrix: - php_ver_target: 7.1 - php_ver_target: 7.2 matrix: fast_finish: false cache: - c:\php -> appveyor.yml - '%LOCALAPPDATA%\Composer\files' init: - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH% - SET COMPOSER_NO_INTERACTION=1 - SET PHP=1 - SET ANSICON=121x90 (121x90) install: - IF EXIST c:\tools\php (SET PHP=0) - ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php_ver_target | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','') - cd c:\tools\php - IF %PHP%==1 copy /Y php.ini-development php.ini - IF %PHP%==1 echo max_execution_time=1200 >> php.ini - IF %PHP%==1 echo date.timezone="UTC" >> php.ini - IF %PHP%==1 echo extension_dir=ext >> php.ini - IF %PHP%==1 echo extension=php_curl.dll >> php.ini - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini - IF %PHP%==1 echo zend.assertions=1 >> php.ini - IF %PHP%==1 echo assert.exception=On >> php.ini - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat - appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar - cd c:\reflectiondocblock - composer install --no-interaction --prefer-dist --no-progress - composer global require phpunit/phpunit ^6 - composer global config bin-dir --absolute test_script: - cd c:\reflectiondocblock - c:\Users\appveyor\AppData\Roaming\Composer\vendor\bin\phpunit --no-coverage php-phpdocumentor-reflection-docblock-4.3.3/composer.json000066400000000000000000000017611360074523700236410ustar00rootroot00000000000000{ "name": "phpdocumentor/reflection-docblock", "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "type": "library", "license": "MIT", "authors": [ { "name": "Mike van Riel", "email": "me@mikevanriel.com" } ], "require": { "php": "^7.0", "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "autoload": { "psr-4": {"phpDocumentor\\Reflection\\": ["src/"]} }, "autoload-dev": { "psr-4": {"phpDocumentor\\Reflection\\": ["tests/unit"]} }, "require-dev": { "mockery/mockery": "^1.0", "phpunit/phpunit": "^6.4", "doctrine/instantiator": "^1.0.5" }, "extra": { "branch-alias": { "dev-master": "4.x-dev" } } } php-phpdocumentor-reflection-docblock-4.3.3/composer.lock000066400000000000000000001523251360074523700236230ustar00rootroot00000000000000{ "_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" ], "content-hash": "f69122debe760b39f6a8eb6eb737b30a", "packages": [ { "name": "phpdocumentor/reflection-common", "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { "php": ">=5.5" }, "require-dev": { "phpunit/phpunit": "^4.6" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ "src" ] } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Jaap van Otterdijk", "email": "opensource@ijaap.nl" } ], "description": "Common reflection classes used by phpdocumentor to reflect the code structure", "homepage": "http://www.phpdoc.org", "keywords": [ "FQSEN", "phpDocumentor", "phpdoc", "reflection", "static analysis" ], "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/type-resolver", "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { "php": "^5.5 || ^7.0", "phpdocumentor/reflection-common": "^1.0" }, "require-dev": { "mockery/mockery": "^0.9.4", "phpunit/phpunit": "^5.2||^4.8.24" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ "src/" ] } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Mike van Riel", "email": "me@mikevanriel.com" } ], "time": "2017-07-14T14:27:02+00:00" }, { "name": "webmozart/assert", "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0" }, "require-dev": { "phpunit/phpunit": "^4.6", "sebastian/version": "^1.0.1" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.3-dev" } }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Bernhard Schussek", "email": "bschussek@gmail.com" } ], "description": "Assertions to validate method input/output with nice error messages.", "keywords": [ "assert", "check", "validate" ], "time": "2016-11-23T20:04:58+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { "php": ">=5.3,<8.0-DEV" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", "phpunit/phpunit": "~4.0", "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Marco Pivetta", "email": "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": "2015-06-14T21:17:01+00:00" }, { "name": "hamcrest/hamcrest-php", "version": "v2.0.0", "source": { "type": "git", "url": "https://github.com/hamcrest/hamcrest-php.git", "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad", "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad", "shasum": "" }, "require": { "php": "^5.3|^7.0" }, "replace": { "cordoval/hamcrest-php": "*", "davedevelopment/hamcrest-php": "*", "kodova/hamcrest-php": "*" }, "require-dev": { "phpunit/php-file-iterator": "1.3.3", "phpunit/phpunit": "~4.0", "satooshi/php-coveralls": "^1.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "2.0-dev" } }, "autoload": { "classmap": [ "hamcrest" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD" ], "description": "This is the PHP port of Hamcrest Matchers", "keywords": [ "test" ], "time": "2016-01-20T08:20:44+00:00" }, { "name": "mockery/mockery", "version": "1.0", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/mockery/mockery/zipball/1bac8c362b12f522fdd1f1fa3556284c91affa38", "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38", "shasum": "" }, "require": { "hamcrest/hamcrest-php": "~2.0", "lib-pcre": ">=7.0", "php": ">=5.6.0" }, "require-dev": { "phpunit/phpunit": "~5.7|~6.1" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-0": { "Mockery": "library/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Pádraic Brady", "email": "padraic.brady@gmail.com", "homepage": "http://blog.astrumfutura.com" }, { "name": "Dave Marshall", "email": "dave.marshall@atstsolutions.co.uk", "homepage": "http://davedevelopment.co.uk" } ], "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", "homepage": "http://github.com/mockery/mockery", "keywords": [ "BDD", "TDD", "library", "mock", "mock objects", "mockery", "stub", "test", "test double", "testing" ], "time": "2017-10-06T16:20:43+00:00" }, { "name": "myclabs/deep-copy", "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", "shasum": "" }, "require": { "php": "^5.6 || ^7.0" }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", "phpunit/phpunit": "^4.1" }, "type": "library", "autoload": { "psr-4": { "DeepCopy\\": "src/DeepCopy/" }, "files": [ "src/DeepCopy/deep_copy.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Create deep copies (clones) of your objects", "keywords": [ "clone", "copy", "duplicate", "object", "object graph" ], "time": "2017-10-19T19:58:43+00:00" }, { "name": "phar-io/manifest", "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", "shasum": "" }, "require": { "ext-dom": "*", "ext-phar": "*", "phar-io/version": "^1.0.1", "php": "^5.6 || ^7.0" }, "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": "Arne Blankerts", "email": "arne@blankerts.de", "role": "Developer" }, { "name": "Sebastian Heuer", "email": "sebastian@phpeople.de", "role": "Developer" }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de", "role": "Developer" } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "time": "2017-03-05T18:14:27+00:00" }, { "name": "phar-io/version", "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", "shasum": "" }, "require": { "php": "^5.6 || ^7.0" }, "type": "library", "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Arne Blankerts", "email": "arne@blankerts.de", "role": "Developer" }, { "name": "Sebastian Heuer", "email": "sebastian@phpeople.de", "role": "Developer" }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de", "role": "Developer" } ], "description": "Library for handling version information and constraints", "time": "2017-03-05T17:38:23+00:00" }, { "name": "phpspec/prophecy", "version": "v1.7.2", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", "sebastian/comparator": "^1.1|^2.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", "phpunit/phpunit": "^4.8 || ^5.6.5" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.7.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": "2017-09-04T11:05:03+00:00" }, { "name": "phpunit/php-code-coverage", "version": "5.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d", "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", "php": "^7.0", "phpunit/php-file-iterator": "^1.4.2", "phpunit/php-text-template": "^1.2.1", "phpunit/php-token-stream": "^2.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/environment": "^3.0", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, "require-dev": { "ext-xdebug": "^2.5", "phpunit/phpunit": "^6.0" }, "suggest": { "ext-xdebug": "^2.5.5" }, "type": "library", "extra": { "branch-alias": { "dev-master": "5.2.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": "2017-11-03T13:47:33+00:00" }, { "name": "phpunit/php-file-iterator", "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "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": "2016-10-03T07:40:28+00:00" }, { "name": "phpunit/php-text-template", "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de", "role": "lead" } ], "description": "Simple template engine.", "homepage": "https://github.com/sebastianbergmann/php-text-template/", "keywords": [ "template" ], "time": "2015-06-21T13:50:34+00:00" }, { "name": "phpunit/php-timer", "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0" }, "require-dev": { "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "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": "sb@sebastian-bergmann.de", "role": "lead" } ], "description": "Utility class for timing", "homepage": "https://github.com/sebastianbergmann/php-timer/", "keywords": [ "timer" ], "time": "2017-02-26T11:10:40+00:00" }, { "name": "phpunit/php-token-stream", "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", "shasum": "" }, "require": { "ext-tokenizer": "*", "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.2.4" }, "type": "library", "extra": { "branch-alias": { "dev-master": "2.0-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": "2017-08-20T05:47:52+00:00" }, { "name": "phpunit/phpunit", "version": "6.4.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/562f7dc75d46510a4ed5d16189ae57fbe45a9932", "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932", "shasum": "" }, "require": { "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "myclabs/deep-copy": "^1.6.1", "phar-io/manifest": "^1.0.1", "phar-io/version": "^1.0", "php": "^7.0", "phpspec/prophecy": "^1.7", "phpunit/php-code-coverage": "^5.2.2", "phpunit/php-file-iterator": "^1.4.2", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^1.0.9", "phpunit/phpunit-mock-objects": "^4.0.3", "sebastian/comparator": "^2.0.2", "sebastian/diff": "^2.0", "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", "sebastian/global-state": "^2.0", "sebastian/object-enumerator": "^3.0.3", "sebastian/resource-operations": "^1.0", "sebastian/version": "^2.0.1" }, "conflict": { "phpdocumentor/reflection-docblock": "3.0.2", "phpunit/dbunit": "<3.0" }, "require-dev": { "ext-pdo": "*" }, "suggest": { "ext-xdebug": "*", "phpunit/php-invoker": "^1.1" }, "bin": [ "phpunit" ], "type": "library", "extra": { "branch-alias": { "dev-master": "6.4.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": "2017-11-08T11:26:09+00:00" }, { "name": "phpunit/phpunit-mock-objects", "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", "reference": "2f789b59ab89669015ad984afa350c4ec577ade0" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0", "reference": "2f789b59ab89669015ad984afa350c4ec577ade0", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.5", "php": "^7.0", "phpunit/php-text-template": "^1.2.1", "sebastian/exporter": "^3.0" }, "conflict": { "phpunit/phpunit": "<6.0" }, "require-dev": { "phpunit/phpunit": "^6.0" }, "suggest": { "ext-soap": "*" }, "type": "library", "extra": { "branch-alias": { "dev-master": "4.0.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": "2017-08-03T14:08:16+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", "shasum": "" }, "require": { "php": "^5.6 || ^7.0" }, "require-dev": { "phpunit/phpunit": "^5.7 || ^6.0" }, "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": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "time": "2017-03-04T06:30:41+00:00" }, { "name": "sebastian/comparator", "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", "reference": "1174d9018191e93cb9d719edec01257fc05f8158" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1174d9018191e93cb9d719edec01257fc05f8158", "reference": "1174d9018191e93cb9d719edec01257fc05f8158", "shasum": "" }, "require": { "php": "^7.0", "sebastian/diff": "^2.0", "sebastian/exporter": "^3.1" }, "require-dev": { "phpunit/phpunit": "^6.4" }, "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": "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": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], "time": "2017-11-03T07:16:52+00:00" }, { "name": "sebastian/diff", "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", "shasum": "" }, "require": { "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { "branch-alias": { "dev-master": "2.0-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": "https://github.com/sebastianbergmann/diff", "keywords": [ "diff" ], "time": "2017-08-03T08:09:46+00:00" }, { "name": "sebastian/environment", "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "shasum": "" }, "require": { "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.1" }, "type": "library", "extra": { "branch-alias": { "dev-master": "3.1.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": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", "shasum": "" }, "require": { "php": "^7.0", "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "3.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" }, { "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": "2017-04-03T13:19:02+00:00" }, { "name": "sebastian/global-state", "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "shasum": "" }, "require": { "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" }, "suggest": { "ext-uopz": "*" }, "type": "library", "extra": { "branch-alias": { "dev-master": "2.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": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { "php": "^7.0", "sebastian/object-reflector": "^1.1.1", "sebastian/recursion-context": "^3.0" }, "require-dev": { "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "3.0.x-dev" } }, "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "time": "2017-08-03T12:35:26+00:00" }, { "name": "sebastian/object-reflector", "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", "reference": "773f97c67f28de00d397be301821b06708fca0be" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", "reference": "773f97c67f28de00d397be301821b06708fca0be", "shasum": "" }, "require": { "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.1-dev" } }, "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", "time": "2017-03-29T09:07:27+00:00" }, { "name": "sebastian/recursion-context", "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "shasum": "" }, "require": { "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "3.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": "2017-03-03T06:23:57+00:00" }, { "name": "sebastian/resource-operations", "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", "shasum": "" }, "require": { "php": ">=5.6.0" }, "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": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "time": "2015-07-28T20:34:47+00:00" }, { "name": "sebastian/version", "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", "shasum": "" }, "require": { "php": ">=5.6" }, "type": "library", "extra": { "branch-alias": { "dev-master": "2.0.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": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, { "name": "theseer/tokenizer", "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", "php": "^7.0" }, "type": "library", "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Arne Blankerts", "email": "arne@blankerts.de", "role": "Developer" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "time": "2017-04-07T12:08:54+00:00" } ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "^7.0" }, "platform-dev": [] } php-phpdocumentor-reflection-docblock-4.3.3/easy-coding-standard.neon000066400000000000000000000022641360074523700257770ustar00rootroot00000000000000includes: - 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/** php-phpdocumentor-reflection-docblock-4.3.3/examples/000077500000000000000000000000001360074523700227305ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/examples/01-interpreting-a-simple-docblock.php000066400000000000000000000015751360074523700316640ustar00rootroot00000000000000create($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(); php-phpdocumentor-reflection-docblock-4.3.3/examples/02-interpreting-tags.php000066400000000000000000000011651360074523700273310ustar00rootroot00000000000000create($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'); php-phpdocumentor-reflection-docblock-4.3.3/examples/03-reconstituting-a-docblock.php000066400000000000000000000013501360074523700307350ustar00rootroot00000000000000create($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); php-phpdocumentor-reflection-docblock-4.3.3/examples/04-adding-your-own-tag.php000066400000000000000000000135201360074523700274570ustar00rootroot00000000000000 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 = << 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); php-phpdocumentor-reflection-docblock-4.3.3/examples/playing-with-descriptions/000077500000000000000000000000001360074523700300505ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/examples/playing-with-descriptions/02-escaping.php000066400000000000000000000033111360074523700325670ustar00rootroot00000000000000create($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 = <<render(); php-phpdocumentor-reflection-docblock-4.3.3/phpunit.xml.dist000066400000000000000000000022251360074523700242660ustar00rootroot00000000000000 ./tests/unit ./tests/integration ./src/ ./vendor/ php-phpdocumentor-reflection-docblock-4.3.3/src/000077500000000000000000000000001360074523700217015ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock.php000066400000000000000000000134011360074523700240710ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; use phpDocumentor\Reflection\DocBlock\Tag; use Webmozart\Assert\Assert; final class DocBlock { /** @var string The opening line for this docblock. */ private $summary = ''; /** @var DocBlock\Description The actual description for this docblock. */ private $description = null; /** @var Tag[] An array containing all the tags in this docblock; except inline. */ private $tags = []; /** @var Types\Context Information about the context of this DocBlock. */ private $context = null; /** @var Location Information about the location of this DocBlock. */ private $location = null; /** @var bool Is this DocBlock (the start of) a template? */ private $isTemplateStart = false; /** @var bool Does this DocBlock signify the end of a DocBlock template? */ private $isTemplateEnd = false; /** * @param string $summary * @param DocBlock\Description $description * @param DocBlock\Tag[] $tags * @param Types\Context $context The context in which the DocBlock occurs. * @param Location $location The location within the file that this DocBlock occurs in. * @param bool $isTemplateStart * @param bool $isTemplateEnd */ public function __construct( $summary = '', DocBlock\Description $description = null, array $tags = [], Types\Context $context = null, Location $location = null, $isTemplateStart = false, $isTemplateEnd = false ) { Assert::string($summary); Assert::boolean($isTemplateStart); Assert::boolean($isTemplateEnd); Assert::allIsInstanceOf($tags, Tag::class); $this->summary = $summary; $this->description = $description ?: new DocBlock\Description(''); foreach ($tags as $tag) { $this->addTag($tag); } $this->context = $context; $this->location = $location; $this->isTemplateEnd = $isTemplateEnd; $this->isTemplateStart = $isTemplateStart; } /** * @return string */ public function getSummary() { return $this->summary; } /** * @return DocBlock\Description */ public function getDescription() { return $this->description; } /** * Returns the current context. * * @return Types\Context */ public function getContext() { return $this->context; } /** * Returns the current location. * * @return Location */ public function getLocation() { return $this->location; } /** * Returns whether this DocBlock is the start of a Template section. * * A Docblock may serve as template for a series of subsequent DocBlocks. This is indicated by a special marker * (`#@+`) that is appended directly after the opening `/**` of a DocBlock. * * An example of such an opening is: * * ``` * /**#@+ * * My DocBlock * * / * ``` * * The description and tags (not the summary!) are copied onto all subsequent DocBlocks and also applied to all * elements that follow until another DocBlock is found that contains the closing marker (`#@-`). * * @see self::isTemplateEnd() for the check whether a closing marker was provided. * * @return boolean */ public function isTemplateStart() { return $this->isTemplateStart; } /** * Returns whether this DocBlock is the end of a Template section. * * @see self::isTemplateStart() for a more complete description of the Docblock Template functionality. * * @return boolean */ public function isTemplateEnd() { return $this->isTemplateEnd; } /** * Returns the tags for this DocBlock. * * @return Tag[] */ public function getTags() { return $this->tags; } /** * Returns an array of tags matching the given name. If no tags are found * an empty array is returned. * * @param string $name String to search by. * * @return Tag[] */ public function getTagsByName($name) { Assert::string($name); $result = []; /** @var Tag $tag */ foreach ($this->getTags() as $tag) { if ($tag->getName() !== $name) { continue; } $result[] = $tag; } return $result; } /** * Checks if a tag of a certain type is present in this DocBlock. * * @param string $name Tag name to check for. * * @return bool */ public function hasTag($name) { Assert::string($name); /** @var Tag $tag */ foreach ($this->getTags() as $tag) { if ($tag->getName() === $name) { return true; } } 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. * * @param Tag $tag The tag to add. * * @return void */ private function addTag(Tag $tag) { $this->tags[] = $tag; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/000077500000000000000000000000001360074523700233615ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Description.php000066400000000000000000000070571360074523700263660ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock\Tags\Formatter; use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter; use Webmozart\Assert\Assert; /** * Object representing to description for a DocBlock. * * A Description object can consist of plain text but can also include tags. A Description Formatter can then combine * a body template with sprintf-style placeholders together with formatted tags in order to reconstitute a complete * description text using the format that you would prefer. * * Because parsing a Description text can be a verbose process this is handled by the {@see DescriptionFactory}. It is * thus recommended to use that to create a Description object, like this: * * $description = $descriptionFactory->create('This is a {@see Description}', $context); * * The description factory will interpret the given body and create a body template and list of tags from them, and pass * that onto the constructor if this class. * * > The $context variable is a class of type {@see \phpDocumentor\Reflection\Types\Context} and contains the namespace * > and the namespace aliases that apply to this DocBlock. These are used by the Factory to resolve and expand partial * > type names and FQSENs. * * If you do not want to use the DescriptionFactory you can pass a body template and tag listing like this: * * $description = new Description( * 'This is a %1$s', * [ new See(new Fqsen('\phpDocumentor\Reflection\DocBlock\Description')) ] * ); * * It is generally recommended to use the Factory as that will also apply escaping rules, while the Description object * is mainly responsible for rendering. * * @see DescriptionFactory to create a new Description. * @see Description\Formatter for the formatting of the body and tags. */ class Description { /** @var string */ private $bodyTemplate; /** @var Tag[] */ private $tags; /** * Initializes a Description with its body (template) and a listing of the tags used in the body template. * * @param string $bodyTemplate * @param Tag[] $tags */ public function __construct($bodyTemplate, array $tags = []) { Assert::string($bodyTemplate); $this->bodyTemplate = $bodyTemplate; $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. * * @param Formatter|null $formatter * * @return string */ public function render(Formatter $formatter = null) { if ($formatter === null) { $formatter = new PassthroughFormatter(); } $tags = []; foreach ($this->tags as $tag) { $tags[] = '{' . $formatter->format($tag) . '}'; } return vsprintf($this->bodyTemplate, $tags); } /** * Returns a plain string representation of this description. * * @return string */ public function __toString() { return $this->render(); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/DescriptionFactory.php000066400000000000000000000155601360074523700277140ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\Types\Context as TypeContext; /** * Creates a new Description object given a body of text. * * Descriptions in phpDocumentor are somewhat complex entities as they can contain one or more tags inside their * body that can be replaced with a readable output. The replacing is done by passing a Formatter object to the * Description object's `render` method. * * In addition to the above does a Description support two types of escape sequences: * * 1. `{@}` to escape the `@` character to prevent it from being interpreted as part of a tag, i.e. `{{@}link}` * 2. `{}` to escape the `}` character, this can be used if you want to use the `}` character in the description * of an inline tag. * * If a body consists of multiple lines then this factory will also remove any superfluous whitespace at the beginning * of each line while maintaining any indentation that is used. This will prevent formatting parsers from tripping * over unexpected spaces as can be observed with tag descriptions. */ class DescriptionFactory { /** @var TagFactory */ private $tagFactory; /** * Initializes this factory with the means to construct (inline) tags. * * @param TagFactory $tagFactory */ public function __construct(TagFactory $tagFactory) { $this->tagFactory = $tagFactory; } /** * Returns the parsed text of this description. * * @param string $contents * @param TypeContext $context * * @return Description */ public function create($contents, TypeContext $context = null) { list($text, $tags) = $this->parse($this->lex($contents), $context); return new Description($text, $tags); } /** * Strips the contents from superfluous whitespace and splits the description into a series of tokens. * * @param string $contents * * @return string[] A series of tokens of which the description text is composed. */ private function lex($contents) { $contents = $this->removeSuperfluousStartingWhitespace($contents); // performance optimalization; if there is no inline tag, don't bother splitting it up. if (strpos($contents, '{@') === false) { return [$contents]; } return preg_split( '/\{ # "{@}" is not a valid inline tag. This ensures that we do not treat it as one, but treat it literally. (?!@\}) # We want to capture the whole tag line, but without the inline tag delimiters. (\@ # Match everything up to the next delimiter. [^{}]* # Nested inline tag content should not be captured, or it will appear in the result separately. (?: # Match nested inline tags. (?: # Because we did not catch the tag delimiters earlier, we must be explicit with them here. # Notice that this also matches "{}", as a way to later introduce it as an escape sequence. \{(?1)?\} | # Make sure we match hanging "{". \{ ) # Match content after the nested inline tag. [^{}]* )* # If there are more inline tags, match them as well. We use "*" since there may not be any # nested inline tags. ) \}/Sux', $contents, null, PREG_SPLIT_DELIM_CAPTURE ); } /** * Parses the stream of tokens in to a new set of tokens containing Tags. * * @param string[] $tokens * @param TypeContext $context * * @return string[]|Tag[] */ private function parse($tokens, TypeContext $context) { $count = count($tokens); $tagCount = 0; $tags = []; for ($i = 1; $i < $count; $i += 2) { $tags[] = $this->tagFactory->create($tokens[$i], $context); $tokens[$i] = '%' . ++$tagCount . '$s'; } //In order to allow "literal" inline tags, the otherwise invalid //sequence "{@}" is changed to "@", and "{}" is changed to "}". //"%" is escaped to "%%" because of vsprintf. //See unit tests for examples. for ($i = 0; $i < $count; $i += 2) { $tokens[$i] = str_replace(['{@}', '{}', '%'], ['@', '}', '%%'], $tokens[$i]); } return [implode('', $tokens), $tags]; } /** * Removes the superfluous from a multi-line description. * * When a description has more than one line then it can happen that the second and subsequent lines have an * additional indentation. This is commonly in use with tags like this: * * {@}since 1.1.0 This is an example * description where we have an * indentation in the second and * subsequent lines. * * If we do not normalize the indentation then we have superfluous whitespace on the second and subsequent * lines and this may cause rendering issues when, for example, using a Markdown converter. * * @param string $contents * * @return string */ private function removeSuperfluousStartingWhitespace($contents) { $lines = explode("\n", $contents); // if there is only one line then we don't have lines with superfluous whitespace and // can use the contents as-is if (count($lines) <= 1) { return $contents; } // determine how many whitespace characters need to be stripped $startingSpaceCount = 9999999; for ($i = 1; $i < count($lines); $i++) { // lines with a no length do not count as they are not indented at all if (strlen(trim($lines[$i])) === 0) { continue; } // determine the number of prefixing spaces by checking the difference in line length before and after // an ltrim $startingSpaceCount = min($startingSpaceCount, strlen($lines[$i]) - strlen(ltrim($lines[$i]))); } // strip the number of spaces from each line if ($startingSpaceCount > 0) { for ($i = 1; $i < count($lines); $i++) { $lines[$i] = substr($lines[$i], $startingSpaceCount); } } return implode("\n", $lines); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/ExampleFinder.php000066400000000000000000000113151360074523700266160ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock\Tags\Example; /** * Class used to find an example file's location based on a given ExampleDescriptor. */ class ExampleFinder { /** @var string */ private $sourceDirectory = ''; /** @var string[] */ private $exampleDirectories = []; /** * Attempts to find the example contents for the given descriptor. * * @param Example $example * * @return string */ public function find(Example $example) { $filename = $example->getFilePath(); $file = $this->getExampleFileContents($filename); if (!$file) { return "** File not found : {$filename} **"; } return implode('', array_slice($file, $example->getStartingLine() - 1, $example->getLineCount())); } /** * Registers the project's root directory where an 'examples' folder can be expected. * * @param string $directory * * @return void */ public function setSourceDirectory($directory = '') { $this->sourceDirectory = $directory; } /** * Returns the project's root directory where an 'examples' folder can be expected. * * @return string */ public function getSourceDirectory() { return $this->sourceDirectory; } /** * Registers a series of directories that may contain examples. * * @param string[] $directories */ public function setExampleDirectories(array $directories) { $this->exampleDirectories = $directories; } /** * Returns a series of directories that may contain examples. * * @return string[] */ public function getExampleDirectories() { return $this->exampleDirectories; } /** * Attempts to find the requested example file and returns its contents or null if no file was found. * * This method will try several methods in search of the given example file, the first one it encounters is * returned: * * 1. Iterates through all examples folders for the given filename * 2. Checks the source folder for the given filename * 3. Checks the 'examples' folder in the current working directory for examples * 4. Checks the path relative to the current working directory for the given filename * * @param string $filename * * @return string|null */ private function getExampleFileContents($filename) { $normalizedPath = null; foreach ($this->exampleDirectories as $directory) { $exampleFileFromConfig = $this->constructExamplePath($directory, $filename); if (is_readable($exampleFileFromConfig)) { $normalizedPath = $exampleFileFromConfig; break; } } if (!$normalizedPath) { if (is_readable($this->getExamplePathFromSource($filename))) { $normalizedPath = $this->getExamplePathFromSource($filename); } elseif (is_readable($this->getExamplePathFromExampleDirectory($filename))) { $normalizedPath = $this->getExamplePathFromExampleDirectory($filename); } elseif (is_readable($filename)) { $normalizedPath = $filename; } } return $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : null; } /** * Get example filepath based on the example directory inside your project. * * @param string $file * * @return string */ private function getExamplePathFromExampleDirectory($file) { return getcwd() . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $file; } /** * Returns a path to the example file in the given directory.. * * @param string $directory * @param string $file * * @return string */ private function constructExamplePath($directory, $file) { return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file; } /** * Get example filepath based on sourcecode. * * @param string $file * * @return string */ private function getExamplePathFromSource($file) { return sprintf( '%s%s%s', trim($this->getSourceDirectory(), '\\/'), DIRECTORY_SEPARATOR, trim($file, '"') ); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Serializer.php000066400000000000000000000113761360074523700262130ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock; use Webmozart\Assert\Assert; /** * Converts a DocBlock back from an object to a complete DocComment including Asterisks. */ class Serializer { /** @var string The string to indent the comment with. */ protected $indentString = ' '; /** @var int The number of times the indent string is repeated. */ protected $indent = 0; /** @var bool Whether to indent the first line with the given indent amount and string. */ protected $isFirstLineIndented = true; /** @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. * * @param int $indent The number of times the indent string is repeated. * @param string $indentString The string to indent the comment with. * @param bool $indentFirstLine Whether to indent the first line. * @param int|null $lineLength The max length of a line or NULL to disable line wrapping. * @param DocBlock\Tags\Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter. */ 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(); } /** * Generate a DocBlock comment. * * @param DocBlock $docblock The DocBlock to serialize. * * @return string The serialized doc block. */ public function getDocComment(DocBlock $docblock) { $indent = str_repeat($this->indentString, $this->indent); $firstIndent = $this->isFirstLineIndented ? $indent : ''; // 3 === strlen(' * ') $wrapLength = $this->lineLength ? $this->lineLength - strlen($indent) - 3 : null; $text = $this->removeTrailingSpaces( $indent, $this->addAsterisksForEachLine( $indent, $this->getSummaryAndDescriptionTextBlock($docblock, $wrapLength) ) ); $comment = "{$firstIndent}/**\n"; if ($text) { $comment .= "{$indent} * {$text}\n"; $comment .= "{$indent} *\n"; } $comment = $this->addTagBlock($docblock, $wrapLength, $indent, $comment); $comment .= $indent . ' */'; return $comment; } /** * @param $indent * @param $text * @return mixed */ private function removeTrailingSpaces($indent, $text) { return str_replace("\n{$indent} * \n", "\n{$indent} *\n", $text); } /** * @param $indent * @param $text * @return mixed */ private function addAsterisksForEachLine($indent, $text) { return str_replace("\n", "\n{$indent} * ", $text); } /** * @param DocBlock $docblock * @param $wrapLength * @return string */ private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, $wrapLength) { $text = $docblock->getSummary() . ((string)$docblock->getDescription() ? "\n\n" . $docblock->getDescription() : ''); if ($wrapLength !== null) { $text = wordwrap($text, $wrapLength); return $text; } return $text; } /** * @param DocBlock $docblock * @param $wrapLength * @param $indent * @param $comment * @return string */ private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment) { foreach ($docblock->getTags() as $tag) { $tagText = $this->tagFormatter->format($tag); if ($wrapLength !== null) { $tagText = wordwrap($tagText, $wrapLength); } $tagText = str_replace("\n", "\n{$indent} * ", $tagText); $comment .= "{$indent} * {$tagText}\n"; } return $comment; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/StandardTagFactory.php000066400000000000000000000271221360074523700276220ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod; use phpDocumentor\Reflection\DocBlock\Tags\Generic; use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Creates a Tag object given the contents of a tag. * * This Factory is capable of determining the appropriate class for a tag and instantiate it using its `create` * factory method. The `create` factory method of a Tag can have a variable number of arguments; this way you can * pass the dependencies that you need to construct a tag object. * * > Important: each parameter in addition to the body variable for the `create` method must default to null, otherwise * > it violates the constraint with the interface; it is recommended to use the {@see Assert::notNull()} method to * > verify that a dependency is actually passed. * * This Factory also features a Service Locator component that is used to pass the right dependencies to the * `create` method of a tag; each dependency should be registered as a service or as a parameter. * * When you want to use a Tag of your own with custom handling you need to call the `registerTagHandler` method, pass * the name of the tag and a Fully Qualified Class Name pointing to a class that implements the Tag interface. */ final class StandardTagFactory implements TagFactory { /** PCRE regular expression matching a tag name. */ const REGEX_TAGNAME = '[\w\-\_\\\\]+'; /** * @var string[] An array with a tag as a key, and an FQCN to a class that handles it as an array value. */ private $tagHandlerMappings = [ 'author' => '\phpDocumentor\Reflection\DocBlock\Tags\Author', 'covers' => '\phpDocumentor\Reflection\DocBlock\Tags\Covers', 'deprecated' => '\phpDocumentor\Reflection\DocBlock\Tags\Deprecated', // 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example', 'link' => '\phpDocumentor\Reflection\DocBlock\Tags\Link', 'method' => '\phpDocumentor\Reflection\DocBlock\Tags\Method', 'param' => '\phpDocumentor\Reflection\DocBlock\Tags\Param', 'property-read' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyRead', 'property' => '\phpDocumentor\Reflection\DocBlock\Tags\Property', 'property-write' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite', 'return' => '\phpDocumentor\Reflection\DocBlock\Tags\Return_', 'see' => '\phpDocumentor\Reflection\DocBlock\Tags\See', 'since' => '\phpDocumentor\Reflection\DocBlock\Tags\Since', 'source' => '\phpDocumentor\Reflection\DocBlock\Tags\Source', 'throw' => '\phpDocumentor\Reflection\DocBlock\Tags\Throws', 'throws' => '\phpDocumentor\Reflection\DocBlock\Tags\Throws', 'uses' => '\phpDocumentor\Reflection\DocBlock\Tags\Uses', 'var' => '\phpDocumentor\Reflection\DocBlock\Tags\Var_', 'version' => '\phpDocumentor\Reflection\DocBlock\Tags\Version' ]; /** * @var \ReflectionParameter[][] a lazy-loading cache containing parameters for each tagHandler that has been used. */ private $tagHandlerParameterCache = []; /** * @var FqsenResolver */ private $fqsenResolver; /** * @var mixed[] an array representing a simple Service Locator where we can store parameters and * services that can be inserted into the Factory Methods of Tag Handlers. */ private $serviceLocator = []; /** * Initialize this tag factory with the means to resolve an FQSEN and optionally a list of tag handlers. * * If no tag handlers are provided than the default list in the {@see self::$tagHandlerMappings} property * is used. * * @param FqsenResolver $fqsenResolver * @param string[] $tagHandlers * * @see self::registerTagHandler() to add a new tag handler to the existing default list. */ public function __construct(FqsenResolver $fqsenResolver, array $tagHandlers = null) { $this->fqsenResolver = $fqsenResolver; if ($tagHandlers !== null) { $this->tagHandlerMappings = $tagHandlers; } $this->addService($fqsenResolver, FqsenResolver::class); } /** * {@inheritDoc} */ public function create($tagLine, TypeContext $context = null) { if (! $context) { $context = new TypeContext(''); } 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); } /** * {@inheritDoc} */ public function addParameter($name, $value) { $this->serviceLocator[$name] = $value; } /** * {@inheritDoc} */ public function addService($service, $alias = null) { $this->serviceLocator[$alias ?: get_class($service)] = $service; } /** * {@inheritDoc} */ public function registerTagHandler($tagName, $handler) { Assert::stringNotEmpty($tagName); Assert::stringNotEmpty($handler); Assert::classExists($handler); Assert::implementsInterface($handler, StaticMethod::class); if (strpos($tagName, '\\') && $tagName[0] !== '\\') { throw new \InvalidArgumentException( 'A namespaced tag must have a leading backslash as it must be fully qualified' ); } $this->tagHandlerMappings[$tagName] = $handler; } /** * Extracts all components for a tag. * * @param string $tagLine * * @return string[] */ private function extractTagParts($tagLine) { $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' ); } if (count($matches) < 3) { $matches[] = ''; } return array_slice($matches, 1); } /** * Creates a new tag object with the given name and body or returns null if the tag name was recognized but the * body was invalid. * * @param string $body * @param string $name * @param TypeContext $context * * @return Tag|null */ private function createTag($body, $name, TypeContext $context) { $handlerClassName = $this->findHandlerClassName($name, $context); $arguments = $this->getArgumentsForParametersFromWiring( $this->fetchParametersForHandlerFactoryMethod($handlerClassName), $this->getServiceLocatorWithDynamicParameters($context, $name, $body) ); return call_user_func_array([$handlerClassName, 'create'], $arguments); } /** * Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`). * * @param string $tagName * @param TypeContext $context * * @return string */ private function findHandlerClassName($tagName, TypeContext $context) { $handlerClassName = Generic::class; if (isset($this->tagHandlerMappings[$tagName])) { $handlerClassName = $this->tagHandlerMappings[$tagName]; } elseif ($this->isAnnotation($tagName)) { // TODO: Annotation support is planned for a later stage and as such is disabled for now // $tagName = (string)$this->fqsenResolver->resolve($tagName, $context); // if (isset($this->annotationMappings[$tagName])) { // $handlerClassName = $this->annotationMappings[$tagName]; // } } return $handlerClassName; } /** * Retrieves the arguments that need to be passed to the Factory Method with the given Parameters. * * @param \ReflectionParameter[] $parameters * @param mixed[] $locator * * @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters * is provided with this method. */ private function getArgumentsForParametersFromWiring($parameters, $locator) { $arguments = []; foreach ($parameters as $index => $parameter) { $typeHint = $parameter->getClass() ? $parameter->getClass()->getName() : null; if (isset($locator[$typeHint])) { $arguments[] = $locator[$typeHint]; continue; } $parameterName = $parameter->getName(); if (isset($locator[$parameterName])) { $arguments[] = $locator[$parameterName]; continue; } $arguments[] = null; } return $arguments; } /** * Retrieves a series of ReflectionParameter objects for the static 'create' method of the given * tag handler class name. * * @param string $handlerClassName * * @return \ReflectionParameter[] */ private function fetchParametersForHandlerFactoryMethod($handlerClassName) { if (! isset($this->tagHandlerParameterCache[$handlerClassName])) { $methodReflection = new \ReflectionMethod($handlerClassName, 'create'); $this->tagHandlerParameterCache[$handlerClassName] = $methodReflection->getParameters(); } return $this->tagHandlerParameterCache[$handlerClassName]; } /** * Returns a copy of this class' Service Locator with added dynamic parameters, such as the tag's name, body and * Context. * * @param TypeContext $context The Context (namespace and aliasses) that may be passed and is used to resolve FQSENs. * @param string $tagName The name of the tag that may be passed onto the factory method of the Tag class. * @param string $tagBody The body of the tag that may be passed onto the factory method of the Tag class. * * @return mixed[] */ private function getServiceLocatorWithDynamicParameters(TypeContext $context, $tagName, $tagBody) { $locator = array_merge( $this->serviceLocator, [ 'name' => $tagName, 'body' => $tagBody, TypeContext::class => $context ] ); return $locator; } /** * Returns whether the given tag belongs to an annotation. * * @param string $tagContent * * @todo this method should be populated once we implement Annotation notation support. * * @return bool */ private function isAnnotation($tagContent) { // 1. Contains a namespace separator // 2. Contains parenthesis // 3. Is present in a list of known annotations (make the algorithm smart by first checking is the last part // of the annotation class name matches the found tag name return false; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tag.php000066400000000000000000000011651360074523700246100ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock\Tags\Formatter; interface Tag { public function getName(); public static function create($body); public function render(Formatter $formatter = null); public function __toString(); } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/TagFactory.php000066400000000000000000000074071360074523700261450ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\Types\Context as TypeContext; interface TagFactory { /** * Adds a parameter to the service locator that can be injected in a tag's factory method. * * When calling a tag's "create" method we always check the signature for dependencies to inject. One way is to * typehint a parameter in the signature so that we can use that interface or class name to inject a dependency * (see {@see addService()} for more information on that). * * Another way is to check the name of the argument against the names in the Service Locator. With this method * you can add a variable that will be inserted when a tag's create method is not typehinted and has a matching * name. * * Be aware that there are two reserved names: * * - name, representing the name of the tag. * - body, representing the complete body of the tag. * * These parameters are injected at the last moment and will override any existing parameter with those names. * * @param string $name * @param mixed $value * * @return void */ public function addParameter($name, $value); /** * Registers a service with the Service Locator using the FQCN of the class or the alias, if provided. * * When calling a tag's "create" method we always check the signature for dependencies to inject. If a parameter * has a typehint then the ServiceLocator is queried to see if a Service is registered for that typehint. * * Because interfaces are regularly used as type-hints this method provides an alias parameter; if the FQCN of the * interface is passed as alias then every time that interface is requested the provided service will be returned. * * @param object $service * @param string $alias * * @return void */ public function addService($service); /** * Factory method responsible for instantiating the correct sub type. * * @param string $tagLine The text for this tag, including description. * @param TypeContext $context * * @throws \InvalidArgumentException if an invalid tag line was presented. * * @return Tag A new tag object. */ public function create($tagLine, TypeContext $context = null); /** * Registers a handler for tags. * * If you want to use your own tags then you can use this method to instruct the TagFactory to register the name * of a tag with the FQCN of a 'Tag Handler'. The Tag handler should implement the {@see Tag} interface (and thus * the create method). * * @param string $tagName Name of tag to register a handler for. When registering a namespaced tag, the full * name, along with a prefixing slash MUST be provided. * @param string $handler FQCN of handler. * * @throws \InvalidArgumentException if the tag name is not a string * @throws \InvalidArgumentException if the tag name is namespaced (contains backslashes) but does not start with * a backslash * @throws \InvalidArgumentException if the handler is not a string * @throws \InvalidArgumentException if the handler is not an existing class * @throws \InvalidArgumentException if the handler does not implement the {@see Tag} interface * * @return void */ public function registerTagHandler($tagName, $handler); } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/000077500000000000000000000000001360074523700242575ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Author.php000066400000000000000000000047351360074523700262430ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use Webmozart\Assert\Assert; /** * Reflection class for an {@}author tag in a Docblock. */ final class Author extends BaseTag implements Factory\StaticMethod { /** @var string register that this is the author tag. */ protected $name = 'author'; /** @var string The name of the author */ private $authorName = ''; /** @var string The email of the author */ private $authorEmail = ''; /** * Initializes this tag with the author name and e-mail. * * @param string $authorName * @param string $authorEmail */ public function __construct($authorName, $authorEmail) { Assert::string($authorName); Assert::string($authorEmail); if ($authorEmail && !filter_var($authorEmail, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException('The author tag does not have a valid e-mail address'); } $this->authorName = $authorName; $this->authorEmail = $authorEmail; } /** * Gets the author's name. * * @return string The author's name. */ public function getAuthorName() { return $this->authorName; } /** * Returns the author's email. * * @return string The author's email. */ public function getEmail() { return $this->authorEmail; } /** * Returns this tag in string form. * * @return string */ public function __toString() { return $this->authorName . (strlen($this->authorEmail) ? ' <' . $this->authorEmail . '>' : ''); } /** * Attempts to create a new Author object based on †he tag body. * * @param string $body * * @return static */ public static function create($body) { Assert::string($body); $splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches); if (!$splitTagContent) { return null; } $authorName = trim($matches[1]); $email = isset($matches[2]) ? trim($matches[2]) : ''; return new static($authorName, $email); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/BaseTag.php000066400000000000000000000022771360074523700263060ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock\Description; /** * Parses a tag definition for a DocBlock. */ abstract class BaseTag implements DocBlock\Tag { /** @var string Name of the tag */ protected $name = ''; /** @var Description|null Description of the tag. */ protected $description; /** * Gets the name of this tag. * * @return string The name of this tag. */ public function getName() { return $this->name; } public function getDescription() { return $this->description; } public function render(Formatter $formatter = null) { if ($formatter === null) { $formatter = new Formatter\PassthroughFormatter(); } return $formatter->format($this); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Covers.php000066400000000000000000000041061360074523700262320ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a @covers tag in a Docblock. */ final class Covers extends BaseTag implements Factory\StaticMethod { protected $name = 'covers'; /** @var Fqsen */ private $refers = null; /** * Initializes this tag. * * @param Fqsen $refers * @param Description $description */ public function __construct(Fqsen $refers, Description $description = null) { $this->refers = $refers; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, DescriptionFactory $descriptionFactory = null, FqsenResolver $resolver = null, TypeContext $context = null ) { Assert::string($body); Assert::notEmpty($body); $parts = preg_split('/\s+/Su', $body, 2); return new static( $resolver->resolve($parts[0], $context), $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context) ); } /** * Returns the structural element this tag refers to. * * @return Fqsen */ public function getReference() { return $this->refers; } /** * Returns a string representation of this tag. * * @return string */ public function __toString() { return $this->refers . ($this->description ? ' ' . $this->description->render() : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Deprecated.php000066400000000000000000000052271360074523700270360ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}deprecated tag in a Docblock. */ final class Deprecated extends BaseTag implements Factory\StaticMethod { protected $name = 'deprecated'; /** * PCRE regular expression matching a version vector. * Assumes the "x" modifier. */ const REGEX_VECTOR = '(?: # Normal release vectors. \d\S* | # VCS version vectors. Per PHPCS, they are expected to # follow the form of the VCS name, followed by ":", followed # by the version vector itself. # By convention, popular VCSes like CVS, SVN and GIT use "$" # around the actual version vector. [^\s\:]+\:\s*\$[^\$]+\$ )'; /** @var string The version vector. */ private $version = ''; public function __construct($version = null, Description $description = null) { Assert::nullOrStringNotEmpty($version); $this->version = $version; $this->description = $description; } /** * @return static */ public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) { Assert::nullOrString($body); if (empty($body)) { return new static(); } $matches = []; if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { return new static( null, null !== $descriptionFactory ? $descriptionFactory->create($body, $context) : null ); } return new static( $matches[1], $descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context) ); } /** * Gets the version section of the tag. * * @return string */ public function getVersion() { return $this->version; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return $this->version . ($this->description ? ' ' . $this->description->render() : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Example.php000066400000000000000000000105601360074523700263650ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ 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. */ final class Example extends BaseTag { /** * @var string Path to a file to use as an example. May also be an absolute URI. */ private $filePath; /** * @var bool Whether the file path component represents an URI. This determines how the file portion * appears at {@link getContent()}. */ 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} */ public function getContent() { if (null === $this->description) { $filePath = '"' . $this->filePath . '"'; if ($this->isURI) { $filePath = $this->isUriRelative($this->filePath) ? str_replace('%2F', '/', rawurlencode($this->filePath)) :$this->filePath; } return trim($filePath . ' ' . parent::getDescription()); } return $this->description; } /** * {@inheritdoc} */ public static function create($body) { // File component: File path in quotes or File URI / Source information if (! preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) { return null; } $filePath = null; $fileUri = null; if ('' !== $matches[1]) { $filePath = $matches[1]; } else { $fileUri = $matches[2]; } $startingLine = 1; $lineCount = null; $description = null; 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 !== null?$filePath:$fileUri, $fileUri !== null, $startingLine, $lineCount, $description ); } /** * Returns the file path. * * @return string Path to a file to use as an example. * May also be an absolute URI. */ public function getFilePath() { return $this->filePath; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return $this->filePath . ($this->description ? ' ' . $this->description : ''); } /** * Returns true if the provided URI is relative or contains a complete scheme (and thus is absolute). * * @param string $uri * * @return bool */ private function isUriRelative($uri) { return false === strpos($uri, ':'); } /** * @return int */ public function getStartingLine() { return $this->startingLine; } /** * @return int */ public function getLineCount() { return $this->lineCount; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Factory/000077500000000000000000000000001360074523700256665ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Factory/StaticMethod.php000066400000000000000000000007271360074523700307750ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; interface StaticMethod { public static function create($body); } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Factory/Strategy.php000066400000000000000000000007141360074523700302030ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; interface Strategy { public function create($body); } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Formatter.php000066400000000000000000000012431360074523700267330ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Tag; interface Formatter { /** * Formats a tag into a string representation according to a specific format, such as Markdown. * * @param Tag $tag * * @return string */ public function format(Tag $tag); } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Formatter/000077500000000000000000000000001360074523700262225ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Formatter/AlignFormatter.php000066400000000000000000000023721360074523700316550ustar00rootroot00000000000000 * @copyright 2017 Mike van Riel * @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; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Formatter/PassthroughFormatter.php000066400000000000000000000014531360074523700331310ustar00rootroot00000000000000 * @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 PassthroughFormatter implements Formatter { /** * Formats the given tag to return a simple plain text version. * * @param Tag $tag * * @return string */ public function format(Tag $tag) { return trim('@' . $tag->getName() . ' ' . (string)$tag); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Generic.php000066400000000000000000000051371360074523700263520ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\StandardTagFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Parses a tag definition for a DocBlock. */ class Generic extends BaseTag implements Factory\StaticMethod { /** * Parses a tag and populates the member variables. * * @param string $name Name of the tag. * @param Description $description The contents of the given tag. */ public function __construct($name, Description $description = null) { $this->validateTagName($name); $this->name = $name; $this->description = $description; } /** * Creates a new tag that represents any unknown tag type. * * @param string $body * @param string $name * @param DescriptionFactory $descriptionFactory * @param TypeContext $context * * @return static */ public static function create( $body, $name = '', DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::string($body); Assert::stringNotEmpty($name); Assert::notNull($descriptionFactory); $description = $descriptionFactory && $body !== "" ? $descriptionFactory->create($body, $context) : null; return new static($name, $description); } /** * Returns the tag as a serialized string * * @return string */ public function __toString() { return ($this->description ? $this->description->render() : ''); } /** * Validates if the tag name matches the expected format, otherwise throws an exception. * * @param string $name * * @return void */ private function validateTagName($name) { if (! preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) { throw new \InvalidArgumentException( 'The tag name "' . $name . '" is not wellformed. Tags may only consist of letters, underscores, ' . 'hyphens and backslashes.' ); } } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Link.php000066400000000000000000000035161360074523700256720ustar00rootroot00000000000000 * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a @link tag in a Docblock. */ final class Link extends BaseTag implements Factory\StaticMethod { protected $name = 'link'; /** @var string */ private $link = ''; /** * Initializes a link to a URL. * * @param string $link * @param Description $description */ public function __construct($link, Description $description = null) { Assert::string($link); $this->link = $link; $this->description = $description; } /** * {@inheritdoc} */ public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) { Assert::string($body); Assert::notNull($descriptionFactory); $parts = preg_split('/\s+/Su', $body, 2); $description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null; return new static($parts[0], $description); } /** * Gets the link * * @return string */ public function getLink() { return $this->link; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return $this->link . ($this->description ? ' ' . $this->description->render() : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Method.php000066400000000000000000000154631360074523700262210ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use phpDocumentor\Reflection\Types\Void_; use Webmozart\Assert\Assert; /** * Reflection class for an {@}method in a Docblock. */ final class Method extends BaseTag implements Factory\StaticMethod { protected $name = 'method'; /** @var string */ private $methodName = ''; /** @var string[] */ private $arguments = []; /** @var bool */ private $isStatic = false; /** @var Type */ private $returnType; public function __construct( $methodName, array $arguments = [], Type $returnType = null, $static = false, Description $description = null ) { Assert::stringNotEmpty($methodName); Assert::boolean($static); if ($returnType === null) { $returnType = new Void_(); } $this->methodName = $methodName; $this->arguments = $this->filterArguments($arguments); $this->returnType = $returnType; $this->isStatic = $static; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::stringNotEmpty($body); Assert::allNotNull([ $typeResolver, $descriptionFactory ]); // 1. none or more whitespace // 2. optionally the keyword "static" followed by whitespace // 3. optionally a word with underscores followed by whitespace : as // type for the return value // 4. then optionally a word with underscores followed by () and // whitespace : as method name as used by phpDocumentor // 5. then a word with underscores, followed by ( and any character // until a ) and whitespace : as method name with signature // 6. any remaining text : as description if (!preg_match( '/^ # Static keyword # Declares a static method ONLY if type is also present (?: (static) \s+ )? # Return type (?: ( (?:[\w\|_\\\\]*\$this[\w\|_\\\\]*) | (?: (?:[\w\|_\\\\]+) # array notation (?:\[\])* )* ) \s+ )? # Method name ([\w_]+) # Arguments (?: \(([^\)]*)\) )? \s* # Description (.*) $/sux', $body, $matches )) { return null; } 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 (is_string($arguments) && strlen($arguments) > 0) { $arguments = explode(',', $arguments); foreach ($arguments as &$argument) { $argument = explode(' ', self::stripRestArg(trim($argument)), 2); if ($argument[0][0] === '$') { $argumentName = substr($argument[0], 1); $argumentType = new Void_(); } else { $argumentType = $typeResolver->resolve($argument[0], $context); $argumentName = ''; if (isset($argument[1])) { $argument[1] = self::stripRestArg($argument[1]); $argumentName = substr($argument[1], 1); } } $argument = [ 'name' => $argumentName, 'type' => $argumentType]; } } else { $arguments = []; } return new static($methodName, $arguments, $returnType, $static, $description); } /** * Retrieves the method name. * * @return string */ public function getMethodName() { return $this->methodName; } /** * @return string[] */ public function getArguments() { return $this->arguments; } /** * Checks whether the method tag describes a static method or not. * * @return bool TRUE if the method declaration is for a static method, FALSE otherwise. */ public function isStatic() { return $this->isStatic; } /** * @return Type */ public function getReturnType() { return $this->returnType; } public function __toString() { $arguments = []; foreach ($this->arguments as $argument) { $arguments[] = $argument['type'] . ' $' . $argument['name']; } return trim(($this->isStatic() ? 'static ' : '') . (string)$this->returnType . ' ' . $this->methodName . '(' . implode(', ', $arguments) . ')' . ($this->description ? ' ' . $this->description->render() : '')); } private function filterArguments($arguments) { foreach ($arguments as &$argument) { 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) ); } } return $arguments; } private static function stripRestArg($argument) { if (strpos($argument, '...') === 0) { $argument = trim(substr($argument, 3)); } return $argument; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Param.php000066400000000000000000000075741360074523700260450ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for the {@}param tag in a Docblock. */ final class Param extends BaseTag implements Factory\StaticMethod { /** @var string */ protected $name = 'param'; /** @var Type */ private $type; /** @var string */ private $variableName = ''; /** @var bool determines whether this is a variadic argument */ private $isVariadic = false; /** * @param string $variableName * @param Type $type * @param bool $isVariadic * @param Description $description */ public function __construct($variableName, Type $type = null, $isVariadic = false, Description $description = null) { Assert::string($variableName); Assert::boolean($isVariadic); $this->variableName = $variableName; $this->type = $type; $this->isVariadic = $isVariadic; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); $type = null; $variableName = ''; $isVariadic = false; // if the first item that is encountered is not a variable; it is a type if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { $type = $typeResolver->resolve(array_shift($parts), $context); array_shift($parts); } // if the next item starts with a $ or ...$ it must be the variable name if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$')) { $variableName = array_shift($parts); array_shift($parts); if (substr($variableName, 0, 3) === '...') { $isVariadic = true; $variableName = substr($variableName, 3); } if (substr($variableName, 0, 1) === '$') { $variableName = substr($variableName, 1); } } $description = $descriptionFactory->create(implode('', $parts), $context); return new static($variableName, $type, $isVariadic, $description); } /** * Returns the variable's name. * * @return string */ public function getVariableName() { return $this->variableName; } /** * Returns the variable's type or null if unknown. * * @return Type|null */ public function getType() { return $this->type; } /** * Returns whether this tag is variadic. * * @return boolean */ public function isVariadic() { return $this->isVariadic; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return ($this->type ? $this->type . ' ' : '') . ($this->isVariadic() ? '...' : '') . '$' . $this->variableName . ($this->description ? ' ' . $this->description : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Property.php000066400000000000000000000063241360074523700266210ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}property tag in a Docblock. */ class Property extends BaseTag implements Factory\StaticMethod { /** @var string */ protected $name = 'property'; /** @var Type */ private $type; /** @var string */ protected $variableName = ''; /** * @param string $variableName * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); $this->variableName = $variableName; $this->type = $type; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); $type = null; $variableName = ''; // if the first item that is encountered is not a variable; it is a type if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { $type = $typeResolver->resolve(array_shift($parts), $context); array_shift($parts); } // if the next item starts with a $ or ...$ it must be the variable name if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) { $variableName = array_shift($parts); array_shift($parts); if (substr($variableName, 0, 1) === '$') { $variableName = substr($variableName, 1); } } $description = $descriptionFactory->create(implode('', $parts), $context); return new static($variableName, $type, $description); } /** * Returns the variable's name. * * @return string */ public function getVariableName() { return $this->variableName; } /** * Returns the variable's type or null if unknown. * * @return Type|null */ public function getType() { return $this->type; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return ($this->type ? $this->type . ' ' : '') . '$' . $this->variableName . ($this->description ? ' ' . $this->description : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/PropertyRead.php000066400000000000000000000063421360074523700274150ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}property-read tag in a Docblock. */ class PropertyRead extends BaseTag implements Factory\StaticMethod { /** @var string */ protected $name = 'property-read'; /** @var Type */ private $type; /** @var string */ protected $variableName = ''; /** * @param string $variableName * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); $this->variableName = $variableName; $this->type = $type; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); $type = null; $variableName = ''; // if the first item that is encountered is not a variable; it is a type if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { $type = $typeResolver->resolve(array_shift($parts), $context); array_shift($parts); } // if the next item starts with a $ or ...$ it must be the variable name if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) { $variableName = array_shift($parts); array_shift($parts); if (substr($variableName, 0, 1) === '$') { $variableName = substr($variableName, 1); } } $description = $descriptionFactory->create(implode('', $parts), $context); return new static($variableName, $type, $description); } /** * Returns the variable's name. * * @return string */ public function getVariableName() { return $this->variableName; } /** * Returns the variable's type or null if unknown. * * @return Type|null */ public function getType() { return $this->type; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return ($this->type ? $this->type . ' ' : '') . '$' . $this->variableName . ($this->description ? ' ' . $this->description : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/PropertyWrite.php000066400000000000000000000063451360074523700276370ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}property-write tag in a Docblock. */ class PropertyWrite extends BaseTag implements Factory\StaticMethod { /** @var string */ protected $name = 'property-write'; /** @var Type */ private $type; /** @var string */ protected $variableName = ''; /** * @param string $variableName * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); $this->variableName = $variableName; $this->type = $type; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); $type = null; $variableName = ''; // if the first item that is encountered is not a variable; it is a type if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { $type = $typeResolver->resolve(array_shift($parts), $context); array_shift($parts); } // if the next item starts with a $ or ...$ it must be the variable name if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) { $variableName = array_shift($parts); array_shift($parts); if (substr($variableName, 0, 1) === '$') { $variableName = substr($variableName, 1); } } $description = $descriptionFactory->create(implode('', $parts), $context); return new static($variableName, $type, $description); } /** * Returns the variable's name. * * @return string */ public function getVariableName() { return $this->variableName; } /** * Returns the variable's type or null if unknown. * * @return Type|null */ public function getType() { return $this->type; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return ($this->type ? $this->type . ' ' : '') . '$' . $this->variableName . ($this->description ? ' ' . $this->description : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Reference/000077500000000000000000000000001360074523700261555ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Reference/Fqsen.php000066400000000000000000000016641360074523700277510ustar00rootroot00000000000000 * @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; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Reference/Reference.php000066400000000000000000000010541360074523700305640ustar00rootroot00000000000000 * @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(); } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Reference/Url.php000066400000000000000000000015151360074523700274320ustar00rootroot00000000000000 * @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; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Return_.php000066400000000000000000000036001360074523700264050ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}return tag in a Docblock. */ final class Return_ extends BaseTag implements Factory\StaticMethod { protected $name = 'return'; /** @var Type */ private $type; public function __construct(Type $type, Description $description = null) { $this->type = $type; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::string($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); $parts = preg_split('/\s+/Su', $body, 2); $type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context); $description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context); return new static($type, $description); } /** * Returns the type section of the variable. * * @return Type */ public function getType() { return $this->type; } public function __toString() { return $this->type . ' ' . $this->description; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/See.php000066400000000000000000000047041360074523700255110ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; 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 Webmozart\Assert\Assert; /** * Reflection class for an {@}see tag in a Docblock. */ class See extends BaseTag implements Factory\StaticMethod { protected $name = 'see'; /** @var Reference */ protected $refers = null; /** * Initializes this tag. * * @param Reference $refers * @param Description $description */ public function __construct(Reference $refers, Description $description = null) { $this->refers = $refers; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, FqsenResolver $resolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::string($body); Assert::allNotNull([$resolver, $descriptionFactory]); $parts = preg_split('/\s+/Su', $body, 2); $description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null; // 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 ref of this tag. * * @return Reference */ public function getReference() { return $this->refers; } /** * Returns a string representation of this tag. * * @return string */ public function __toString() { return $this->refers . ($this->description ? ' ' . $this->description->render() : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Since.php000066400000000000000000000047771360074523700260500ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}since tag in a Docblock. */ final class Since extends BaseTag implements Factory\StaticMethod { protected $name = 'since'; /** * PCRE regular expression matching a version vector. * Assumes the "x" modifier. */ const REGEX_VECTOR = '(?: # Normal release vectors. \d\S* | # VCS version vectors. Per PHPCS, they are expected to # follow the form of the VCS name, followed by ":", followed # by the version vector itself. # By convention, popular VCSes like CVS, SVN and GIT use "$" # around the actual version vector. [^\s\:]+\:\s*\$[^\$]+\$ )'; /** @var string The version vector. */ private $version = ''; public function __construct($version = null, Description $description = null) { Assert::nullOrStringNotEmpty($version); $this->version = $version; $this->description = $description; } /** * @return static */ public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) { Assert::nullOrString($body); if (empty($body)) { return new static(); } $matches = []; if (! preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { return null; } return new static( $matches[1], $descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context) ); } /** * Gets the version section of the tag. * * @return string */ public function getVersion() { return $this->version; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return $this->version . ($this->description ? ' ' . $this->description->render() : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Source.php000066400000000000000000000055561360074523700262430ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}source tag in a Docblock. */ final class Source extends BaseTag implements Factory\StaticMethod { /** @var string */ protected $name = 'source'; /** @var int The starting line, relative to the structural element's location. */ private $startingLine = 1; /** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */ private $lineCount = null; public function __construct($startingLine, $lineCount = null, Description $description = null) { Assert::integerish($startingLine); Assert::nullOrIntegerish($lineCount); $this->startingLine = (int)$startingLine; $this->lineCount = $lineCount !== null ? (int)$lineCount : null; $this->description = $description; } /** * {@inheritdoc} */ public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) { Assert::stringNotEmpty($body); Assert::notNull($descriptionFactory); $startingLine = 1; $lineCount = null; $description = null; // Starting line / Number of lines / Description if (preg_match('/^([1-9]\d*)\s*(?:((?1))\s+)?(.*)$/sux', $body, $matches)) { $startingLine = (int)$matches[1]; if (isset($matches[2]) && $matches[2] !== '') { $lineCount = (int)$matches[2]; } $description = $matches[3]; } return new static($startingLine, $lineCount, $descriptionFactory->create($description, $context)); } /** * Gets the starting line. * * @return int The starting line, relative to the structural element's * location. */ public function getStartingLine() { return $this->startingLine; } /** * Returns the number of lines. * * @return int|null The number of lines, relative to the starting line. NULL * means "to the end". */ public function getLineCount() { return $this->lineCount; } public function __toString() { return $this->startingLine . ($this->lineCount !== null ? ' ' . $this->lineCount : '') . ($this->description ? ' ' . $this->description->render() : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Throws.php000066400000000000000000000036151360074523700262630ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}throws tag in a Docblock. */ final class Throws extends BaseTag implements Factory\StaticMethod { protected $name = 'throws'; /** @var Type */ private $type; public function __construct(Type $type, Description $description = null) { $this->type = $type; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::string($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); $parts = preg_split('/\s+/Su', $body, 2); $type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context); $description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context); return new static($type, $description); } /** * Returns the type section of the variable. * * @return Type */ public function getType() { return $this->type; } public function __toString() { return $this->type . ' ' . $this->description; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Uses.php000066400000000000000000000041201360074523700257040ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}uses tag in a Docblock. */ final class Uses extends BaseTag implements Factory\StaticMethod { protected $name = 'uses'; /** @var Fqsen */ protected $refers = null; /** * Initializes this tag. * * @param Fqsen $refers * @param Description $description */ public function __construct(Fqsen $refers, Description $description = null) { $this->refers = $refers; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, FqsenResolver $resolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::string($body); Assert::allNotNull([$resolver, $descriptionFactory]); $parts = preg_split('/\s+/Su', $body, 2); return new static( $resolver->resolve($parts[0], $context), $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context) ); } /** * Returns the structural element this tag refers to. * * @return Fqsen */ public function getReference() { return $this->refers; } /** * Returns a string representation of this tag. * * @return string */ public function __toString() { return $this->refers . ' ' . $this->description->render(); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Var_.php000066400000000000000000000064161360074523700256660ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}var tag in a Docblock. */ class Var_ extends BaseTag implements Factory\StaticMethod { /** @var string */ protected $name = 'var'; /** @var Type */ private $type; /** @var string */ protected $variableName = ''; /** * @param string $variableName * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); $this->variableName = $variableName; $this->type = $type; $this->description = $description; } /** * {@inheritdoc} */ public static function create( $body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); $type = null; $variableName = ''; // if the first item that is encountered is not a variable; it is a type if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { $type = $typeResolver->resolve(array_shift($parts), $context); array_shift($parts); } // if the next item starts with a $ or ...$ it must be the variable name if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) { $variableName = array_shift($parts); array_shift($parts); if (substr($variableName, 0, 1) === '$') { $variableName = substr($variableName, 1); } } $description = $descriptionFactory->create(implode('', $parts), $context); return new static($variableName, $type, $description); } /** * Returns the variable's name. * * @return string */ public function getVariableName() { return $this->variableName; } /** * Returns the variable's type or null if unknown. * * @return Type|null */ public function getType() { return $this->type; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return ($this->type ? $this->type . ' ' : '') . (empty($this->variableName) ? null : ('$' . $this->variableName)) . ($this->description ? ' ' . $this->description : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlock/Tags/Version.php000066400000000000000000000047041360074523700264220ustar00rootroot00000000000000 * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; /** * Reflection class for a {@}version tag in a Docblock. */ final class Version extends BaseTag implements Factory\StaticMethod { protected $name = 'version'; /** * PCRE regular expression matching a version vector. * Assumes the "x" modifier. */ const REGEX_VECTOR = '(?: # Normal release vectors. \d\S* | # VCS version vectors. Per PHPCS, they are expected to # follow the form of the VCS name, followed by ":", followed # by the version vector itself. # By convention, popular VCSes like CVS, SVN and GIT use "$" # around the actual version vector. [^\s\:]+\:\s*\$[^\$]+\$ )'; /** @var string The version vector. */ private $version = ''; public function __construct($version = null, Description $description = null) { Assert::nullOrStringNotEmpty($version); $this->version = $version; $this->description = $description; } /** * @return static */ public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) { Assert::nullOrString($body); if (empty($body)) { return new static(); } $matches = []; if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { return null; } return new static( $matches[1], $descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context) ); } /** * Gets the version section of the tag. * * @return string */ public function getVersion() { return $this->version; } /** * Returns a string representation for this tag. * * @return string */ public function __toString() { return $this->version . ($this->description ? ' ' . $this->description->render() : ''); } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlockFactory.php000066400000000000000000000222061360074523700254240ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\StandardTagFactory; use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\TagFactory; use Webmozart\Assert\Assert; final class DocBlockFactory implements DocBlockFactoryInterface { /** @var DocBlock\DescriptionFactory */ private $descriptionFactory; /** @var DocBlock\TagFactory */ private $tagFactory; /** * Initializes this factory with the required subcontractors. * * @param DescriptionFactory $descriptionFactory * @param TagFactory $tagFactory */ public function __construct(DescriptionFactory $descriptionFactory, TagFactory $tagFactory) { $this->descriptionFactory = $descriptionFactory; $this->tagFactory = $tagFactory; } /** * Factory method for easy instantiation. * * @param string[] $additionalTags * * @return DocBlockFactory */ public static function createInstance(array $additionalTags = []) { $fqsenResolver = new FqsenResolver(); $tagFactory = new StandardTagFactory($fqsenResolver); $descriptionFactory = new DescriptionFactory($tagFactory); $tagFactory->addService($descriptionFactory); $tagFactory->addService(new TypeResolver($fqsenResolver)); $docBlockFactory = new self($descriptionFactory, $tagFactory); foreach ($additionalTags as $tagName => $tagHandler) { $docBlockFactory->registerTagHandler($tagName, $tagHandler); } return $docBlockFactory; } /** * @param object|string $docblock A string containing the DocBlock to parse or an object supporting the * getDocComment method (such as a ReflectionClass object). * @param Types\Context $context * @param Location $location * * @return DocBlock */ public function create($docblock, Types\Context $context = null, Location $location = null) { if (is_object($docblock)) { if (!method_exists($docblock, 'getDocComment')) { $exceptionMessage = 'Invalid object passed; the given object must support the getDocComment method'; throw new \InvalidArgumentException($exceptionMessage); } $docblock = $docblock->getDocComment(); } Assert::stringNotEmpty($docblock); if ($context === null) { $context = new Types\Context(''); } $parts = $this->splitDocBlock($this->stripDocComment($docblock)); list($templateMarker, $summary, $description, $tags) = $parts; return new DocBlock( $summary, $description ? $this->descriptionFactory->create($description, $context) : null, array_filter($this->parseTagBlock($tags, $context), function ($tag) { return $tag instanceof Tag; }), $context, $location, $templateMarker === '#@+', $templateMarker === '#@-' ); } public function registerTagHandler($tagName, $handler) { $this->tagFactory->registerTagHandler($tagName, $handler); } /** * Strips the asterisks from the DocBlock comment. * * @param string $comment String containing the comment text. * * @return string */ private function stripDocComment($comment) { $comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment)); // reg ex above is not able to remove */ from a single line docblock if (substr($comment, -2) === '*/') { $comment = trim(substr($comment, 0, -2)); } return str_replace(["\r\n", "\r"], "\n", $comment); } /** * Splits the DocBlock into a template marker, summary, description and block of tags. * * @param string $comment Comment to split into the sub-parts. * * @author Richard van Velzen (@_richardJ) Special thanks to Richard for the regex responsible for the split. * @author Mike van Riel for extending the regex with template marker support. * * @return string[] containing the template marker (if any), summary, description and a string containing the tags. */ private function splitDocBlock($comment) { // Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This // method does not split tags so we return this verbatim as the fourth result (tags). This saves us the // performance impact of running a regular expression if (strpos($comment, '@') === 0) { return ['', '', '', $comment]; } // clears all extra horizontal whitespace from the line endings to prevent parsing issues $comment = preg_replace('/\h*$/Sum', '', $comment); /* * Splits the docblock into a template marker, summary, description and tags section. * * - The template marker is empty, #@+ or #@- if the DocBlock starts with either of those (a newline may * occur after it and will be stripped). * - The short description is started from the first character until a dot is encountered followed by a * newline OR two consecutive newlines (horizontal whitespace is taken into account to consider spacing * errors). This is optional. * - The long description, any character until a new line is encountered followed by an @ and word * characters (a tag). This is optional. * - Tags; the remaining characters * * Big thanks to RichardJ for contributing this Regular Expression */ preg_match( '/ \A # 1. Extract the template marker (?:(\#\@\+|\#\@\-)\n?)? # 2. Extract the summary (?: (?! @\pL ) # The summary may not start with an @ ( [^\n.]+ (?: (?! \. \n | \n{2} ) # End summary upon a dot followed by newline or two newlines [\n.] (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line [^\n.]+ # Include anything else )* \.? )? ) # 3. Extract the description (?: \s* # Some form of whitespace _must_ precede a description because a summary must be there (?! @\pL ) # The description may not start with an @ ( [^\n]+ (?: \n+ (?! [ \t]* @\pL ) # End description when an @ is found as first character on a new line [^\n]+ # Include anything else )* ) )? # 4. Extract the tags (anything that follows) (\s+ [\s\S]*)? # everything that follows /ux', $comment, $matches ); array_shift($matches); while (count($matches) < 4) { $matches[] = ''; } return $matches; } /** * Creates the tag objects. * * @param string $tags Tag block to parse. * @param Types\Context $context Context of the parsed Tag * * @return DocBlock\Tag[] */ private function parseTagBlock($tags, Types\Context $context) { $tags = $this->filterTagBlock($tags); if (!$tags) { return []; } $result = $this->splitTagBlockIntoTagLines($tags); foreach ($result as $key => $tagLine) { $result[$key] = $this->tagFactory->create(trim($tagLine), $context); } return $result; } /** * @param string $tags * * @return string[] */ private function splitTagBlockIntoTagLines($tags) { $result = []; foreach (explode("\n", $tags) as $tag_line) { if (isset($tag_line[0]) && ($tag_line[0] === '@')) { $result[] = $tag_line; } else { $result[count($result) - 1] .= "\n" . $tag_line; } } return $result; } /** * @param $tags * @return string */ private function filterTagBlock($tags) { $tags = trim($tags); if (!$tags) { return null; } if ('@' !== $tags[0]) { // @codeCoverageIgnoreStart // Can't simulate this; this only happens if there is an error with the parsing of the DocBlock that // we didn't foresee. throw new \LogicException('A tag block started with text instead of an at-sign(@): ' . $tags); // @codeCoverageIgnoreEnd } return $tags; } } php-phpdocumentor-reflection-docblock-4.3.3/src/DocBlockFactoryInterface.php000066400000000000000000000010411360074523700272370ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; use Mockery as m; use PHPUnit\Framework\TestCase; /** * @coversNothing */ final class DocblocksWithAnnotationsTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } public function testDocblockWithAnnotations() { $docComment = <<create($docComment); $this->assertCount(3, $docblock->getTags()); } public function testDocblockWithAnnotationHavingZeroValue() { $docComment = <<create($docComment); $this->assertSame(0, printf('%i', $docblock->getTagsByName('my-tag'))); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/integration/InterpretingDocBlocksTest.php000066400000000000000000000066341360074523700324170ustar00rootroot00000000000000 * @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\StandardTagFactory; use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\Tags\See; use PHPUnit\Framework\TestCase; /** * @coversNothing */ class InterpretingDocBlocksTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } public function testInterpretingASimpleDocBlock() { /** * @var DocBlock $docblock * @var string $summary * @var Description $description */ include(__DIR__ . '/../../examples/01-interpreting-a-simple-docblock.php'); $descriptionText = <<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 ); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/integration/ReconstitutingADocBlockTest.php000066400000000000000000000016651360074523700327030ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; use Mockery as m; use PHPUnit\Framework\TestCase; /** * @coversNothing */ class ReconstitutingADocBlockTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } public function testReconstituteADocBlock() { /** * @var string $docComment * @var string $reconstitutedDocComment */ include(__DIR__ . '/../../examples/03-reconstituting-a-docblock.php'); $this->assertSame($docComment, $reconstitutedDocComment); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/integration/UsingTagsTest.php000066400000000000000000000024631360074523700300610ustar00rootroot00000000000000 * @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\Tag; use PHPUnit\Framework\TestCase; /** * @coversNothing */ class UsingTagsTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } 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); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/000077500000000000000000000000001360074523700232335ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/000077500000000000000000000000001360074523700247135ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/DescriptionFactoryTest.php000066400000000000000000000136111360074523700321010ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\DescriptionFactory * @covers :: */ class DescriptionFactoryTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 = <<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 }.'], ]; } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/DescriptionTest.php000066400000000000000000000110151360074523700305450ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Description */ class DescriptionTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 ::getTags * @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic * @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag */ public function testDescriptionTagsGetter() { $body = '@JoinTable(name="table", joinColumns=%1$s, inverseJoinColumns=%2$s)'; $tag1 = new Generic('JoinColumn', new Description('(name="column_id", referencedColumnName="id")')); $tag2 = new Generic('JoinColumn', new Description('(name="column_id_2", referencedColumnName="id")')); $tags = [ $tag1, $tag2, ]; $fixture = new Description($body, $tags); $this->assertEquals(2, count($fixture->getTags())); $actualTags = $fixture->getTags(); $this->assertSame($tags, $actualTags); $this->assertSame($tag1, $actualTags[0]); $this->assertSame($tag2, $actualTags[1]); } /** * @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 testDescriptionMultipleTagsCanBeCastToString() { $body = '@JoinTable(name="table", joinColumns=%1$s, inverseJoinColumns=%2$s)'; $tag1 = new Generic('JoinColumn', new Description('(name="column_id", referencedColumnName="id")')); $tag2 = new Generic('JoinColumn', new Description('(name="column_id_2", referencedColumnName="id")')); $tags = [ $tag1, $tag2, ]; $fixture = new Description($body, $tags); $expected = '@JoinTable(name="table", joinColumns={@JoinColumn (name="column_id", referencedColumnName="id")}, inverseJoinColumns={@JoinColumn (name="column_id_2", referencedColumnName="id")})'; $this->assertSame($expected, (string)$fixture); } /** * @covers ::__construct * @expectedException \InvalidArgumentException */ public function testBodyTemplateMustBeAString() { new Description([]); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/ExampleFinderTest.php000066400000000000000000000017471360074523700310200ustar00rootroot00000000000000 */ class ExampleFinderTest extends TestCase { /** @var ExampleFinder */ private $fixture; /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } public function setUp() { $this->fixture = new ExampleFinder(); } /** * @covers ::find * @covers ::getSourceDirectory * @uses \phpDocumentor\Reflection\DocBlock\Tags\Example * @uses \phpDocumentor\Reflection\DocBlock\Description */ public function testFileNotFound() { $example = new Example('./example.php', false, 1, 0, new Description('Test')); $this->assertSame('** File not found : ./example.php **', $this->fixture->find($example)); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/SerializerTest.php000066400000000000000000000144111360074523700303760ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Serializer * @covers :: */ class SerializerTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 * @covers ::getDocComment */ public function testNoExtraSpacesAfterTagRemoval() { $expected = <<<'DOCCOMMENT' /** * @unknown-tag */ DOCCOMMENT; $expectedAfterRemove = <<<'DOCCOMMENT_AFTER_REMOVE' /** */ DOCCOMMENT_AFTER_REMOVE; $fixture = new Serializer(0, '', true, 15); $genericTag = new DocBlock\Tags\Generic('unknown-tag'); $docBlock = new DocBlock('', null, [$genericTag]); $this->assertSame($expected, $fixture->getDocComment($docBlock)); $docBlock->removeTag($genericTag); $this->assertSame($expectedAfterRemove, $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, []); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/StandardTagFactoryTest.php000066400000000000000000000316671360074523700320250ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass phpDocumentor\Reflection\DocBlock\StandardTagFactory * @covers :: */ class StandardTagFactoryTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 ', $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 * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen */ 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 ', $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() { $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 '); $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()); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/000077500000000000000000000000001360074523700256115ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/AuthorTest.php000066400000000000000000000112201360074523700304200ustar00rootroot00000000000000 * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; use Mockery as m; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Author * @covers :: */ class AuthorTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 ', $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 ', (string) $fixture); } /** * @covers ::__construct * @covers ::__toString */ public function testStringRepresentationWithEmtpyEmail() { $fixture = new Author('Mike van Riel', ''); $this->assertSame('Mike van Riel', (string) $fixture); } /** * @covers ::create * @uses \phpDocumentor\Reflection\DocBlock\Tags\Author:: */ public function testFactoryMethod() { $fixture = Author::create('Mike van Riel '); $this->assertSame('Mike van Riel ', (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 function testFactoryMethodReturnsNullIfItCouldNotReadBody() { $this->assertNull(Author::create('dfgr<')); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/CoversTest.php000066400000000000000000000124451360074523700304310ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Covers * @covers :: */ class CoversTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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('')); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/DeprecatedTest.php000066400000000000000000000132631360074523700312270ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Deprecated * @covers :: */ class DeprecatedTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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 * @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__construct */ public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex() { $this->assertEquals(new Deprecated(), Deprecated::create('dkhf<')); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/ExampleTest.php000066400000000000000000000064231360074523700305620ustar00rootroot00000000000000assertEquals('"example1.php"', $tag->getContent()); $this->assertEquals('', $tag->getDescription()); $this->assertEquals('example', $tag->getName()); } /** * @covers ::create * @covers ::__construct * @covers ::getFilePath * @covers ::getDescription * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag */ public function testWithDescription() { $tag = Example::create('"example1.php" some text'); $this->assertEquals('example1.php', $tag->getFilePath()); $this->assertEquals('some text', $tag->getDescription()); } /** * @covers ::create * @covers ::__construct * @covers ::getFilePath * @covers ::getStartingLine * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag */ public function testStartlineIsParsed() { $tag = Example::create('"example1.php" 10'); $this->assertEquals('example1.php', $tag->getFilePath()); $this->assertEquals(10, $tag->getStartingLine()); } /** * @covers ::create * @covers ::__construct * @covers ::getFilePath * @covers ::getStartingLine * @covers ::getDescription * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag */ public function testAllowOmitingLineCount() { $tag = Example::create('"example1.php" 10 some text'); $this->assertEquals('example1.php', $tag->getFilePath()); $this->assertEquals(10, $tag->getStartingLine()); $this->assertEquals('some text', $tag->getDescription()); } /** * @covers ::create * @covers ::__construct * @covers ::getFilePath * @covers ::getStartingLine * @covers ::getLineCount * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag */ public function testLengthIsParsed() { $tag = Example::create('"example1.php" 10 5'); $this->assertEquals('example1.php', $tag->getFilePath()); $this->assertEquals(10, $tag->getStartingLine()); $this->assertEquals(5, $tag->getLineCount()); } /** * @covers ::create * @covers ::__construct * @covers ::getFilePath * @covers ::getStartingLine * @covers ::getLineCount * @covers ::getDescription * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag */ public function testFullExample() { $tag = Example::create('"example1.php" 10 5 test text'); $this->assertEquals('example1.php', $tag->getFilePath()); $this->assertEquals(10, $tag->getStartingLine()); $this->assertEquals(5, $tag->getLineCount()); $this->assertEquals('test text', $tag->getDescription()); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/Formatter/000077500000000000000000000000001360074523700275545ustar00rootroot00000000000000AlignFormatterTest.php000066400000000000000000000041431360074523700337660ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/Formatter * @copyright 2017 Mike van Riel * @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\Link; use phpDocumentor\Reflection\DocBlock\Tags\Param; use phpDocumentor\Reflection\DocBlock\Tags\Version; use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Formatter\AlignFormatter */ class AlignFormatterTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @covers ::format * @covers \phpDocumentor\Reflection\DocBlock\Tags\Formatter\AlignFormatter::__construct * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag * @uses \phpDocumentor\Reflection\DocBlock\Tags\Link * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param * @uses \phpDocumentor\Reflection\DocBlock\Tags\Version * @uses \phpDocumentor\Reflection\Types\String_ */ public function testFormatterCallsToStringAndReturnsAStandardRepresentation() { $tags = [ new Param('foobar', new String_()), new Version('1.2.0'), new Link('http://www.example.com', new Description('Examples')) ]; $fixture = new AlignFormatter($tags); $expected = [ '@param string $foobar', '@version 1.2.0', '@link http://www.example.com Examples' ]; foreach ($tags as $key => $tag) { $this->assertSame( $expected[$key], $fixture->format($tag) ); } } } PassthroughFormatterTest.php000066400000000000000000000035751360074523700352530ustar00rootroot00000000000000php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/Formatter * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter */ class PassthroughFormatterTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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'))) ); } /** * @covers ::format * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag * @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic */ public function testFormatterToStringWitoutDescription() { $expected = '@unknown-tag'; $fixture = new PassthroughFormatter(); $this->assertSame( $expected, $fixture->format(new Generic('unknown-tag')) ); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/GenericTest.php000066400000000000000000000115771360074523700305510ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Generic * @covers :: */ class GenericTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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'); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/LinkTest.php000066400000000000000000000127321360074523700300640ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Link * @covers :: */ class LinkTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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([])); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/MethodTest.php000066400000000000000000000463751360074523700304210ustar00rootroot00000000000000 * @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\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\This; use phpDocumentor\Reflection\Types\Void_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Method * @covers :: */ class MethodTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__construct * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::getArguments * @uses \phpDocumentor\Reflection\DocBlock\Description */ 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:: * @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()); } /** * @covers ::create * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method:: * @uses \phpDocumentor\Reflection\TypeResolver * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\Types\Context */ public function testReturnTypeThis() { $descriptionFactory = m::mock(DescriptionFactory::class); $resolver = new TypeResolver(); $context = new Context(''); $description = new Description(''); $descriptionFactory->shouldReceive('create')->with('', $context)->andReturn($description); $fixture = Method::create( 'static $this myMethod()', $resolver, $descriptionFactory, $context ); $this->assertTrue($fixture->isStatic()); $this->assertSame('static $this myMethod()', (string)$fixture); $this->assertSame('myMethod', $fixture->getMethodName()); $this->assertInstanceOf(This::class, $fixture->getReturnType()); } 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:: * @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:: * @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()); } /** * @covers ::create * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method:: * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory * @uses \phpDocumentor\Reflection\TypeResolver * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\Types\Context * * @covers ::create */ public function testCreateMethodEmptyArguments() : void { $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()); } /** * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method:: * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory * @uses \phpDocumentor\Reflection\TypeResolver * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Void_ */ public function testCreateWithoutReturnType() { $descriptionFactory = m::mock(DescriptionFactory::class); $resolver = new TypeResolver(); $context = new Context(''); $description = new Description(''); $descriptionFactory->shouldReceive('create')->with('', $context)->andReturn($description); $fixture = Method::create( 'myMethod()', $resolver, $descriptionFactory, $context ); $this->assertSame('void myMethod()', (string)$fixture); $this->assertSame('myMethod', $fixture->getMethodName()); $this->assertEquals([], $fixture->getArguments()); $this->assertInstanceOf(Void_::class, $fixture->getReturnType()); $this->assertSame($description, $fixture->getDescription()); } /** * @covers ::create * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method:: * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory * @uses \phpDocumentor\Reflection\TypeResolver * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Integer * @uses \phpDocumentor\Reflection\Types\Object_ */ public function testCreateWithMixedReturnTypes() { $descriptionFactory = m::mock(DescriptionFactory::class); $resolver = new TypeResolver(); $context = new Context(''); $descriptionFactory->shouldReceive('create')->andReturn(new Description('')); $fixture = Method::create( 'MyClass[]|int[] myMethod()', $resolver, $descriptionFactory, $context ); $this->assertSame('\MyClass[]|int[] myMethod()', (string)$fixture); $this->assertSame('myMethod', $fixture->getMethodName()); $this->assertEquals([], $fixture->getArguments()); $this->assertEquals( new Compound([ new Array_(new Object_(new Fqsen('\MyClass'))), new Array_(new Integer()), ]), $fixture->getReturnType() ); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/ParamTest.php000066400000000000000000000167661360074523700302420ustar00rootroot00000000000000 * @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_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Param * @covers :: */ class ParamTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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, []); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/PropertyReadTest.php000066400000000000000000000154341360074523700316110ustar00rootroot00000000000000 * @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_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead * @covers :: */ class PropertyReadTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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([]); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/PropertyTest.php000066400000000000000000000151621360074523700310130ustar00rootroot00000000000000 * @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_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Property * @covers :: */ class PropertyTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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([]); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/PropertyWriteTest.php000066400000000000000000000154671360074523700320360ustar00rootroot00000000000000 * @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_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite * @covers :: */ class PropertyWriteTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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([]); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/ReturnTest.php000066400000000000000000000130231360074523700304400ustar00rootroot00000000000000 * @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_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Return_ * @covers :: */ class ReturnTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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_:: * @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()); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/SeeTest.php000066400000000000000000000176631360074523700277130ustar00rootroot00000000000000 * @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\DocBlock\Tags\Reference\Fqsen as FqsenRef; use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url as UrlRef; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\See * @covers :: */ class SeeTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__construct * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen * @uses \phpDocumentor\Reflection\Fqsen * @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName */ public function testIfCorrectTagNameIsReturned() { $fixture = new See(new FqsenRef(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 * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen * @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render * @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName */ public function testIfTagCanBeRenderedUsingDefaultFormatter() { $fixture = new See(new FqsenRef(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 * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen * @uses \phpDocumentor\Reflection\Fqsen * @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render */ public function testIfTagCanBeRenderedUsingSpecificFormatter() { $fixture = new See(new FqsenRef(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)); } /** * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen * @uses \phpDocumentor\Reflection\Fqsen * @covers ::__construct * @covers ::getReference */ public function testHasReferenceToFqsen() { $expected = new FqsenRef(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 * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen * @uses \phpDocumentor\Reflection\Fqsen */ public function testHasDescription() { $expected = new Description('Description'); $fixture = new See(new FqsenRef(new Fqsen('\DateTime')), $expected); $this->assertSame($expected, $fixture->getDescription()); } /** * @covers ::__construct * @covers ::__toString * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen * @uses \phpDocumentor\Reflection\Fqsen */ public function testStringRepresentationIsReturned() { $fixture = new See(new FqsenRef(new Fqsen('\DateTime::format()')), new Description('Description')); $this->assertSame('\DateTime::format() Description', (string)$fixture); } /** * @covers ::create * @uses \phpDocumentor\Reflection\DocBlock\Tags\See:: * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory * @uses \phpDocumentor\Reflection\FqsenResolver * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen * @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->assertInstanceOf(FqsenRef::class, $fixture->getReference()); $this->assertSame((string)$fqsen, (string)$fixture->getReference()); $this->assertSame($description, $fixture->getDescription()); } /** * @covers ::create * @uses \phpDocumentor\Reflection\DocBlock\Tags\See:: * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory * @uses \phpDocumentor\Reflection\FqsenResolver * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url * @uses \phpDocumentor\Reflection\Types\Context */ public function testFactoryMethodWithUrl() { $descriptionFactory = m::mock(DescriptionFactory::class); $resolver = m::mock(FqsenResolver::class); $context = new Context(''); $description = new Description('My Description'); $descriptionFactory ->shouldReceive('create')->with('My Description', $context)->andReturn($description); $resolver->shouldNotReceive('resolve'); $fixture = See::create('https://test.org My Description', $resolver, $descriptionFactory, $context); $this->assertSame('https://test.org My Description', (string)$fixture); $this->assertInstanceOf(UrlRef::class, $fixture->getReference()); $this->assertSame('https://test.org', (string)$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()); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/SinceTest.php000066400000000000000000000127651360074523700302360ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Since * @covers :: */ class SinceTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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<')); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/SourceTest.php000066400000000000000000000143161360074523700304270ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Source * @covers :: */ class SourceTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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', []); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/ThrowsTest.php000066400000000000000000000130361360074523700304530ustar00rootroot00000000000000 * @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_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Throws * @covers :: */ class ThrowsTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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()); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/UsesTest.php000066400000000000000000000133021360074523700301000ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Uses * @covers :: */ class UsesTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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()); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/VarTest.php000066400000000000000000000155351360074523700277230ustar00rootroot00000000000000 * @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_; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Var_ * @covers :: */ class VarTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 * @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render */ public function testIfVariableNameIsOmmitedIfEmpty() { $fixture = new Var_('', null, null); $this->assertSame('@var', $fixture->render()); } /** * @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_:: * @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_:: * @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_([]); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlock/Tags/VersionTest.php000066400000000000000000000130401360074523700306050ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Version * @covers :: */ class VersionTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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:: * @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:: * @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<')); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlockFactoryTest.php000066400000000000000000000224731360074523700276240ustar00rootroot00000000000000 * @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; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass phpDocumentor\Reflection\DocBlockFactory * @covers :: * @uses \Webmozart\Assert\Assert * @uses phpDocumentor\Reflection\DocBlock */ class DocBlockFactoryTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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 = <<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 = << 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 = << 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.', '' ], [ <<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 = << 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 = << This is with * multiline description. */ DOCBLOCK; $docblock = $fixture->create($given, new Context('')); $this->assertEquals([], $docblock->getTags()); } } php-phpdocumentor-reflection-docblock-4.3.3/tests/unit/DocBlockTest.php000066400000000000000000000167111360074523700262720ustar00rootroot00000000000000 * @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\Tags\Deprecated; use phpDocumentor\Reflection\Types\Context; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass phpDocumentor\Reflection\DocBlock * @covers :: * @uses \Webmozart\Assert\Assert */ class DocBlockTest extends TestCase { /** * Call Mockery::close after each test. */ public function tearDown() { m::close(); } /** * @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()); } /** * @covers ::__construct * @covers ::removeTag * * @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated */ public function testRemoveTag() { $someTag = new Deprecated(); $anotherTag = new Deprecated(); $fixture = new DocBlock('', null, [$someTag]); $this->assertCount(1, $fixture->getTags()); $fixture->removeTag($anotherTag); $this->assertCount(1, $fixture->getTags()); $fixture->removeTag($someTag); $this->assertCount(0, $fixture->getTags()); } }