From bab88701ea52d718b4d56728670f43a456720e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Votruba?= Date: Sat, 2 Dec 2017 19:12:29 +0100 Subject: [PATCH] Add PHPStan and bump to max level (#139) * composer: put require- together * add phpstan * add phpstan to travis * phpstan fixes * phpstan fixes * phpstan fixes * drop null defaults since every property is null by default * DescriptionFactory: fix parse nullable type * travis: add phpstan max * travis: fix phpstan config --- .travis.yml | 1 + composer.json | 11 +- composer.lock | 985 +++++++++++++++++++++++++++- phpstan.neon | 10 + src/DocBlock.php | 14 +- src/DocBlock/DescriptionFactory.php | 2 +- src/DocBlock/Serializer.php | 4 +- src/DocBlock/StandardTagFactory.php | 2 +- src/DocBlock/Tags/Author.php | 5 +- src/DocBlock/Tags/Covers.php | 2 +- src/DocBlock/Tags/Method.php | 4 +- src/DocBlock/Tags/Param.php | 2 +- src/DocBlock/Tags/Property.php | 2 +- src/DocBlock/Tags/PropertyRead.php | 2 +- src/DocBlock/Tags/PropertyWrite.php | 2 +- src/DocBlock/Tags/See.php | 2 +- src/DocBlock/Tags/Since.php | 6 +- src/DocBlock/Tags/Source.php | 2 +- src/DocBlock/Tags/Uses.php | 2 +- src/DocBlock/Tags/Var_.php | 2 +- src/DocBlock/Tags/Version.php | 5 +- src/DocBlockFactory.php | 2 +- 22 files changed, 1028 insertions(+), 41 deletions(-) create mode 100644 phpstan.neon diff --git a/.travis.yml b/.travis.yml index ce37fcd..6e3c9cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ script: - vendor/bin/phpunit --coverage-clover=coverage.xml -v # coding style - if [[ $STATIC_ANALYSIS != "" ]]; then temp/ecs/bin/ecs check src tests; fi + - if [[ $STATIC_ANALYSIS != "" ]]; then vendor/bin/phpstan analyse src --level max --configuration phpstan.neon; fi after_script: - wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; diff --git a/composer.json b/composer.json index a0631df..f97ebdf 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,12 @@ "phpdocumentor/type-resolver": "^0.4", "webmozart/assert": "^1.0" }, + "require-dev": { + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4", + "doctrine/instantiator": "^1.0", + "phpstan/phpstan": "^0.9.0" + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": "src" @@ -25,11 +31,6 @@ "phpDocumentor\\Reflection\\": "tests/unit" } }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4", - "doctrine/instantiator": "^1.0" - }, "extra": { "branch-alias": { "dev-master": "4.x-dev" diff --git a/composer.lock b/composer.lock index 0cabfa4..c81991a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "2a242eca1a53d53cacb1e5bb03e62846", + "content-hash": "f6bf95704ed863f57d7200f760c54aa0", "packages": [ { "name": "phpdocumentor/reflection-common", @@ -261,6 +261,49 @@ ], "time": "2016-01-20T08:20:44+00:00" }, + { + "name": "jean85/pretty-package-versions", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "cda6ed1bfbcf7a3736b8943466ad8b1b5c0cc7c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/cda6ed1bfbcf7a3736b8943466ad8b1b5c0cc7c9", + "reference": "cda6ed1bfbcf7a3736b8943466ad8b1b5c0cc7c9", + "shasum": "" + }, + "require": { + "ocramius/package-versions": "^1.1.3", + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A wrapper for ocramius/pretty-package-versions to get pretty versions strings", + "keywords": [ + "package versions" + ], + "time": "2017-09-06T15:48:57+00:00" + }, { "name": "mockery/mockery", "version": "1.0", @@ -371,6 +414,567 @@ ], "time": "2017-10-19T19:58:43+00:00" }, + { + "name": "nette/bootstrap", + "version": "v2.4.5", + "source": { + "type": "git", + "url": "https://github.com/nette/bootstrap.git", + "reference": "804925787764d708a7782ea0d9382a310bb21968" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/804925787764d708a7782ea0d9382a310bb21968", + "reference": "804925787764d708a7782ea0d9382a310bb21968", + "shasum": "" + }, + "require": { + "nette/di": "~2.4.7", + "nette/utils": "~2.4", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "latte/latte": "~2.2", + "nette/application": "~2.3", + "nette/caching": "~2.3", + "nette/database": "~2.3", + "nette/forms": "~2.3", + "nette/http": "~2.4.0", + "nette/mail": "~2.3", + "nette/robot-loader": "^2.4.2 || ^3.0", + "nette/safe-stream": "~2.2", + "nette/security": "~2.3", + "nette/tester": "~2.0", + "tracy/tracy": "^2.4.1" + }, + "suggest": { + "nette/robot-loader": "to use Configurator::createRobotLoader()", + "tracy/tracy": "to use Configurator::enableTracy()" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "πŸ…± Nette Bootstrap: the simple way to configure and bootstrap your Nette application.", + "homepage": "https://nette.org", + "keywords": [ + "bootstrapping", + "configurator", + "nette" + ], + "time": "2017-08-20T17:36:59+00:00" + }, + { + "name": "nette/di", + "version": "v2.4.10", + "source": { + "type": "git", + "url": "https://github.com/nette/di.git", + "reference": "a4b3be935b755f23aebea1ce33d7e3c832cdff98" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/di/zipball/a4b3be935b755f23aebea1ce33d7e3c832cdff98", + "reference": "a4b3be935b755f23aebea1ce33d7e3c832cdff98", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/neon": "^2.3.3 || ~3.0.0", + "nette/php-generator": "^2.6.1 || ~3.0.0", + "nette/utils": "^2.4.3 || ~3.0.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/bootstrap": "<2.4", + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "πŸ’Ž Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.", + "homepage": "https://nette.org", + "keywords": [ + "compiled", + "di", + "dic", + "factory", + "ioc", + "nette", + "static" + ], + "time": "2017-08-31T22:42:00+00:00" + }, + { + "name": "nette/finder", + "version": "v2.4.1", + "source": { + "type": "git", + "url": "https://github.com/nette/finder.git", + "reference": "4d43a66d072c57d585bf08a3ef68d3587f7e9547" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/finder/zipball/4d43a66d072c57d585bf08a3ef68d3587f7e9547", + "reference": "4d43a66d072c57d585bf08a3ef68d3587f7e9547", + "shasum": "" + }, + "require": { + "nette/utils": "^2.4 || ~3.0.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "Nette Finder: Files Searching", + "homepage": "https://nette.org", + "time": "2017-07-10T23:47:08+00:00" + }, + { + "name": "nette/neon", + "version": "v2.4.2", + "source": { + "type": "git", + "url": "https://github.com/nette/neon.git", + "reference": "9eacd50553b26b53a3977bfb2fea2166d4331622" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/neon/zipball/9eacd50553b26b53a3977bfb2fea2166d4331622", + "reference": "9eacd50553b26b53a3977bfb2fea2166d4331622", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "ext-json": "*", + "php": ">=5.6.0" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "Nette NEON: parser & generator for Nette Object Notation", + "homepage": "http://ne-on.org", + "time": "2017-07-11T18:29:08+00:00" + }, + { + "name": "nette/php-generator", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/nette/php-generator.git", + "reference": "eb2dbc9c3409e9db40568109ca4994d51373b60c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/php-generator/zipball/eb2dbc9c3409e9db40568109ca4994d51373b60c", + "reference": "eb2dbc9c3409e9db40568109ca4994d51373b60c", + "shasum": "" + }, + "require": { + "nette/utils": "^2.4.2 || ~3.0.0", + "php": ">=7.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.1 features.", + "homepage": "https://nette.org", + "keywords": [ + "code", + "nette", + "php", + "scaffolding" + ], + "time": "2017-07-11T19:07:13+00:00" + }, + { + "name": "nette/robot-loader", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/nette/robot-loader.git", + "reference": "b703b4f5955831b0bcaacbd2f6af76021b056826" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/b703b4f5955831b0bcaacbd2f6af76021b056826", + "reference": "b703b4f5955831b0bcaacbd2f6af76021b056826", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/finder": "^2.3 || ^3.0", + "nette/utils": "^2.4 || ^3.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "πŸ€ Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", + "homepage": "https://nette.org", + "keywords": [ + "autoload", + "class", + "interface", + "nette", + "trait" + ], + "time": "2017-07-18T00:09:56+00:00" + }, + { + "name": "nette/utils", + "version": "v2.4.8", + "source": { + "type": "git", + "url": "https://github.com/nette/utils.git", + "reference": "f1584033b5af945b470533b466b81a789d532034" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/utils/zipball/f1584033b5af945b470533b466b81a789d532034", + "reference": "f1584033b5af945b470533b466b81a789d532034", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "suggest": { + "ext-gd": "to use Image", + "ext-iconv": "to use Strings::webalize() and toAscii()", + "ext-intl": "for script transliteration in Strings::webalize() and toAscii()", + "ext-json": "to use Nette\\Utils\\Json", + "ext-mbstring": "to use Strings::lower() etc...", + "ext-xml": "to use Strings::length() etc. when mbstring is not available" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "πŸ›  Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "homepage": "https://nette.org", + "keywords": [ + "array", + "core", + "datetime", + "images", + "json", + "nette", + "paginator", + "password", + "slugify", + "string", + "unicode", + "utf-8", + "utility", + "validation" + ], + "time": "2017-08-20T17:32:29+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v3.1.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "08131e7ff29de6bb9f12275c7d35df71f25f4d89" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/08131e7ff29de6bb9f12275c7d35df71f25f4d89", + "reference": "08131e7ff29de6bb9f12275c7d35df71f25f4d89", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|~5.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2017-11-04T11:48:34+00:00" + }, + { + "name": "ocramius/package-versions", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/PackageVersions.git", + "reference": "72b226d2957e9e6a9ed09aeaa29cabd840d1a3b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/72b226d2957e9e6a9ed09aeaa29cabd840d1a3b7", + "reference": "72b226d2957e9e6a9ed09aeaa29cabd840d1a3b7", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "~7.0" + }, + "require-dev": { + "composer/composer": "^1.3", + "ext-zip": "*", + "humbug/humbug": "dev-master", + "phpunit/phpunit": "^5.7.5" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "time": "2017-09-06T15:24:43+00:00" + }, { "name": "phar-io/manifest", "version": "1.0.1", @@ -536,6 +1140,106 @@ ], "time": "2017-11-24T13:59:53+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "08d714b2f0bc0a2bf9407255d5bb634669b7065c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/08d714b2f0bc0a2bf9407255d5bb634669b7065c", + "reference": "08d714b2f0bc0a2bf9407255d5bb634669b7065c", + "shasum": "" + }, + "require": { + "php": "~7.0" + }, + "require-dev": { + "consistence/coding-standard": "^2.0.0", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/phpstan": "^0.9", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^3.3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "time": "2017-11-22T10:46:07+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "0.9", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "f8cccde009c856e42704b7e4c250d5c73c60d00d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f8cccde009c856e42704b7e4c250d5c73c60d00d", + "reference": "f8cccde009c856e42704b7e4c250d5c73c60d00d", + "shasum": "" + }, + "require": { + "jean85/pretty-package-versions": "^1.0.2", + "nette/bootstrap": "^2.4 || ^3.0", + "nette/di": "^2.4.7 || ^3.0", + "nette/robot-loader": "^3.0.1", + "nette/utils": "^2.4.5 || ^3.0", + "nikic/php-parser": "^3.1", + "php": "~7.0", + "phpstan/phpdoc-parser": "^0.1", + "symfony/console": "~3.2 || ~4.0", + "symfony/finder": "~3.2 || ~4.0" + }, + "require-dev": { + "consistence/coding-standard": "2.2.1", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/phpstan-php-parser": "^0.9", + "phpstan/phpstan-phpunit": "^0.9", + "phpstan/phpstan-strict-rules": "^0.9", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "4.0.0" + }, + "bin": [ + "bin/phpstan" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": [ + "src/", + "build/PHPStan" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "time": "2017-11-29T11:25:41+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "5.2.3", @@ -929,6 +1633,53 @@ ], "time": "2017-08-03T14:08:16+00:00" }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -1488,6 +2239,238 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "symfony/console", + "version": "v3.3.13", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/63cd7960a0a522c3537f6326706d7f3b8de65805", + "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3", + "symfony/dependency-injection": "~3.3", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/filesystem": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/filesystem": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2017-11-16T15:24:32+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.3.13", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "74557880e2846b5c84029faa96b834da37e29810" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/74557880e2846b5c84029faa96b834da37e29810", + "reference": "74557880e2846b5c84029faa96b834da37e29810", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2017-11-10T16:38:39+00:00" + }, + { + "name": "symfony/finder", + "version": "v3.3.13", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/138af5ec075d4b1d1bd19de08c38a34bb2d7d880", + "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2017-11-05T15:47:03+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2017-10-11T12:05:26+00:00" + }, { "name": "theseer/tokenizer", "version": "1.1.0", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..2beb983 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +parameters: + ignoreErrors: + # false positive + - '#Call to an undefined method object::getDocComment\(\)#' + - '#Cannot call method render\(\) on phpDocumentor\\Reflection\\DocBlock\\Description\|string#' + - '#Calling method create\(\) on possibly null value of type phpDocumentor\\Reflection\\DocBlock\\DescriptionFactory\|null#' + - '#Calling method resolve\(\) on possibly null value of type phpDocumentor\\Reflection\\(TypeResolver|FqsenResolver)\|null#' + + # nested parents + - '#Calling method render\(\) on possibly null value of type phpDocumentor\\Reflection\\DocBlock\\Description\|string\|null#' diff --git a/src/DocBlock.php b/src/DocBlock.php index b7df997..726a8e0 100644 --- a/src/DocBlock.php +++ b/src/DocBlock.php @@ -22,16 +22,16 @@ final class DocBlock private $summary = ''; /** @var DocBlock\Description The actual description for this docblock. */ - private $description = null; + private $description; /** @var Tag[] An array containing all the tags in this docblock; except inline. */ private $tags = []; - /** @var Types\Context Information about the context of this DocBlock. */ - private $context = null; + /** @var Types\Context|null Information about the context of this DocBlock. */ + private $context; - /** @var Location Information about the location of this DocBlock. */ - private $location = null; + /** @var Location|null Information about the location of this DocBlock. */ + private $location; /** @var bool Is this DocBlock (the start of) a template? */ private $isTemplateStart = false; @@ -81,7 +81,7 @@ final class DocBlock /** * Returns the current context. */ - public function getContext(): Types\Context + public function getContext(): ?Types\Context { return $this->context; } @@ -182,7 +182,7 @@ final class DocBlock /** * Remove a tag from this DocBlock. * - * @param Tag $tag The tag to remove. + * @param Tag $tagToRemove The tag to remove. */ public function removeTag(Tag $tagToRemove): void { diff --git a/src/DocBlock/DescriptionFactory.php b/src/DocBlock/DescriptionFactory.php index 39d91b7..3d2a743 100644 --- a/src/DocBlock/DescriptionFactory.php +++ b/src/DocBlock/DescriptionFactory.php @@ -108,7 +108,7 @@ class DescriptionFactory * * @return string[]|Tag[] */ - private function parse($tokens, TypeContext $context) + private function parse($tokens, ?TypeContext $context = null): array { $count = count($tokens); $tagCount = 0; diff --git a/src/DocBlock/Serializer.php b/src/DocBlock/Serializer.php index 9670c16..64eb996 100644 --- a/src/DocBlock/Serializer.php +++ b/src/DocBlock/Serializer.php @@ -30,10 +30,10 @@ class Serializer protected $isFirstLineIndented = true; /** @var int|null The max length of a line. */ - protected $lineLength = null; + protected $lineLength; /** @var DocBlock\Tags\Formatter A custom tag formatter. */ - protected $tagFormatter = null; + protected $tagFormatter; /** * Create a Serializer instance. diff --git a/src/DocBlock/StandardTagFactory.php b/src/DocBlock/StandardTagFactory.php index 5feab3d..8ff252b 100644 --- a/src/DocBlock/StandardTagFactory.php +++ b/src/DocBlock/StandardTagFactory.php @@ -105,7 +105,7 @@ final class StandardTagFactory implements TagFactory /** * {@inheritDoc} */ - public function create(string $tagLine, ?TypeContext $context = null): Tag + public function create(string $tagLine, ?TypeContext $context = null): ?Tag { if (! $context) { $context = new TypeContext(''); diff --git a/src/DocBlock/Tags/Author.php b/src/DocBlock/Tags/Author.php index ba8f782..c239220 100644 --- a/src/DocBlock/Tags/Author.php +++ b/src/DocBlock/Tags/Author.php @@ -70,11 +70,8 @@ final class Author extends BaseTag implements Factory\StaticMethod /** * Attempts to create a new Author object based on †he tag body. - * - * - * @return static */ - public static function create(string $body) + public static function create(string $body): ?self { $splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches); if (!$splitTagContent) { diff --git a/src/DocBlock/Tags/Covers.php b/src/DocBlock/Tags/Covers.php index d35a4bf..46fcd87 100644 --- a/src/DocBlock/Tags/Covers.php +++ b/src/DocBlock/Tags/Covers.php @@ -28,7 +28,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod protected $name = 'covers'; /** @var Fqsen */ - private $refers = null; + private $refers; /** * Initializes this tag. diff --git a/src/DocBlock/Tags/Method.php b/src/DocBlock/Tags/Method.php index a5254e7..9e8ac19 100644 --- a/src/DocBlock/Tags/Method.php +++ b/src/DocBlock/Tags/Method.php @@ -69,7 +69,7 @@ final class Method extends BaseTag implements Factory\StaticMethod ?TypeResolver $typeResolver = null, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null - ): Method { + ): ?self { Assert::stringNotEmpty($body); Assert::allNotNull([ $typeResolver, $descriptionFactory ]); @@ -125,7 +125,7 @@ final class Method extends BaseTag implements Factory\StaticMethod [, $static, $returnType, $methodName, $arguments, $description] = $matches; - $static = $static === 'static'; + $static = $static === 'static'; if ($returnType === '') { $returnType = 'void'; diff --git a/src/DocBlock/Tags/Param.php b/src/DocBlock/Tags/Param.php index 189831e..d386703 100644 --- a/src/DocBlock/Tags/Param.php +++ b/src/DocBlock/Tags/Param.php @@ -28,7 +28,7 @@ final class Param extends BaseTag implements Factory\StaticMethod /** @var string */ protected $name = 'param'; - /** @var Type */ + /** @var Type|null */ private $type; /** @var string */ diff --git a/src/DocBlock/Tags/Property.php b/src/DocBlock/Tags/Property.php index 9a02143..c421f96 100644 --- a/src/DocBlock/Tags/Property.php +++ b/src/DocBlock/Tags/Property.php @@ -28,7 +28,7 @@ class Property extends BaseTag implements Factory\StaticMethod /** @var string */ protected $name = 'property'; - /** @var Type */ + /** @var Type|null */ private $type; /** @var string */ diff --git a/src/DocBlock/Tags/PropertyRead.php b/src/DocBlock/Tags/PropertyRead.php index c4d1733..d37acb0 100644 --- a/src/DocBlock/Tags/PropertyRead.php +++ b/src/DocBlock/Tags/PropertyRead.php @@ -28,7 +28,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod /** @var string */ protected $name = 'property-read'; - /** @var Type */ + /** @var Type|null */ private $type; /** @var string */ diff --git a/src/DocBlock/Tags/PropertyWrite.php b/src/DocBlock/Tags/PropertyWrite.php index 845acb3..b762e58 100644 --- a/src/DocBlock/Tags/PropertyWrite.php +++ b/src/DocBlock/Tags/PropertyWrite.php @@ -28,7 +28,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod /** @var string */ protected $name = 'property-write'; - /** @var Type */ + /** @var Type|null */ private $type; /** @var string */ diff --git a/src/DocBlock/Tags/See.php b/src/DocBlock/Tags/See.php index 6e94dba..67838ad 100644 --- a/src/DocBlock/Tags/See.php +++ b/src/DocBlock/Tags/See.php @@ -30,7 +30,7 @@ class See extends BaseTag implements Factory\StaticMethod protected $name = 'see'; /** @var Reference */ - protected $refers = null; + protected $refers; /** * Initializes this tag. diff --git a/src/DocBlock/Tags/Since.php b/src/DocBlock/Tags/Since.php index d22a72a..9fe288f 100644 --- a/src/DocBlock/Tags/Since.php +++ b/src/DocBlock/Tags/Since.php @@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; +use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; @@ -52,14 +53,11 @@ final class Since extends BaseTag implements Factory\StaticMethod $this->description = $description; } - /** - * @return static - */ public static function create( ?string $body, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null - ) { + ): ?self { if (empty($body)) { return new static(); } diff --git a/src/DocBlock/Tags/Source.php b/src/DocBlock/Tags/Source.php index cc58a5a..b2285e6 100644 --- a/src/DocBlock/Tags/Source.php +++ b/src/DocBlock/Tags/Source.php @@ -30,7 +30,7 @@ final class Source extends BaseTag implements Factory\StaticMethod private $startingLine = 1; /** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */ - private $lineCount = null; + private $lineCount; public function __construct($startingLine, $lineCount = null, ?Description $description = null) { diff --git a/src/DocBlock/Tags/Uses.php b/src/DocBlock/Tags/Uses.php index 5bed26f..1560816 100644 --- a/src/DocBlock/Tags/Uses.php +++ b/src/DocBlock/Tags/Uses.php @@ -28,7 +28,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod protected $name = 'uses'; /** @var Fqsen */ - protected $refers = null; + protected $refers; /** * Initializes this tag. diff --git a/src/DocBlock/Tags/Var_.php b/src/DocBlock/Tags/Var_.php index 0e487c1..af24906 100644 --- a/src/DocBlock/Tags/Var_.php +++ b/src/DocBlock/Tags/Var_.php @@ -28,7 +28,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod /** @var string */ protected $name = 'var'; - /** @var Type */ + /** @var Type|null */ private $type; /** @var string */ diff --git a/src/DocBlock/Tags/Version.php b/src/DocBlock/Tags/Version.php index 468d99d..0f958af 100644 --- a/src/DocBlock/Tags/Version.php +++ b/src/DocBlock/Tags/Version.php @@ -52,14 +52,11 @@ final class Version extends BaseTag implements Factory\StaticMethod $this->description = $description; } - /** - * @return static - */ public static function create( ?string $body, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null - ) { + ): ?self { if (empty($body)) { return new static(); } diff --git a/src/DocBlockFactory.php b/src/DocBlockFactory.php index 4ef6bc4..dca5b70 100644 --- a/src/DocBlockFactory.php +++ b/src/DocBlockFactory.php @@ -207,7 +207,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface * @param string $tags Tag block to parse. * @param Types\Context $context Context of the parsed Tag * - * @return DocBlock\Tag[] + * @return DocBlock\Tag[]|string[]|null[] */ private function parseTagBlock(string $tags, Types\Context $context): array {