diff --git a/.travis.yml b/.travis.yml index b2309e1..b69b070 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -dist: trusty +dist: xenial sudo: false language: php @@ -42,5 +42,8 @@ jobs: - bash <(curl -s https://codecov.io/bash) - stage: Lint + install: + # Use lock file for install so old version of phpstan is used. + - travis_retry composer install -n --prefer-dist php: 7.4 script: vendor/bin/phpstan analyse diff --git a/composer.json b/composer.json index 3db1c75..39601dd 100644 --- a/composer.json +++ b/composer.json @@ -17,16 +17,16 @@ {"name": "Marco Pivetta", "email": "ocramius@gmail.com"} ], "require": { - "php": "^7.1", + "php": "^7.1 || ^8.0", "ext-tokenizer": "*", "doctrine/annotations": "^1.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^6.0 || ^8.2.0", "doctrine/common": "^2.10", - "phpstan/phpstan": "^0.11.0", - "phpstan/phpstan-phpunit": "^0.11.0", - "phpunit/phpunit": "^7.0" + "phpstan/phpstan": "^0.11.0 || ^0.12.20", + "phpstan/phpstan-phpunit": "^0.11.0 || ^0.12.16", + "phpunit/phpunit": "^7.5 || ^9.1.5" }, "conflict": { "doctrine/common": "<2.9" @@ -43,10 +43,7 @@ } }, "config": { - "sort-packages": true, - "platform": { - "php": "7.1.0" - } + "sort-packages": true }, "extra": { "branch-alias": { diff --git a/composer.lock b/composer.lock index 99cd052..49186ee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cbb9e79f5c3e2a2d1338e7b51933ae38", + "content-hash": "cbb66ed485ea7efeb9c127d176b8d40d", "packages": [ { "name": "doctrine/annotations", @@ -3919,12 +3919,9 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.1", + "php": "^7.1 || ^8.0", "ext-tokenizer": "*" }, "platform-dev": [], - "platform-overrides": { - "php": "7.1.0" - }, "plugin-api-version": "2.0.0" } diff --git a/lib/Doctrine/Common/Reflection/Compatibility/Php7/ReflectionClass.php b/lib/Doctrine/Common/Reflection/Compatibility/Php7/ReflectionClass.php new file mode 100644 index 0000000..ec4c180 --- /dev/null +++ b/lib/Doctrine/Common/Reflection/Compatibility/Php7/ReflectionClass.php @@ -0,0 +1,24 @@ += 80000) { + class_alias('Doctrine\Common\Reflection\Compatibility\Php8\ReflectionClass', 'Doctrine\Common\Reflection\Compatibility\ReflectionClass'); +} else { + class_alias('Doctrine\Common\Reflection\Compatibility\Php7\ReflectionClass', 'Doctrine\Common\Reflection\Compatibility\ReflectionClass'); +} + +if (false) { + class ReflectionClass + { + } +} diff --git a/lib/Doctrine/Common/Reflection/Compatibility/ReflectionMethod.php b/lib/Doctrine/Common/Reflection/Compatibility/ReflectionMethod.php new file mode 100644 index 0000000..aab5333 --- /dev/null +++ b/lib/Doctrine/Common/Reflection/Compatibility/ReflectionMethod.php @@ -0,0 +1,18 @@ += 80000) { + class_alias('Doctrine\Common\Reflection\Compatibility\Php8\ReflectionMethod', 'Doctrine\Common\Reflection\Compatibility\ReflectionMethod'); +} else { + class_alias('Doctrine\Common\Reflection\Compatibility\Php7\ReflectionMethod', 'Doctrine\Common\Reflection\Compatibility\ReflectionMethod'); +} + +if (false) { + class ReflectionMethod + { + } +} diff --git a/lib/Doctrine/Common/Reflection/StaticReflectionClass.php b/lib/Doctrine/Common/Reflection/StaticReflectionClass.php index 180f5a6..f0b0179 100644 --- a/lib/Doctrine/Common/Reflection/StaticReflectionClass.php +++ b/lib/Doctrine/Common/Reflection/StaticReflectionClass.php @@ -2,11 +2,14 @@ namespace Doctrine\Common\Reflection; +use Doctrine\Common\Reflection\Compatibility\ReflectionClass as CompatibilityReflectionClass; use ReflectionClass; use ReflectionException; class StaticReflectionClass extends ReflectionClass { + use CompatibilityReflectionClass; + /** * The static reflection parser object. * @@ -83,14 +86,6 @@ public function getConstant($name) throw new ReflectionException('Method not implemented'); } - /** - * {@inheritDoc} - */ - public function getConstants() - { - throw new ReflectionException('Method not implemented'); - } - /** * {@inheritDoc} */ @@ -371,14 +366,6 @@ public function isUserDefined() throw new ReflectionException('Method not implemented'); } - /** - * {@inheritDoc} - */ - public function newInstance($args) - { - throw new ReflectionException('Method not implemented'); - } - /** * {@inheritDoc} */ diff --git a/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php b/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php index 9b31696..d4c0be1 100644 --- a/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php +++ b/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php @@ -2,11 +2,14 @@ namespace Doctrine\Common\Reflection; +use Doctrine\Common\Reflection\Compatibility\ReflectionMethod as CompatibilityReflectionMethod; use ReflectionException; use ReflectionMethod; class StaticReflectionMethod extends ReflectionMethod { + use CompatibilityReflectionMethod; + /** * The PSR-0 parser object. * @@ -110,14 +113,6 @@ public function getPrototype() throw new ReflectionException('Method not implemented'); } - /** - * {@inheritDoc} - */ - public function invoke($object, $parameter = null) - { - throw new ReflectionException('Method not implemented'); - } - /** * {@inheritDoc} */ diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a7ec494..8cfbbe4 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,5 +7,8 @@ parameters: ignoreErrors: - '#Doctrine\\Common\\Reflection\\StaticReflection[a-zA-Z0-9_]+::__construct\(\) does not call parent constructor from Reflection[a-zA-Z0-9_]+#' + excludes_analyse: + - lib/Doctrine/Common/Reflection/Compatibility/ReflectionClass.php + - lib/Doctrine/Common/Reflection/Compatibility/ReflectionMethod.php includes: - vendor/phpstan/phpstan-phpunit/extension.neon