diff --git a/.github/main.workflow b/.github/main.workflow index 04d7fe5..60dd027 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -2,6 +2,7 @@ workflow "Qa workflow" { on = "push" resolves = [ "PHPStan", + "Psalm", "composer-require-checker", "Code style check", ] @@ -28,8 +29,14 @@ action "composer-require-checker" { } action "Code style check" { - uses = "docker://oskarstark/phpcs-ga" + uses = "docker://phpdoc/phpcs-ga:master" + secrets = ["GITHUB_TOKEN"] + args = "-d memory_limit=1024M -s" + needs = ["composer"] +} + +action "Psalm" { + uses = "docker://mickaelandrieu/psalm-ga" secrets = ["GITHUB_TOKEN"] - args = "-d memory_limit=1024M" needs = ["composer"] } diff --git a/composer.json b/composer.json index 540d278..b9ca030 100644 --- a/composer.json +++ b/composer.json @@ -9,15 +9,14 @@ "email": "me@mikevanriel.com" } ], - "minimum-stability": "beta", "require": { - "php": ">=7.1", + "php": "^7.1", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { "mockery/mockery": "~1", - "phpunit/phpunit": "~6", - "ext-tokenizer": "^7.1" + "ext-tokenizer": "^7.1", + "phpunit/phpunit": "^7.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 72e114f..529abe6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,11 +4,11 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "06b34e8692439fcd33da549a3379fe6e", + "content-hash": "8168e5df1ad1444a9512e8b63bab2bfe", "packages": [ { "name": "phpdocumentor/reflection-common", - "version": "2.0.0-beta1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", @@ -60,94 +60,41 @@ } ], "packages-dev": [ - { - "name": "dflydev/markdown", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/dflydev/dflydev-markdown.git", - "reference": "76501a808522dbe40a5a71d272bd08d54cbae03d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dflydev/dflydev-markdown/zipball/76501a808522dbe40a5a71d272bd08d54cbae03d", - "reference": "76501a808522dbe40a5a71d272bd08d54cbae03d", - "shasum": "" - }, - "require": { - "php": ">=5.3" - }, - "type": "library", - "autoload": { - "psr-0": { - "dflydev\\markdown": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "New BSD License" - ], - "authors": [ - { - "name": "Dragonfly Development Inc.", - "email": "info@dflydev.com", - "homepage": "http://dflydev.com" - }, - { - "name": "Beau Simensen", - "email": "beau@dflydev.com", - "homepage": "http://beausimensen.com" - }, - { - "name": "Michel Fortin", - "homepage": "http://michelf.com" - }, - { - "name": "John Gruber", - "homepage": "http://daringfireball.net" - } - ], - "description": "PHP Markdown & Extra", - "homepage": "http://github.com/dflydev/dflydev-markdown", - "keywords": [ - "markdown" - ], - "abandoned": "michelf/php-markdown", - "time": "2012-01-02T23:11:32+00:00" - }, { "name": "doctrine/instantiator", - "version": "1.0.4", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + "reference": "a2c590166b2133a4633738648b6b064edae0814a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "2.0.*@ALPHA" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Instantiator\\": "src" + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" } }, "notification-url": "https://packagist.org/downloads/", @@ -162,12 +109,12 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2014-10-13T12:58:55+00:00" + "time": "2019-03-17T17:37:11+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -219,16 +166,16 @@ }, { "name": "mockery/mockery", - "version": "1.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38" + "reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/1bac8c362b12f522fdd1f1fa3556284c91affa38", - "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38", + "url": "https://api.github.com/repos/mockery/mockery/zipball/0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2", + "reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2", "shasum": "" }, "require": { @@ -237,7 +184,7 @@ "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "~5.7|~6.1" + "phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0" }, "type": "library", "extra": { @@ -266,8 +213,8 @@ "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", + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", "keywords": [ "BDD", "TDD", @@ -280,41 +227,47 @@ "test double", "testing" ], - "time": "2017-10-06T16:20:43+00:00" + "time": "2019-02-13T09:37:52+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.3.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "96fbdc07635989c35c5a1912379f4c4b2ab15fd5" + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/96fbdc07635989c35c5a1912379f4c4b2ab15fd5", - "reference": "96fbdc07635989c35c5a1912379f4c4b2ab15fd5", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.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", - "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ "clone", "copy", @@ -322,28 +275,133 @@ "object", "object graph" ], - "time": "2015-03-21T22:40:23+00:00" + "time": "2019-04-07T13:18:21+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "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": "2018-07-08T19:23:20+00:00" + }, + { + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "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": "2018-07-08T19:19:57+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "2.0.0", + "version": "2.0.5", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "66ae84e9d7c8ea85c979cb65977bd8e608baf0c5" + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/66ae84e9d7c8ea85c979cb65977bd8e608baf0c5", - "reference": "66ae84e9d7c8ea85c979cb65977bd8e608baf0c5", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e6a969a640b00d8daa3c66518b0405fb41ae0c4b", + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b", "shasum": "" }, "require": { - "dflydev/markdown": "1.0.*", "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "3.7.*@stable" + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" }, "type": "library", "extra": { @@ -368,37 +426,37 @@ "email": "mike.vanriel@naenius.com" } ], - "time": "2013-08-07T11:04:22+00:00" + "time": "2016-01-25T08:17:30+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.6.2", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb" + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/6c52c2722f8460122f96f86346600e1077ce22cb", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1", - "sebastian/recursion-context": "^1.0|^2.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { - "phpspec/phpspec": "^2.0", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -431,43 +489,44 @@ "spy", "stub" ], - "time": "2016-11-21T14:58:47+00:00" + "time": "2018-08-05T17:53:17+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.0.0", + "version": "6.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "e7d7a4acca58e45bdfd00221563d131cfb04ba96" + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e7d7a4acca58e45bdfd00221563d131cfb04ba96", - "reference": "e7d7a4acca58e45bdfd00221563d131cfb04ba96", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", "shasum": "" }, "require": { - "php": "^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.2", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^2.0", - "sebastian/version": "^2.0" + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.1", + "phpunit/php-file-iterator": "^2.0", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.1 || ^4.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": "^2.5", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^7.0" }, "suggest": { - "ext-dom": "*", - "ext-xmlwriter": "*" + "ext-xdebug": "^2.6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0.x-dev" + "dev-master": "6.1-dev" } }, "autoload": { @@ -482,7 +541,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -493,29 +552,32 @@ "testing", "xunit" ], - "time": "2017-02-02T10:35:41+00:00" + "time": "2018-10-31T16:06:48+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", - "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -530,7 +592,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -540,20 +602,20 @@ "filesystem", "iterator" ], - "time": "2015-04-02T05:19:05+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "shasum": "" }, "require": { @@ -562,20 +624,17 @@ "type": "library", "autoload": { "classmap": [ - "Text/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -584,26 +643,34 @@ "keywords": [ "template" ], - "time": "2014-01-30T17:20:04+00:00" + "time": "2015-06-21T13:50:34+00:00" }, { "name": "phpunit/php-timer", - "version": "1.0.6", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d" + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d", - "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -616,7 +683,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -625,33 +692,33 @@ "keywords": [ "timer" ], - "time": "2015-06-13T07:35:30+00:00" + "time": "2019-06-07T04:22:29+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.2", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "db63be1159c81df649cd0260e30249a586d4129e" + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/db63be1159c81df649cd0260e30249a586d4129e", - "reference": "db63be1159c81df649cd0260e30249a586d4129e", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -674,55 +741,57 @@ "keywords": [ "tokenizer" ], - "time": "2015-06-12T07:34:24+00:00" + "time": "2018-10-30T05:52:18+00:00" }, { "name": "phpunit/phpunit", - "version": "6.0.0", + "version": "7.5.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9d0c024d2099531442d862b66b0ad7cf35ed8e78" + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9d0c024d2099531442d862b66b0ad7cf35ed8e78", - "reference": "9d0c024d2099531442d862b66b0ad7cf35ed8e78", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.3", - "php": "^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^5.0", - "phpunit/php-file-iterator": "^1.4", - "phpunit/php-text-template": "^1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^4.0", - "sebastian/comparator": "^1.2.4", - "sebastian/diff": "^1.2", - "sebastian/environment": "^2.0", - "sebastian/exporter": "^2.0", - "sebastian/global-state": "^1.1", - "sebastian/object-enumerator": "^2.0", - "sebastian/resource-operations": "^1.0", - "sebastian/version": "^2.0" + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", + "php": "^7.1", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-file-iterator": "^2.0.1", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1", + "sebastian/comparator": "^3.0", + "sebastian/diff": "^3.0", + "sebastian/environment": "^4.0", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0", + "sebastian/version": "^2.0.1" }, "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2", - "phpunit/dbunit": "<3.0" + "phpunit/phpunit-mock-objects": "*" }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^1.1" + "phpunit/php-invoker": "^2.0" }, "bin": [ "phpunit" @@ -730,7 +799,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.0.x-dev" + "dev-master": "7.5-dev" } }, "autoload": { @@ -756,87 +825,27 @@ "testing", "xunit" ], - "time": "2017-02-03T05:22:46+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "4.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "3819745c44f3aff9518fd655f320c4535d541af7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3819745c44f3aff9518fd655f320c4535d541af7", - "reference": "3819745c44f3aff9518fd655f320c4535d541af7", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^2.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" - ], - "abandoned": true, - "time": "2017-02-02T10:36:38+00:00" + "time": "2019-05-28T11:59:40+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe" + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", "shasum": "" }, "require": { - "php": ">=5.6" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^5.7 || ^6.0" }, "type": "library", "extra": { @@ -861,34 +870,34 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2016-02-13T06:45:14+00:00" + "time": "2017-03-04T06:30:41+00:00" }, { "name": "sebastian/comparator", - "version": "1.2.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -919,38 +928,39 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-01-29T09:50:25+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "1.2.0", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -973,36 +983,42 @@ } ], "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", + "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2014-08-15T10:29:00+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "2.0.0", + "version": "4.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1027,34 +1043,34 @@ "environment", "hhvm" ], - "time": "2016-11-26T07:53:53+00:00" + "time": "2019-05-05T09:05:15+00:00" }, { "name": "sebastian/exporter", - "version": "2.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -1094,27 +1110,27 @@ "export", "exporter" ], - "time": "2016-11-19T08:54:04+00:00" + "time": "2017-04-03T13:19:02+00:00" }, { "name": "sebastian/global-state", - "version": "1.1.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97" + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23af31f402993cfd94e99cbc4b782e9a78eb0e97", - "reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-uopz": "*" @@ -1122,7 +1138,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1145,33 +1161,34 @@ "keywords": [ "global state" ], - "time": "2015-06-21T15:11:22+00:00" + "time": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", - "version": "2.0.0", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35" + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1191,32 +1208,77 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2016-11-19T07:35:10+00:00" + "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": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1244,29 +1306,29 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-11-19T07:33:16+00:00" + "time": "2017-03-03T06:23:57+00:00" }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1286,20 +1348,20 @@ ], "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" + "time": "2018-10-04T04:07:39+00:00" }, { "name": "sebastian/version", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5" + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", - "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", "shasum": "" }, "require": { @@ -1329,18 +1391,56 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-02-04T12:56:52+00:00" + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8", + "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8", + "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": "2019-04-04T09:56:43+00:00" } ], "aliases": [], - "minimum-stability": "beta", - "stability-flags": { - "phpdocumentor/reflection-common": 10 - }, + "minimum-stability": "stable", + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.1" + "php": "^7.1" }, "platform-dev": { "ext-tokenizer": "^7.1" diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 732b5fe..c030e8d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -6,10 +6,25 @@ tests/unit */tests/unit/Types/ContextFactoryTest.php - - *\.php - - - */src/*_.php - + + *\.php + + + + + + + + */src/*_.php + + + + */src/*/Abstract*.php + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d8dc1f1..d2bfaf3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,6 @@ colors="true" verbose="true" forceCoversAnnotation="true" - checkForUnintentionallyCoveredCode="false" > @@ -23,13 +22,10 @@ - + + + + + + + + + + + + + diff --git a/src/FqsenResolver.php b/src/FqsenResolver.php index e90b7ff..1f9fe50 100644 --- a/src/FqsenResolver.php +++ b/src/FqsenResolver.php @@ -1,25 +1,30 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; +use InvalidArgumentException; use phpDocumentor\Reflection\Types\Context; +use function explode; +use function implode; +use function strpos; class FqsenResolver { /** @var string Definition of the NAMESPACE operator in PHP */ - const OPERATOR_NAMESPACE = '\\'; + private const OPERATOR_NAMESPACE = '\\'; - public function resolve($fqsen, Context $context = null): Fqsen + public function resolve(string $fqsen, ?Context $context = null) : Fqsen { if ($context === null) { $context = new Context(''); @@ -34,12 +39,8 @@ public function resolve($fqsen, Context $context = null): Fqsen /** * Tests whether the given type is a Fully Qualified Structural Element Name. - * - * @param string $type - * - * @return bool */ - private function isFqsen($type): bool + private function isFqsen(string $type) : bool { return strpos($type, self::OPERATOR_NAMESPACE) === 0; } @@ -48,11 +49,9 @@ private function isFqsen($type): bool * Resolves a partial Structural Element Name (i.e. `Reflection\DocBlock`) to its FQSEN representation * (i.e. `\phpDocumentor\Reflection\DocBlock`) based on the Namespace and aliases mentioned in the Context. * - * @param string $type - * @return Fqsen - * @throws \InvalidArgumentException when type is not a valid FQSEN. + * @throws InvalidArgumentException When type is not a valid FQSEN. */ - private function resolvePartialStructuralElementName($type, Context $context): Fqsen + private function resolvePartialStructuralElementName(string $type, Context $context) : Fqsen { $typeParts = explode(self::OPERATOR_NAMESPACE, $type, 2); @@ -61,7 +60,7 @@ private function resolvePartialStructuralElementName($type, Context $context): F // if the first segment is not an alias; prepend namespace name and return if (!isset($namespaceAliases[$typeParts[0]])) { $namespace = $context->getNamespace(); - if ('' !== $namespace) { + if ($namespace !== '') { $namespace .= self::OPERATOR_NAMESPACE; } diff --git a/src/Type.php b/src/Type.php index 1a8291c..fc931eb 100644 --- a/src/Type.php +++ b/src/Type.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -16,8 +17,6 @@ interface Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString(); + public function __toString() : string; } diff --git a/src/TypeResolver.php b/src/TypeResolver.php index 85ea1cf..d849d5a 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -1,17 +1,20 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; +use ArrayIterator; +use InvalidArgumentException; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Collection; use phpDocumentor\Reflection\Types\Compound; @@ -21,28 +24,46 @@ use phpDocumentor\Reflection\Types\Nullable; use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\String_; +use RuntimeException; +use const PREG_SPLIT_DELIM_CAPTURE; +use const PREG_SPLIT_NO_EMPTY; +use function array_keys; +use function array_pop; +use function class_exists; +use function class_implements; +use function count; +use function in_array; +use function preg_split; +use function strlen; +use function strpos; +use function strtolower; +use function substr; +use function trim; final class TypeResolver { /** @var string Definition of the ARRAY operator for types */ - const OPERATOR_ARRAY = '[]'; + private const OPERATOR_ARRAY = '[]'; /** @var string Definition of the NAMESPACE operator in PHP */ - const OPERATOR_NAMESPACE = '\\'; + private const OPERATOR_NAMESPACE = '\\'; /** @var int the iterator parser is inside a compound context */ - const PARSER_IN_COMPOUND = 0; + private const PARSER_IN_COMPOUND = 0; /** @var int the iterator parser is inside a nullable expression context */ - const PARSER_IN_NULLABLE = 1; + private const PARSER_IN_NULLABLE = 1; /** @var int the iterator parser is inside an array expression context */ - const PARSER_IN_ARRAY_EXPRESSION = 2; + private const PARSER_IN_ARRAY_EXPRESSION = 2; /** @var int the iterator parser is inside a collection expression context */ - const PARSER_IN_COLLECTION_EXPRESSION = 3; + private const PARSER_IN_COLLECTION_EXPRESSION = 3; - /** @var string[] List of recognized keywords and unto which Value Object they map */ + /** + * @var array List of recognized keywords and unto which Value Object they map + * @psalm-var array> + */ private $keywords = [ 'string' => Types\String_::class, 'int' => Types\Integer::class, @@ -76,7 +97,7 @@ final class TypeResolver /** * Initializes this TypeResolver with the means to create and resolve Fqsen objects. */ - public function __construct(FqsenResolver $fqsenResolver = null) + public function __construct(?FqsenResolver $fqsenResolver = null) { $this->fqsenResolver = $fqsenResolver ?: new FqsenResolver(); } @@ -91,17 +112,17 @@ public function __construct(FqsenResolver $fqsenResolver = null) * This method only works as expected if the namespace and aliases are set; * no dynamic reflection is being performed here. * - * @param string $type The relative or absolute type. - * @uses Context::getNamespace() to determine with what to prefix the type name. * @uses Context::getNamespaceAliases() to check whether the first part of the relative type name should not be * replaced with another namespace. - * @return Type + * @uses Context::getNamespace() to determine with what to prefix the type name. + * + * @param string $type The relative or absolute type. */ - public function resolve(string $type, Context $context = null): Type + public function resolve(string $type, ?Context $context = null) : Type { $type = trim($type); if (!$type) { - throw new \InvalidArgumentException('Attempted to resolve "' . $type . '" but it appears to be empty'); + throw new InvalidArgumentException('Attempted to resolve "' . $type . '" but it appears to be empty'); } if ($context === null) { @@ -116,11 +137,11 @@ public function resolve(string $type, Context $context = null): Type PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); - if (false === $tokens) { - throw new \InvalidArgumentException('Unable to split the type string "' . $type . '" into tokens'); + if ($tokens === false) { + throw new InvalidArgumentException('Unable to split the type string "' . $type . '" into tokens'); } - $tokenIterator = new \ArrayIterator($tokens); + $tokenIterator = new ArrayIterator($tokens); return $this->parseTypes($tokenIterator, $context, self::PARSER_IN_COMPOUND); } @@ -128,12 +149,11 @@ public function resolve(string $type, Context $context = null): Type /** * Analyse each tokens and creates types * - * @param \ArrayIterator $tokens the iterator on tokens - * @param int $parserContext on of self::PARSER_* constants, indicating + * @param ArrayIterator $tokens the iterator on tokens + * @param int $parserContext on of self::PARSER_* constants, indicating * the context where we are in the parsing - * @return Type */ - private function parseTypes(\ArrayIterator $tokens, Context $context, $parserContext) + private function parseTypes(ArrayIterator $tokens, Context $context, int $parserContext) : Type { $types = []; $token = ''; @@ -142,7 +162,7 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon if ($token === '|') { if (count($types) === 0) { - throw new \RuntimeException( + throw new RuntimeException( 'A type is missing before a type separator' ); } @@ -151,7 +171,7 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon && $parserContext !== self::PARSER_IN_ARRAY_EXPRESSION && $parserContext !== self::PARSER_IN_COLLECTION_EXPRESSION ) { - throw new \RuntimeException( + throw new RuntimeException( 'Unexpected type separator' ); } @@ -162,13 +182,13 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon && $parserContext !== self::PARSER_IN_ARRAY_EXPRESSION && $parserContext !== self::PARSER_IN_COLLECTION_EXPRESSION ) { - throw new \RuntimeException( + throw new RuntimeException( 'Unexpected nullable character' ); } $tokens->next(); - $type = $this->parseTypes($tokens, $context, self::PARSER_IN_NULLABLE); + $type = $this->parseTypes($tokens, $context, self::PARSER_IN_NULLABLE); $types[] = new Nullable($type); } elseif ($token === '(') { $tokens->next(); @@ -194,7 +214,7 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon break; } elseif ($token === '<') { if (count($types) === 0) { - throw new \RuntimeException( + throw new RuntimeException( 'Unexpected collection operator "<", class name is missing' ); } @@ -207,7 +227,7 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon $tokens->next(); } elseif ($parserContext === self::PARSER_IN_COLLECTION_EXPRESSION && ($token === '>' || trim($token) === ',') - ) { + ) { break; } else { $type = $this->resolveSingleType($token, $context); @@ -221,26 +241,26 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon } if ($token === '|') { - throw new \RuntimeException( + throw new RuntimeException( 'A type is missing after a type separator' ); } if (count($types) === 0) { if ($parserContext === self::PARSER_IN_NULLABLE) { - throw new \RuntimeException( + throw new RuntimeException( 'A type is missing after a nullable character' ); } if ($parserContext === self::PARSER_IN_ARRAY_EXPRESSION) { - throw new \RuntimeException( + throw new RuntimeException( 'A type is missing in an array expression' ); } if ($parserContext === self::PARSER_IN_COLLECTION_EXPRESSION) { - throw new \RuntimeException( + throw new RuntimeException( 'A type is missing in a collection expression' ); } @@ -255,9 +275,10 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon * resolve the given type into a type object * * @param string $type the type string, representing a single type + * * @return Type|Array_|Object_ */ - private function resolveSingleType($type, Context $context) + private function resolveSingleType(string $type, Context $context) { switch (true) { case $this->isKeyword($type): @@ -271,7 +292,7 @@ private function resolveSingleType($type, Context $context) // @codeCoverageIgnoreStart default: // I haven't got the foggiest how the logic would come here but added this as a defense. - throw new \RuntimeException( + throw new RuntimeException( 'Unable to resolve type "' . $type . '", there is no known method to resolve it' ); } @@ -281,21 +302,18 @@ private function resolveSingleType($type, Context $context) /** * Adds a keyword to the list of Keywords and associates it with a specific Value Object. - * - * @param string $keyword - * @param string $typeClassName */ - public function addKeyword($keyword, $typeClassName) + public function addKeyword(string $keyword, string $typeClassName) : void { if (!class_exists($typeClassName)) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'The Value Object that needs to be created with a keyword "' . $keyword . '" must be an existing class' . ' but we could not find the class ' . $typeClassName ); } if (!in_array(Type::class, class_implements($typeClassName), true)) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'The class "' . $typeClassName . '" must implement the interface "phpDocumentor\Reflection\Type"' ); } @@ -307,10 +325,8 @@ public function addKeyword($keyword, $typeClassName) * Detects whether the given type represents an array. * * @param string $type A relative or absolute type as defined in the phpDocumentor documentation. - * - * @return bool */ - private function isTypedArray($type) + private function isTypedArray(string $type) : bool { return substr($type, -2) === self::OPERATOR_ARRAY; } @@ -319,10 +335,8 @@ private function isTypedArray($type) * Detects whether the given type represents a PHPDoc keyword. * * @param string $type A relative or absolute type as defined in the phpDocumentor documentation. - * - * @return bool */ - private function isKeyword($type) + private function isKeyword(string $type) : bool { return in_array(strtolower($type), array_keys($this->keywords), true); } @@ -331,60 +345,41 @@ private function isKeyword($type) * Detects whether the given type represents a relative structural element name. * * @param string $type A relative or absolute type as defined in the phpDocumentor documentation. - * - * @return bool */ - private function isPartialStructuralElementName($type) + private function isPartialStructuralElementName(string $type) : bool { return ($type[0] !== self::OPERATOR_NAMESPACE) && !$this->isKeyword($type); } /** * Tests whether the given type is a Fully Qualified Structural Element Name. - * - * @param string $type - * - * @return bool */ - private function isFqsen($type) + private function isFqsen(string $type) : bool { return strpos($type, self::OPERATOR_NAMESPACE) === 0; } /** * Resolves the given typed array string (i.e. `string[]`) into an Array object with the right types set. - * - * @param string $type - * @return Array_ */ - private function resolveTypedArray($type, Context $context) + private function resolveTypedArray(string $type, Context $context) : Array_ { return new Array_($this->resolveSingleType(substr($type, 0, -2), $context)); } /** * Resolves the given keyword (such as `string`) into a Type object representing that keyword. - * - * @param string $type - * - * @return Type */ - private function resolveKeyword($type) + private function resolveKeyword(string $type) : Type { $className = $this->keywords[strtolower($type)]; - return new $className(); } /** * Resolves the given FQSEN string into an FQSEN object. - * - * @param string $type - * @param Context|null $context - * - * @return Object_ */ - private function resolveTypedObject($type, Context $context = null) + private function resolveTypedObject(string $type, ?Context $context = null) : Object_ { return new Object_($this->fqsenResolver->resolve($type, $context)); } @@ -394,14 +389,14 @@ private function resolveTypedObject($type, Context $context = null) * * @return Array_|Collection */ - private function resolveCollection(\ArrayIterator $tokens, Type $classType, Context $context) + private function resolveCollection(ArrayIterator $tokens, Type $classType, Context $context) : Type { - $isArray = ('array' === (string) $classType); + $isArray = ((string) $classType === 'array'); // allow only "array" or class name before "<" if (!$isArray - && (! $classType instanceof Object_ || $classType->getFqsen() === null)) { - throw new \RuntimeException( + && (!$classType instanceof Object_ || $classType->getFqsen() === null)) { + throw new RuntimeException( $classType . ' is not a collection' ); } @@ -409,7 +404,7 @@ private function resolveCollection(\ArrayIterator $tokens, Type $classType, Cont $tokens->next(); $valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION); - $keyType = null; + $keyType = null; if ($tokens->current() !== null && trim($tokens->current()) === ',') { // if we have a comma, then we just parsed the key type, not the value type @@ -417,21 +412,21 @@ private function resolveCollection(\ArrayIterator $tokens, Type $classType, Cont if ($isArray) { // check the key type for an "array" collection. We allow only // strings or integers. - if (! $keyType instanceof String_ && - ! $keyType instanceof Integer && - ! $keyType instanceof Compound + if (!$keyType instanceof String_ && + !$keyType instanceof Integer && + !$keyType instanceof Compound ) { - throw new \RuntimeException( + throw new RuntimeException( 'An array can have only integers or strings as keys' ); } if ($keyType instanceof Compound) { foreach ($keyType->getIterator() as $item) { - if (! $item instanceof String_ && - ! $item instanceof Integer + if (!$item instanceof String_ && + !$item instanceof Integer ) { - throw new \RuntimeException( + throw new RuntimeException( 'An array can have only integers or strings as keys' ); } @@ -446,12 +441,12 @@ private function resolveCollection(\ArrayIterator $tokens, Type $classType, Cont if ($tokens->current() !== '>') { if (empty($tokens->current())) { - throw new \RuntimeException( + throw new RuntimeException( 'Collection: ">" is missing' ); } - throw new \RuntimeException( + throw new RuntimeException( 'Unexpected character "' . $tokens->current() . '", ">" is missing' ); } @@ -460,16 +455,15 @@ private function resolveCollection(\ArrayIterator $tokens, Type $classType, Cont return new Array_($valueType, $keyType); } + /** @psalm-suppress RedundantCondition */ if ($classType instanceof Object_) { return $this->makeCollectionFromObject($classType, $valueType, $keyType); } + + throw new RuntimeException('Invalid $classType provided'); } - /** - * @param Type|null $keyType - * @return Collection - */ - private function makeCollectionFromObject(Object_ $object, Type $valueType, Type $keyType = null) + private function makeCollectionFromObject(Object_ $object, Type $valueType, ?Type $keyType = null) : Collection { return new Collection($object->getFqsen(), $valueType, $keyType); } diff --git a/src/Types/AbstractList.php b/src/Types/AbstractList.php index 17aa762..06260bc 100644 --- a/src/Types/AbstractList.php +++ b/src/Types/AbstractList.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -31,21 +32,21 @@ abstract class AbstractList implements Type /** * Initializes this representation of an array with the given Type. */ - public function __construct(Type $valueType = null, Type $keyType = null) + public function __construct(?Type $valueType = null, ?Type $keyType = null) { if ($valueType === null) { $valueType = new Mixed_(); } - $this->valueType = $valueType; + $this->valueType = $valueType; $this->defaultKeyType = new Compound([new String_(), new Integer()]); - $this->keyType = $keyType; + $this->keyType = $keyType; } /** * Returns the type for the keys of this array. */ - public function getKeyType(): Type + public function getKeyType() : Type { if ($this->keyType === null) { return $this->defaultKeyType; @@ -57,7 +58,7 @@ public function getKeyType(): Type /** * Returns the value for the keys of this array. */ - public function getValueType(): Type + public function getValueType() : Type { return $this->valueType; } @@ -65,7 +66,7 @@ public function getValueType(): Type /** * Returns a rendered output of the Type as it would be used in a DocBlock. */ - public function __toString(): string + public function __toString() : string { if ($this->keyType) { return 'array<' . $this->keyType . ',' . $this->valueType . '>'; diff --git a/src/Types/Array_.php b/src/Types/Array_.php index aa5fcd3..7e3b13f 100644 --- a/src/Types/Array_.php +++ b/src/Types/Array_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ diff --git a/src/Types/Boolean.php b/src/Types/Boolean.php index 7953627..2490917 100644 --- a/src/Types/Boolean.php +++ b/src/Types/Boolean.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Boolean implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'bool'; } diff --git a/src/Types/Callable_.php b/src/Types/Callable_.php index 50a7398..a0c3734 100644 --- a/src/Types/Callable_.php +++ b/src/Types/Callable_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Callable_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'callable'; } diff --git a/src/Types/Collection.php b/src/Types/Collection.php index c7cc024..8699df6 100644 --- a/src/Types/Collection.php +++ b/src/Types/Collection.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -33,10 +34,8 @@ final class Collection extends AbstractList /** * Initializes this representation of an array with the given Type or Fqsen. - * - * @param Fqsen|null $fqsen */ - public function __construct(Fqsen $fqsen = null, Type $valueType, Type $keyType = null) + public function __construct(?Fqsen $fqsen, Type $valueType, ?Type $keyType = null) { parent::__construct($valueType, $keyType); @@ -45,10 +44,8 @@ public function __construct(Fqsen $fqsen = null, Type $valueType, Type $keyType /** * Returns the FQSEN associated with this object. - * - * @return Fqsen|null */ - public function getFqsen() + public function getFqsen() : ?Fqsen { return $this->fqsen; } @@ -56,12 +53,14 @@ public function getFqsen() /** * Returns a rendered output of the Type as it would be used in a DocBlock. */ - public function __toString(): string + public function __toString() : string { + $objectType = (string) ($this->fqsen ?? 'object'); + if ($this->keyType === null) { - return $this->fqsen . '<' . $this->valueType . '>'; + return $objectType . '<' . $this->valueType . '>'; } - return $this->fqsen . '<' . $this->keyType . ',' . $this->valueType . '>'; + return $objectType . '<' . $this->keyType . ',' . $this->valueType . '>'; } } diff --git a/src/Types/Compound.php b/src/Types/Compound.php index 2aae62b..1da7bf9 100644 --- a/src/Types/Compound.php +++ b/src/Types/Compound.php @@ -1,20 +1,23 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; use ArrayIterator; +use InvalidArgumentException; use IteratorAggregate; use phpDocumentor\Reflection\Type; +use function implode; /** * Value Object representing a Compound Type. @@ -32,13 +35,15 @@ final class Compound implements Type, IteratorAggregate * Initializes a compound type (i.e. `string|int`) and tests if the provided types all implement the Type interface. * * @param Type[] $types - * @throws \InvalidArgumentException when types are not all instance of Type + * + * @throws InvalidArgumentException When types are not all instance of Type. */ public function __construct(array $types) { foreach ($types as $type) { + /** @psalm-suppress RedundantConditionGivenDocblockType */ if (!$type instanceof Type) { - throw new \InvalidArgumentException('A compound type can only have other types as elements'); + throw new InvalidArgumentException('A compound type can only have other types as elements'); } } @@ -47,12 +52,8 @@ public function __construct(array $types) /** * Returns the type at the given index. - * - * @param integer $index - * - * @return Type|null */ - public function get($index) + public function get(int $index) : ?Type { if (!$this->has($index)) { return null; @@ -63,22 +64,16 @@ public function get($index) /** * Tests if this compound type has a type with the given index. - * - * @param integer $index - * - * @return bool */ - public function has($index) + public function has(int $index) : bool { return isset($this->types[$index]); } /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return implode('|', $this->types); } diff --git a/src/Types/Context.php b/src/Types/Context.php index 6052d9a..6e29baa 100644 --- a/src/Types/Context.php +++ b/src/Types/Context.php @@ -1,17 +1,22 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; +use function strlen; +use function substr; +use function trim; + /** * Provides information about the Context in which the DocBlock occurs that receives this context. * @@ -31,19 +36,19 @@ final class Context /** @var string The current namespace. */ private $namespace; - /** @var array List of namespace aliases => Fully Qualified Namespace. */ + /** @var string[] List of namespace aliases => Fully Qualified Namespace. */ private $namespaceAliases; /** * Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN) * format (without a preceding `\`). * - * @param string $namespace The namespace where this DocBlock resides in. - * @param array $namespaceAliases List of namespace aliases => Fully Qualified Namespace. + * @param string $namespace The namespace where this DocBlock resides in. + * @param string[] $namespaceAliases List of namespace aliases => Fully Qualified Namespace. */ - public function __construct($namespace, array $namespaceAliases = []) + public function __construct(string $namespace, array $namespaceAliases = []) { - $this->namespace = ('global' !== $namespace && 'default' !== $namespace) + $this->namespace = $namespace !== 'global' && $namespace !== 'default' ? trim($namespace, '\\') : ''; @@ -64,10 +69,8 @@ public function __construct($namespace, array $namespaceAliases = []) /** * Returns the Qualified Namespace Name (thus without `\` in front) where the associated element is in. - * - * @return string */ - public function getNamespace() + public function getNamespace() : string { return $this->namespace; } @@ -78,7 +81,7 @@ public function getNamespace() * * @return string[] */ - public function getNamespaceAliases() + public function getNamespaceAliases() : array { return $this->namespaceAliases; } diff --git a/src/Types/ContextFactory.php b/src/Types/ContextFactory.php index fae433a..f0e9fff 100644 --- a/src/Types/ContextFactory.php +++ b/src/Types/ContextFactory.php @@ -1,18 +1,43 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; +use ArrayIterator; +use InvalidArgumentException; +use ReflectionClass; +use ReflectionClassConstant; +use ReflectionMethod; +use ReflectionParameter; +use ReflectionProperty; +use Reflector; +use RuntimeException; use UnexpectedValueException; +use const T_AS; +use const T_CLASS; +use const T_CURLY_OPEN; +use const T_DOLLAR_OPEN_CURLY_BRACES; +use const T_NAMESPACE; +use const T_NS_SEPARATOR; +use const T_STRING; +use const T_USE; +use function array_merge; +use function file_exists; +use function file_get_contents; +use function get_class; +use function is_string; +use function token_get_all; +use function trim; /** * Convenience class to create a Context for DocBlocks when not using the Reflection Component of phpDocumentor. @@ -26,73 +51,75 @@ final class ContextFactory { /** The literal used at the end of a use statement. */ - const T_LITERAL_END_OF_USE = ';'; + private const T_LITERAL_END_OF_USE = ';'; /** The literal used between sets of use statements */ - const T_LITERAL_USE_SEPARATOR = ','; + private const T_LITERAL_USE_SEPARATOR = ','; /** * Build a Context given a Class Reflection. * * @see Context for more information on Contexts. */ - public function createFromReflector(\Reflector $reflector): Context + public function createFromReflector(Reflector $reflector) : Context { - if ($reflector instanceof \ReflectionClass) { + if ($reflector instanceof ReflectionClass) { return $this->createFromReflectionClass($reflector); } - if ($reflector instanceof \ReflectionParameter) { + if ($reflector instanceof ReflectionParameter) { return $this->createFromReflectionParameter($reflector); } - if ($reflector instanceof \ReflectionMethod) { + if ($reflector instanceof ReflectionMethod) { return $this->createFromReflectionMethod($reflector); } - if ($reflector instanceof \ReflectionProperty) { + if ($reflector instanceof ReflectionProperty) { return $this->createFromReflectionProperty($reflector); } - if ($reflector instanceof \ReflectionClassConstant) { + if ($reflector instanceof ReflectionClassConstant) { return $this->createFromReflectionClassConstant($reflector); } throw new UnexpectedValueException('Unhandled \Reflector instance given: ' . get_class($reflector)); } - private function createFromReflectionParameter(\ReflectionParameter $parameter): Context + private function createFromReflectionParameter(ReflectionParameter $parameter) : Context { $class = $parameter->getDeclaringClass(); if ($class) { return $this->createFromReflectionClass($class); } + + throw new InvalidArgumentException('Unable to get class of ' . $parameter->getName()); } - private function createFromReflectionMethod(\ReflectionMethod $method): Context + private function createFromReflectionMethod(ReflectionMethod $method) : Context { return $this->createFromReflectionClass($method->getDeclaringClass()); } - private function createFromReflectionProperty(\ReflectionProperty $property): Context + private function createFromReflectionProperty(ReflectionProperty $property) : Context { return $this->createFromReflectionClass($property->getDeclaringClass()); } - private function createFromReflectionClassConstant(\ReflectionClassConstant $constant): Context + private function createFromReflectionClassConstant(ReflectionClassConstant $constant) : Context { return $this->createFromReflectionClass($constant->getDeclaringClass()); } - private function createFromReflectionClass(\ReflectionClass $class): Context + private function createFromReflectionClass(ReflectionClass $class) : Context { - $fileName = $class->getFileName(); + $fileName = $class->getFileName(); $namespace = $class->getNamespaceName(); if (is_string($fileName) && file_exists($fileName)) { $contents = file_get_contents($fileName); - if (false === $contents) { - throw new \RuntimeException('Unable to read file "' . $fileName . '"'); + if ($contents === false) { + throw new RuntimeException('Unable to read file "' . $fileName . '"'); } return $this->createForNamespace($namespace, $contents); @@ -104,19 +131,18 @@ private function createFromReflectionClass(\ReflectionClass $class): Context /** * Build a Context for a namespace in the provided file contents. * - * @param string $namespace It does not matter if a `\` precedes the namespace name, this method first normalizes. - * @param string $fileContents the file's contents to retrieve the aliases from with the given namespace. - * * @see Context for more information on Contexts. * - * @return Context + * @param string $namespace It does not matter if a `\` precedes the namespace name, + * this method first normalizes. + * @param string $fileContents The file's contents to retrieve the aliases from with the given namespace. */ - public function createForNamespace($namespace, $fileContents) + public function createForNamespace(string $namespace, string $fileContents) : Context { - $namespace = trim($namespace, '\\'); - $useStatements = []; + $namespace = trim($namespace, '\\'); + $useStatements = []; $currentNamespace = ''; - $tokens = new \ArrayIterator(token_get_all($fileContents)); + $tokens = new ArrayIterator(token_get_all($fileContents)); while ($tokens->valid()) { switch ($tokens->current()[0]) { @@ -127,7 +153,7 @@ public function createForNamespace($namespace, $fileContents) // Fast-forward the iterator through the class so that any // T_USE tokens found within are skipped - these are not // valid namespace use statements so should be ignored. - $braceLevel = 0; + $braceLevel = 0; $firstBraceFound = false; while ($tokens->valid() && ($braceLevel > 0 || !$firstBraceFound)) { if ($tokens->current() === '{' @@ -162,10 +188,8 @@ public function createForNamespace($namespace, $fileContents) /** * Deduce the name from tokens when we are at the T_NAMESPACE token. - * - * @return string */ - private function parseNamespace(\ArrayIterator $tokens) + private function parseNamespace(ArrayIterator $tokens) : string { // skip to the first string or namespace separator $this->skipToNextStringOrNamespaceSeparator($tokens); @@ -185,17 +209,16 @@ private function parseNamespace(\ArrayIterator $tokens) * * @return string[] */ - private function parseUseStatement(\ArrayIterator $tokens) + private function parseUseStatement(ArrayIterator $tokens) : array { $uses = []; - $continue = true; - while ($continue) { + while (true) { $this->skipToNextStringOrNamespaceSeparator($tokens); $uses = array_merge($uses, $this->extractUseStatements($tokens)); if ($tokens->current()[0] === self::T_LITERAL_END_OF_USE) { - $continue = false; + return $uses; } } @@ -205,7 +228,7 @@ private function parseUseStatement(\ArrayIterator $tokens) /** * Fast-forwards the iterator as longs as we don't encounter a T_STRING or T_NS_SEPARATOR token. */ - private function skipToNextStringOrNamespaceSeparator(\ArrayIterator $tokens) + private function skipToNextStringOrNamespaceSeparator(ArrayIterator $tokens) : void { while ($tokens->valid() && ($tokens->current()[0] !== T_STRING) && ($tokens->current()[0] !== T_NS_SEPARATOR)) { $tokens->next(); @@ -216,22 +239,22 @@ private function skipToNextStringOrNamespaceSeparator(\ArrayIterator $tokens) * Deduce the namespace name and alias of an import when we are at the T_USE token or have not reached the end of * a USE statement yet. This will return a key/value array of the alias => namespace. * - * @return array + * @return string[] + * + * @psalm-suppress TypeDoesNotContainType */ - private function extractUseStatements(\ArrayIterator $tokens) + private function extractUseStatements(ArrayIterator $tokens) : array { $extractedUseStatements = []; - $groupedNs = ''; - $currentNs = ''; - $currentAlias = null; - $state = 'start'; + $groupedNs = ''; + $currentNs = ''; + $currentAlias = null; + $state = 'start'; - $i = 0; while ($tokens->valid()) { - $i += 1; $currentToken = $tokens->current(); - $tokenId = is_string($currentToken) ? $currentToken : $currentToken[0]; - $tokenValue = is_string($currentToken) ? null : $currentToken[1]; + $tokenId = is_string($currentToken) ? $currentToken : $currentToken[0]; + $tokenValue = is_string($currentToken) ? null : $currentToken[1]; switch ($state) { case 'start': switch ($tokenId) { @@ -241,7 +264,7 @@ private function extractUseStatements(\ArrayIterator $tokens) break; case T_CURLY_OPEN: case '{': - $state = 'grouped'; + $state = 'grouped'; $groupedNs = $currentNs; break; case T_AS: @@ -278,10 +301,10 @@ private function extractUseStatements(\ArrayIterator $tokens) $state = 'grouped-alias'; break; case self::T_LITERAL_USE_SEPARATOR: - $state = 'grouped'; + $state = 'grouped'; $extractedUseStatements[$currentAlias ?: $currentNs] = $currentNs; - $currentNs = $groupedNs; - $currentAlias = null; + $currentNs = $groupedNs; + $currentAlias = null; break; case self::T_LITERAL_END_OF_USE: $state = 'end'; @@ -296,10 +319,10 @@ private function extractUseStatements(\ArrayIterator $tokens) $currentAlias .= $tokenValue; break; case self::T_LITERAL_USE_SEPARATOR: - $state = 'grouped'; + $state = 'grouped'; $extractedUseStatements[$currentAlias ?: $currentNs] = $currentNs; - $currentNs = $groupedNs; - $currentAlias = null; + $currentNs = $groupedNs; + $currentAlias = null; break; case self::T_LITERAL_END_OF_USE: $state = 'end'; diff --git a/src/Types/Float_.php b/src/Types/Float_.php index c7f2f1d..7149c93 100644 --- a/src/Types/Float_.php +++ b/src/Types/Float_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Float_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'float'; } diff --git a/src/Types/Integer.php b/src/Types/Integer.php index 48e3521..25d52e7 100644 --- a/src/Types/Integer.php +++ b/src/Types/Integer.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,10 +19,8 @@ final class Integer implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'int'; } diff --git a/src/Types/Iterable_.php b/src/Types/Iterable_.php index 10d0554..4916951 100644 --- a/src/Types/Iterable_.php +++ b/src/Types/Iterable_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Iterable_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'iterable'; } diff --git a/src/Types/Mixed_.php b/src/Types/Mixed_.php index f6e37c6..470c60a 100644 --- a/src/Types/Mixed_.php +++ b/src/Types/Mixed_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Mixed_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'mixed'; } diff --git a/src/Types/Null_.php b/src/Types/Null_.php index b841149..725f9d8 100644 --- a/src/Types/Null_.php +++ b/src/Types/Null_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Null_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'null'; } diff --git a/src/Types/Nullable.php b/src/Types/Nullable.php index 7a6b2fc..0d38228 100644 --- a/src/Types/Nullable.php +++ b/src/Types/Nullable.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -19,9 +20,7 @@ */ final class Nullable implements Type { - /** - * @var Type - */ + /** @var Type The actual type that is wrapped */ private $realType; /** @@ -34,20 +33,16 @@ public function __construct(Type $realType) /** * Provide access to the actual type directly, if needed. - * - * @return Type */ - public function getActualType() + public function getActualType() : Type { return $this->realType; } /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return '?' . $this->realType->__toString(); } diff --git a/src/Types/Object_.php b/src/Types/Object_.php index c003420..3155699 100644 --- a/src/Types/Object_.php +++ b/src/Types/Object_.php @@ -1,19 +1,22 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; +use InvalidArgumentException; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\Type; +use function strpos; /** * Value Object representing an object. @@ -30,12 +33,12 @@ final class Object_ implements Type /** * Initializes this object with an optional FQSEN, if not provided this object is considered 'untyped'. * - * @throws \InvalidArgumentException when provided $fqsen is not a valid type. + * @throws InvalidArgumentException When provided $fqsen is not a valid type. */ - public function __construct(Fqsen $fqsen = null) + public function __construct(?Fqsen $fqsen = null) { if (strpos((string) $fqsen, '::') !== false || strpos((string) $fqsen, '()') !== false) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'Object types can only refer to a class, interface or trait but a method, function, constant or ' . 'property was received: ' . (string) $fqsen ); @@ -46,15 +49,13 @@ public function __construct(Fqsen $fqsen = null) /** * Returns the FQSEN associated with this object. - * - * @return Fqsen|null */ - public function getFqsen() + public function getFqsen() : ?Fqsen { return $this->fqsen; } - public function __toString() + public function __toString() : string { if ($this->fqsen) { return (string) $this->fqsen; diff --git a/src/Types/Parent_.php b/src/Types/Parent_.php index 1ee477a..8d7efb6 100644 --- a/src/Types/Parent_.php +++ b/src/Types/Parent_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -23,10 +24,8 @@ final class Parent_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'parent'; } diff --git a/src/Types/Resource_.php b/src/Types/Resource_.php index b34c587..b46ea9a 100644 --- a/src/Types/Resource_.php +++ b/src/Types/Resource_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Resource_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'resource'; } diff --git a/src/Types/Scalar.php b/src/Types/Scalar.php index c2f68a9..6ce586c 100644 --- a/src/Types/Scalar.php +++ b/src/Types/Scalar.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Scalar implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'scalar'; } diff --git a/src/Types/Self_.php b/src/Types/Self_.php index e28202f..bcce03d 100644 --- a/src/Types/Self_.php +++ b/src/Types/Self_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -23,10 +24,8 @@ final class Self_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'self'; } diff --git a/src/Types/Static_.php b/src/Types/Static_.php index 3ddbb76..112bf87 100644 --- a/src/Types/Static_.php +++ b/src/Types/Static_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -28,10 +29,8 @@ final class Static_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'static'; } diff --git a/src/Types/String_.php b/src/Types/String_.php index 2874443..2af6342 100644 --- a/src/Types/String_.php +++ b/src/Types/String_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class String_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'string'; } diff --git a/src/Types/This.php b/src/Types/This.php index 5e6aecf..4e1b33d 100644 --- a/src/Types/This.php +++ b/src/Types/This.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -24,10 +25,8 @@ final class This implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return '$this'; } diff --git a/src/Types/Void_.php b/src/Types/Void_.php index 1dacc06..176039f 100644 --- a/src/Types/Void_.php +++ b/src/Types/Void_.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -24,10 +25,8 @@ final class Void_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'void'; } diff --git a/tests/unit/CollectionResolverTest.php b/tests/unit/CollectionResolverTest.php index 006bc97..2c020c8 100644 --- a/tests/unit/CollectionResolverTest.php +++ b/tests/unit/CollectionResolverTest.php @@ -1,40 +1,44 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; +use InvalidArgumentException; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Collection; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Object_; +use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; +use RuntimeException; /** * @covers :: - * @coversDefaultClass phpDocumentor\Reflection\TypeResolver + * @coversDefaultClass \phpDocumentor\Reflection\TypeResolver */ class CollectionResolverTest extends TestCase { /** - * @covers ::__construct - * @covers ::resolve - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::resolve + * @covers ::__construct */ - public function testResolvingCollection() + public function testResolvingCollection() : void { $fixture = new TypeResolver(); @@ -46,7 +50,7 @@ public function testResolvingCollection() $this->assertEquals('\\ArrayObject', (string) $resolvedType->getFqsen()); - /** @var Array_ $valueType */ + /** @var String_ $valueType */ $valueType = $resolvedType->getValueType(); /** @var Compound $keyType */ @@ -57,15 +61,15 @@ public function testResolvingCollection() } /** - * @covers ::__construct - * @covers ::resolve - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve */ - public function testResolvingCollectionWithKeyType() + public function testResolvingCollectionWithKeyType() : void { $fixture = new TypeResolver(); @@ -90,15 +94,15 @@ public function testResolvingCollectionWithKeyType() } /** - * @covers ::__construct - * @covers ::resolve - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve */ - public function testResolvingArrayCollection() + public function testResolvingArrayCollection() : void { $fixture = new TypeResolver(); @@ -119,15 +123,15 @@ public function testResolvingArrayCollection() } /** - * @covers ::__construct - * @covers ::resolve - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve */ - public function testResolvingArrayCollectionWithKey() + public function testResolvingArrayCollectionWithKey() : void { $fixture = new TypeResolver(); @@ -148,15 +152,15 @@ public function testResolvingArrayCollectionWithKey() } /** - * @covers ::__construct - * @covers ::resolve - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + + * @covers ::__construct + * @covers ::resolve */ - public function testResolvingArrayCollectionWithKeyAndWhitespace() + public function testResolvingArrayCollectionWithKeyAndWhitespace() : void { $fixture = new TypeResolver(); @@ -177,17 +181,17 @@ public function testResolvingArrayCollectionWithKeyAndWhitespace() } /** - * @covers ::__construct - * @covers ::resolve - * - * @expectedException \InvalidArgumentException - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve + * + * @expectedException InvalidArgumentException */ - public function testResolvingArrayCollectionWithKeyAndTooManyWhitespace() + public function testResolvingArrayCollectionWithKeyAndTooManyWhitespace() : void { $fixture = new TypeResolver(); @@ -195,15 +199,15 @@ public function testResolvingArrayCollectionWithKeyAndTooManyWhitespace() } /** - * @covers ::__construct - * @covers ::resolve - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve */ - public function testResolvingCollectionOfCollection() + public function testResolvingCollectionOfCollection() : void { $fixture = new TypeResolver(); @@ -235,10 +239,10 @@ public function testResolvingCollectionOfCollection() /** * @covers ::__construct * @covers ::resolve - * @expectedException \RuntimeException + * @expectedException RuntimeException * @expectedExceptionMessage An array can have only integers or strings as keys */ - public function testBadArrayCollectionKey() + public function testBadArrayCollectionKey() : void { $fixture = new TypeResolver(); $fixture->resolve('array', new Context('')); @@ -247,10 +251,10 @@ public function testBadArrayCollectionKey() /** * @covers ::__construct * @covers ::resolve - * @expectedException \RuntimeException + * @expectedException RuntimeException * @expectedExceptionMessage Unexpected collection operator "<", class name is missing */ - public function testMissingStartCollection() + public function testMissingStartCollection() : void { $fixture = new TypeResolver(); $fixture->resolve('', new Context('')); @@ -259,10 +263,10 @@ public function testMissingStartCollection() /** * @covers ::__construct * @covers ::resolve - * @expectedException \RuntimeException + * @expectedException RuntimeException * @expectedExceptionMessage Collection: ">" is missing */ - public function testMissingEndCollection() + public function testMissingEndCollection() : void { $fixture = new TypeResolver(); $fixture->resolve('ArrayObjectresolve('string', new Context('')); } /** - * @covers ::__construct - * @covers ::resolve - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Collection * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve */ - public function testResolvingCollectionAsArray() + public function testResolvingCollectionAsArray() : void { $fixture = new TypeResolver(); diff --git a/tests/unit/FqsenResolverTest.php b/tests/unit/FqsenResolverTest.php index fb4bef6..3771ab8 100644 --- a/tests/unit/FqsenResolverTest.php +++ b/tests/unit/FqsenResolverTest.php @@ -1,8 +1,19 @@ resolve('\DocBlock', $context); - static::assertEquals('\DocBlock', (string)$result); + static::assertEquals('\DocBlock', (string) $result); } /** * @covers ::resolve */ - public function testResolveWithoutContext() + public function testResolveWithoutContext() : void { $fqsenResolver = new FqsenResolver(); $result = $fqsenResolver->resolve('\DocBlock'); - static::assertEquals('\DocBlock', (string)$result); + static::assertEquals('\DocBlock', (string) $result); } /** * @covers ::resolve */ - public function testResolveFromAlias() + public function testResolveFromAlias() : void { $fqsenResolver = new FqsenResolver(); $context = new Context('somens', ['ns' => 'some\other\ns']); $result = $fqsenResolver->resolve('ns', $context); - static::assertEquals('\some\other\ns', (string)$result); + static::assertEquals('\some\other\ns', (string) $result); } /** * @covers ::resolve */ - public function testResolveFromPartialAlias() + public function testResolveFromPartialAlias() : void { $fqsenResolver = new FqsenResolver(); $context = new Context('somens', ['other' => 'some\other']); $result = $fqsenResolver->resolve('other\ns', $context); - static::assertEquals('\some\other\ns', (string)$result); + static::assertEquals('\some\other\ns', (string) $result); } /** - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException */ - public function testResolveThrowsExceptionWhenGarbageInputIsPassed() + public function testResolveThrowsExceptionWhenGarbageInputIsPassed() : void { $fqsenResolver = new FqsenResolver(); diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 3629dba..15be85a 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -1,17 +1,19 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; +use InvalidArgumentException; use Mockery as m; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Boolean; @@ -22,14 +24,18 @@ use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; +use stdClass; +use function get_class; /** - * @coversDefaultClass phpDocumentor\Reflection\TypeResolver + * @coversDefaultClass \phpDocumentor\Reflection\TypeResolver */ class TypeResolverTest extends TestCase { /** * Call Mockery::close after each test. + * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint */ public function tearDown() { @@ -37,20 +43,17 @@ public function tearDown() } /** - * @param string $keyword - * @param string $expectedClass + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Array_ + * @uses \phpDocumentor\Reflection\Types\Object_ * * @covers ::__construct * @covers ::resolve * @covers :: * - * @uses \phpDocumentor\Reflection\Types\Context - * @uses \phpDocumentor\Reflection\Types\Array_ - * @uses \phpDocumentor\Reflection\Types\Object_ - * * @dataProvider provideKeywords */ - public function testResolvingKeywords($keyword, $expectedClass) + public function testResolvingKeywords(string $keyword, string $expectedClass) : void { $fixture = new TypeResolver(); @@ -60,20 +63,18 @@ public function testResolvingKeywords($keyword, $expectedClass) } /** - * @param string $fqsen + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Object_ + * @uses \phpDocumentor\Reflection\Fqsen + * @uses \phpDocumentor\Reflection\FqsenResolver * * @covers ::__construct * @covers ::resolve * @covers :: * - * @uses \phpDocumentor\Reflection\Types\Context - * @uses \phpDocumentor\Reflection\Types\Object_ - * @uses \phpDocumentor\Reflection\Fqsen - * @uses \phpDocumentor\Reflection\FqsenResolver - * * @dataProvider provideFqcn */ - public function testResolvingFQSENs($fqsen) + public function testResolvingFQSENs(string $fqsen) : void { $fixture = new TypeResolver(); @@ -86,16 +87,16 @@ public function testResolvingFQSENs($fqsen) } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingRelativeQSENsBasedOnNamespace() + public function testResolvingRelativeQSENsBasedOnNamespace() : void { $fixture = new TypeResolver(); @@ -108,16 +109,16 @@ public function testResolvingRelativeQSENsBasedOnNamespace() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingRelativeQSENsBasedOnNamespaceAlias() + public function testResolvingRelativeQSENsBasedOnNamespaceAlias() : void { $fixture = new TypeResolver(); @@ -133,15 +134,15 @@ public function testResolvingRelativeQSENsBasedOnNamespaceAlias() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingTypedArrays() + public function testResolvingTypedArrays() : void { $fixture = new TypeResolver(); @@ -155,15 +156,15 @@ public function testResolvingTypedArrays() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Nullable * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingNullableTypes() + public function testResolvingNullableTypes() : void { $fixture = new TypeResolver(); @@ -176,15 +177,15 @@ public function testResolvingNullableTypes() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingNestedTypedArrays() + public function testResolvingNestedTypedArrays() : void { $fixture = new TypeResolver(); @@ -206,18 +207,18 @@ public function testResolvingNestedTypedArrays() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\String_ * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingCompoundTypes() + public function testResolvingCompoundTypes() : void { $fixture = new TypeResolver(); @@ -239,18 +240,18 @@ public function testResolvingCompoundTypes() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingCompoundTypedArrayTypes() + public function testResolvingCompoundTypedArrayTypes() : void { $fixture = new TypeResolver(); @@ -273,10 +274,6 @@ public function testResolvingCompoundTypedArrayTypes() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\String_ @@ -285,29 +282,33 @@ public function testResolvingCompoundTypedArrayTypes() * @uses \phpDocumentor\Reflection\Types\Boolean * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingNullableCompoundTypes() + public function testResolvingNullableCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve('?string|null|?boolean'); - $this->assertSame('?string|null|?bool', (string)$resolvedType); + $this->assertSame('?string|null|?bool', (string) $resolvedType); } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingArrayExpressionObjectsTypes() + public function testResolvingArrayExpressionObjectsTypes() : void { $fixture = new TypeResolver(); @@ -333,18 +334,18 @@ public function testResolvingArrayExpressionObjectsTypes() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingArrayExpressionSimpleTypes() + public function testResolvingArrayExpressionSimpleTypes() : void { $fixture = new TypeResolver(); @@ -365,7 +366,7 @@ public function testResolvingArrayExpressionSimpleTypes() /** @var Object_ $secondType */ $secondType = $valueType->get(1); - /** @var boolean $thirdType */ + /** @var Boolean $thirdType */ $thirdType = $valueType->get(2); $this->assertInstanceOf(String_::class, $firstType); @@ -374,18 +375,18 @@ public function testResolvingArrayExpressionSimpleTypes() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingArrayOfArrayExpressionTypes() + public function testResolvingArrayOfArrayExpressionTypes() : void { $fixture = new TypeResolver(); @@ -414,18 +415,18 @@ public function testResolvingArrayOfArrayExpressionTypes() } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testReturnEmptyCompoundOnAnUnclosedArrayExpressionType() + public function testReturnEmptyCompoundOnAnUnclosedArrayExpressionType() : void { $fixture = new TypeResolver(); @@ -433,22 +434,22 @@ public function testReturnEmptyCompoundOnAnUnclosedArrayExpressionType() $resolvedType = $fixture->resolve('(string|\stdClass', new Context('')); $this->assertInstanceOf(Compound::class, $resolvedType); - $this->assertSame('', (string)$resolvedType); + $this->assertSame('', (string) $resolvedType); } /** - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Object_ * @uses \phpDocumentor\Reflection\Fqsen * @uses \phpDocumentor\Reflection\FqsenResolver + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingArrayExpressionOrCompoundTypes() + public function testResolvingArrayExpressionOrCompoundTypes() : void { $fixture = new TypeResolver(); @@ -492,17 +493,17 @@ public function testResolvingArrayExpressionOrCompoundTypes() * order around then 'integer[]|string[]' would read as an array of string or integer array; which is something * other than what we intend. * - * @covers ::__construct - * @covers ::resolve - * @covers :: - * * @uses \phpDocumentor\Reflection\Types\Context * @uses \phpDocumentor\Reflection\Types\Compound * @uses \phpDocumentor\Reflection\Types\Array_ * @uses \phpDocumentor\Reflection\Types\Integer * @uses \phpDocumentor\Reflection\Types\String_ + * + * @covers ::__construct + * @covers ::resolve + * @covers :: */ - public function testResolvingCompoundTypesWithTwoArrays() + public function testResolvingCompoundTypesWithTwoArrays() : void { $fixture = new TypeResolver(); @@ -525,13 +526,14 @@ public function testResolvingCompoundTypesWithTwoArrays() } /** - * @covers ::__construct - * @covers ::addKeyword * @uses \phpDocumentor\Reflection\TypeResolver::resolve * @uses \phpDocumentor\Reflection\TypeResolver:: * @uses \phpDocumentor\Reflection\Types\Context + * + * @covers ::__construct + * @covers ::addKeyword */ - public function testAddingAKeyword() + public function testAddingAKeyword() : void { // Assign $typeMock = m::mock(Type::class); @@ -547,37 +549,42 @@ public function testAddingAKeyword() } /** + * @uses \phpDocumentor\Reflection\Types\Context + * * @covers ::__construct * @covers ::addKeyword - * @uses \phpDocumentor\Reflection\Types\Context - * @expectedException \InvalidArgumentException + * + * @expectedException InvalidArgumentException */ - public function testAddingAKeywordFailsIfTypeClassDoesNotExist() + public function testAddingAKeywordFailsIfTypeClassDoesNotExist() : void { $fixture = new TypeResolver(); $fixture->addKeyword('mock', 'IDoNotExist'); } /** + * @uses \phpDocumentor\Reflection\Types\Context + * * @covers ::__construct * @covers ::addKeyword - * @uses \phpDocumentor\Reflection\Types\Context - * @expectedException \InvalidArgumentException + * + * @expectedException InvalidArgumentException */ - public function testAddingAKeywordFailsIfTypeClassDoesNotImplementTypeInterface() + public function testAddingAKeywordFailsIfTypeClassDoesNotImplementTypeInterface() : void { $fixture = new TypeResolver(); - $fixture->addKeyword('mock', \stdClass::class); + $fixture->addKeyword('mock', stdClass::class); } /** + * @uses \phpDocumentor\Reflection\Types\Context + * * @covers ::__construct * @covers ::resolve - * @uses \phpDocumentor\Reflection\Types\Context * - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException */ - public function testExceptionIsThrownIfTypeIsEmpty() + public function testExceptionIsThrownIfTypeIsEmpty() : void { $fixture = new TypeResolver(); $fixture->resolve(' ', new Context('')); @@ -588,7 +595,7 @@ public function testExceptionIsThrownIfTypeIsEmpty() * * @return string[][] */ - public function provideKeywords() + public function provideKeywords() : array { return [ ['string', Types\String_::class], @@ -620,7 +627,7 @@ public function provideKeywords() * * @return string[][] */ - public function provideFqcn() + public function provideFqcn() : array { return [ 'namespace' => ['\phpDocumentor\Reflection'], diff --git a/tests/unit/Types/CompoundTest.php b/tests/unit/Types/CompoundTest.php index c6d45b1..d57fd6a 100644 --- a/tests/unit/Types/CompoundTest.php +++ b/tests/unit/Types/CompoundTest.php @@ -1,17 +1,19 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; +use InvalidArgumentException; use PHPUnit\Framework\TestCase; /** @@ -21,23 +23,22 @@ class CompoundTest extends TestCase { /** * @covers ::__construct - * - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException * @expectedExceptionMessage A compound type can only have other types as elements */ - public function testCompoundCannotBeConstructedFromType() + public function testCompoundCannotBeConstructedFromType() : void { new Compound(['foo']); } /** - * @covers ::get - * * @uses \phpDocumentor\Reflection\Types\Compound::__construct * @uses \phpDocumentor\Reflection\Types\Compound::has * @uses \phpDocumentor\Reflection\Types\Integer + * + * @covers ::get */ - public function testCompoundGetType() + public function testCompoundGetType() : void { $integer = new Integer(); @@ -45,57 +46,57 @@ public function testCompoundGetType() } /** - * @covers ::get - * * @uses \phpDocumentor\Reflection\Types\Compound::__construct * @uses \phpDocumentor\Reflection\Types\Compound::has + * + * @covers ::get */ - public function testCompoundGetNotExistingType() + public function testCompoundGetNotExistingType() : void { $this->assertNull((new Compound([]))->get(0)); } /** - * @covers ::has - * * @uses \phpDocumentor\Reflection\Types\Compound::__construct * @uses \phpDocumentor\Reflection\Types\Integer + * + * @covers ::has */ - public function testCompoundHasType() + public function testCompoundHasType() : void { $this->assertTrue((new Compound([new Integer()]))->has(0)); } /** - * @covers ::has - * * @uses \phpDocumentor\Reflection\Types\Compound::__construct + * + * @covers ::has */ - public function testCompoundHasNotExistingType() + public function testCompoundHasNotExistingType() : void { $this->assertFalse((new Compound([]))->has(0)); } /** - * @covers ::__construct - * @covers ::__toString - * * @uses \phpDocumentor\Reflection\Types\Integer * @uses \phpDocumentor\Reflection\Types\Boolean + * + * @covers ::__construct + * @covers ::__toString */ - public function testCompoundCanBeConstructedAndStringifiedCorrectly() + public function testCompoundCanBeConstructedAndStringifiedCorrectly() : void { $this->assertSame('int|bool', (string) (new Compound([new Integer(), new Boolean()]))); } /** - * @covers ::getIterator - * * @uses \phpDocumentor\Reflection\Types\Compound::__construct * @uses \phpDocumentor\Reflection\Types\Integer * @uses \phpDocumentor\Reflection\Types\Boolean + * + * @covers ::getIterator */ - public function testCompoundCanBeIterated() + public function testCompoundCanBeIterated() : void { $types = [new Integer(), new Boolean()]; diff --git a/tests/unit/Types/ContextFactoryTest.php b/tests/unit/Types/ContextFactoryTest.php index 9ca8534..823a707 100644 --- a/tests/unit/Types/ContextFactoryTest.php +++ b/tests/unit/Types/ContextFactoryTest.php @@ -5,8 +5,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * - * @copyright 2010-2018 Mike van Riel - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -22,6 +20,7 @@ Exception as e }; use \ReflectionClass; + use stdClass; /** * @coversDefaultClass \phpDocumentor\Reflection\Types\ContextFactory @@ -34,7 +33,7 @@ class ContextFactoryTest extends TestCase * @covers ::createForNamespace * @uses phpDocumentor\Reflection\Types\Context */ - public function testReadsNamespaceFromClassReflection() + public function testReadsNamespaceFromClassReflection() : void { $fixture = new ContextFactory(); $context = $fixture->createFromReflector(new ReflectionClass($this)); @@ -47,7 +46,7 @@ public function testReadsNamespaceFromClassReflection() * @covers ::createForNamespace * @uses phpDocumentor\Reflection\Types\Context */ - public function testReadsAliasesFromClassReflection() + public function testReadsAliasesFromClassReflection() : void { $fixture = new ContextFactory(); $expected = [ @@ -59,6 +58,7 @@ public function testReadsAliasesFromClassReflection() 'Assert' => Assert::class, 'e' => e::class, ReflectionClass::class => ReflectionClass::class, + 'stdClass', ]; $context = $fixture->createFromReflector(new ReflectionClass($this)); @@ -74,7 +74,7 @@ public function testReadsAliasesFromClassReflection() * @covers ::createForNamespace * @uses phpDocumentor\Reflection\Types\Context */ - public function testReadsNamespaceFromProvidedNamespaceAndContent() + public function testReadsNamespaceFromProvidedNamespaceAndContent() : void { $fixture = new ContextFactory(); $context = $fixture->createForNamespace(__NAMESPACE__, file_get_contents(__FILE__)); @@ -86,7 +86,7 @@ public function testReadsNamespaceFromProvidedNamespaceAndContent() * @covers ::createForNamespace * @uses phpDocumentor\Reflection\Types\Context */ - public function testReadsAliasesFromProvidedNamespaceAndContent() + public function testReadsAliasesFromProvidedNamespaceAndContent() : void { $fixture = new ContextFactory(); $expected = [ @@ -109,7 +109,7 @@ public function testReadsAliasesFromProvidedNamespaceAndContent() * @covers ::createForNamespace * @uses phpDocumentor\Reflection\Types\Context */ - public function testTraitUseIsNotDetectedAsNamespaceUse() + public function testTraitUseIsNotDetectedAsNamespaceUse() : void { $php = 'createFromReflector(new \ReflectionClass(\stdClass::class)); + $context = $fixture->createFromReflector(new ReflectionClass(stdClass::class)); $this->assertSame([], $context->getNamespaceAliases()); } @@ -180,7 +180,7 @@ public function testEmptyFileName() /** * @covers ::createFromReflector */ - public function testEvalDClass() + public function testEvalDClass() : void { eval(<<createFromReflector(new \ReflectionClass('Foo\Bar')); + $context = $fixture->createFromReflector(new ReflectionClass('Foo\Bar')); $this->assertSame([], $context->getNamespaceAliases()); } public function tearDown() { - \Mockery::close(); + m::close(); } } } diff --git a/tests/unit/Types/ContextTest.php b/tests/unit/Types/ContextTest.php index 922f267..e65b71f 100644 --- a/tests/unit/Types/ContextTest.php +++ b/tests/unit/Types/ContextTest.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -23,7 +24,7 @@ class ContextTest extends TestCase * @covers ::__construct * @covers ::getNamespace */ - public function testProvidesANormalizedNamespace() + public function testProvidesANormalizedNamespace() : void { $fixture = new Context('\My\Space'); $this->assertSame('My\Space', $fixture->getNamespace()); @@ -33,7 +34,7 @@ public function testProvidesANormalizedNamespace() * @covers ::__construct * @covers ::getNamespace */ - public function testInterpretsNamespaceNamedGlobalAsRootNamespace() + public function testInterpretsNamespaceNamedGlobalAsRootNamespace() : void { $fixture = new Context('global'); $this->assertSame('', $fixture->getNamespace()); @@ -43,7 +44,7 @@ public function testInterpretsNamespaceNamedGlobalAsRootNamespace() * @covers ::__construct * @covers ::getNamespace */ - public function testInterpretsNamespaceNamedDefaultAsRootNamespace() + public function testInterpretsNamespaceNamedDefaultAsRootNamespace() : void { $fixture = new Context('default'); $this->assertSame('', $fixture->getNamespace()); @@ -53,7 +54,7 @@ public function testInterpretsNamespaceNamedDefaultAsRootNamespace() * @covers ::__construct * @covers ::getNamespaceAliases */ - public function testProvidesNormalizedNamespaceAliases() + public function testProvidesNormalizedNamespaceAliases() : void { $fixture = new Context('', ['Space' => '\My\Space']); $this->assertSame(['Space' => 'My\Space'], $fixture->getNamespaceAliases()); diff --git a/tests/unit/Types/NullableTest.php b/tests/unit/Types/NullableTest.php index ee3fb20..f6fe2b2 100644 --- a/tests/unit/Types/NullableTest.php +++ b/tests/unit/Types/NullableTest.php @@ -1,12 +1,13 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -23,7 +24,7 @@ class NullableTest extends TestCase * @covers ::__construct * @covers ::getActualType */ - public function testNullableTypeWrapsCorrectly() + public function testNullableTypeWrapsCorrectly() : void { $realType = new String_(); @@ -35,8 +36,8 @@ public function testNullableTypeWrapsCorrectly() /** * @covers ::__toString */ - public function testNullableStringifyCorrectly() + public function testNullableStringifyCorrectly() : void { - $this->assertSame('?string', (string) (new Nullable(new String_()))); + $this->assertSame('?string', (string) new Nullable(new String_())); } }