diff --git a/.travis.yml b/.travis.yml index 32b39b8ad..4d1886b8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ jobs: - stage: Lint before_script: - - travis_retry composer require --dev --prefer-dist --prefer-stable phpstan/phpstan:^0.7 + - travis_retry composer require --dev --prefer-dist --prefer-stable phpstan/phpstan:^0.12.20 script: vendor/bin/phpstan analyse -l 3 -c phpstan.neon lib tests - stage: Benchmark @@ -41,3 +41,4 @@ jobs: - curl -o phpbench.phar https://phpbench.github.io/phpbench/phpbench.phar - curl -o phpbench.phar.pubkey https://phpbench.github.io/phpbench/phpbench.phar.pubkey script: php phpbench.phar run + php: 7.4 diff --git a/composer.json b/composer.json index 040e71732..0f9b09386 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ }, "require-dev": { "doctrine/cache": "1.*", + "phpstan/phpstan": "^0.12.20", "phpunit/phpunit": "^7.5" }, "config": { diff --git a/lib/Doctrine/Common/Annotations/Annotation/Attributes.php b/lib/Doctrine/Common/Annotations/Annotation/Attributes.php index 53134e309..13524a92b 100644 --- a/lib/Doctrine/Common/Annotations/Annotation/Attributes.php +++ b/lib/Doctrine/Common/Annotations/Annotation/Attributes.php @@ -31,7 +31,7 @@ final class Attributes { /** - * @var array + * @var array */ public $value; } diff --git a/lib/Doctrine/Common/Annotations/Annotation/Target.php b/lib/Doctrine/Common/Annotations/Annotation/Target.php index a52972b8b..d6d8c84d5 100644 --- a/lib/Doctrine/Common/Annotations/Annotation/Target.php +++ b/lib/Doctrine/Common/Annotations/Annotation/Target.php @@ -62,7 +62,7 @@ final class Target /** * Literal target declaration. * - * @var integer + * @var string */ public $literal; diff --git a/phpstan.neon b/phpstan.neon index bac7f83c4..4ea025cf7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,4 @@ parameters: - autoload_files: - - %currentWorkingDirectory%/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php excludes_analyse: - %currentWorkingDirectory%/tests/*/Fixtures/* - %currentWorkingDirectory%/tests/Doctrine/Tests/Common/Annotations/ReservedKeywordsClasses.php @@ -8,7 +6,8 @@ parameters: - %currentWorkingDirectory%/tests/Doctrine/Tests/DoctrineTestCase.php polluteScopeWithLoopInitialAssignments: true ignoreErrors: - - '#Class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment not found#' - '#Instantiated class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment not found#' - '#Property Doctrine\\Tests\\Common\\Annotations\\DummyClassNonAnnotationProblem::\$foo has unknown class#' - - '#Call to an undefined method ReflectionClass::getUseStatements\(\)#' + + # That tag is empty on purpose + - '#PHPDoc tag @var has invalid value \(\)\: Unexpected token "\\n ", expected type at offset 15#' diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index c71d19521..abc61974d 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -4,6 +4,7 @@ use Doctrine\Common\Annotations\Annotation; use Doctrine\Common\Annotations\AnnotationException; +use Doctrine\Common\Annotations\Reader; use PHPUnit\Framework\TestCase; use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader; @@ -469,10 +470,7 @@ public function testWillFailOnAnnotationConstantReferenceContainingDashes() $reader->getClassAnnotations($reflection); } - /** - * @return AnnotationReader - */ - abstract protected function getReader(); + abstract protected function getReader(): Reader; } /** diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php index 818c3e60d..0a6c30b79 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php @@ -5,6 +5,7 @@ use Doctrine\Common\Annotations\AnnotationException; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\DocParser; +use Doctrine\Common\Annotations\Reader; use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\SingleUseAnnotation; use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithFullPathUseStatement; use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithImportedIgnoredAnnotation; @@ -19,10 +20,9 @@ class AnnotationReaderTest extends AbstractReaderTest { /** - * @param DocParser|null $parser * @return AnnotationReader */ - protected function getReader(DocParser $parser = null) + protected function getReader(DocParser $parser = null): Reader { return new AnnotationReader($parser); } diff --git a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php index ea7156c00..f001e9f76 100644 --- a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\Common\Annotations; +use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Cache\Cache; use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route; use Doctrine\Common\Annotations\AnnotationReader; @@ -283,7 +284,7 @@ protected function doTestCacheFresh($className, $lastCacheModification) $this->assertEquals([$route], $reader->getClassAnnotations(new \ReflectionClass($className))); } - protected function getReader() + protected function getReader(): Reader { $this->cache = new ArrayCache(); return new CachedReader(new AnnotationReader(), $this->cache); diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 07f5a0593..777f64ab8 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -828,12 +828,12 @@ public function getConstantsProvider() '@AnnotationWithConstants({ AnnotationWithConstants::STRING = AnnotationWithConstants::INTEGER, ClassWithConstants::SOME_KEY = ClassWithConstants::SOME_VALUE, - Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants::SOME_KEY = InterfaceWithConstants::SOME_VALUE + Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants::SOME_KEY = InterfaceWithConstants::SOME_VALUE })', [ AnnotationWithConstants::STRING => AnnotationWithConstants::INTEGER, ClassWithConstants::SOME_KEY => ClassWithConstants::SOME_VALUE, - ClassWithConstants::SOME_KEY => InterfaceWithConstants::SOME_VALUE + InterfaceWithConstants::SOME_KEY => InterfaceWithConstants::SOME_VALUE ] ]; $provider[] = [ diff --git a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php index 861141b4d..76c0c1d37 100644 --- a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php @@ -4,12 +4,13 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\FileCacheReader; +use Doctrine\Common\Annotations\Reader; class FileCacheReaderTest extends AbstractReaderTest { private $cacheDir; - protected function getReader() + protected function getReader(): Reader { $this->cacheDir = sys_get_temp_dir() . '/annotations_' . uniqid('', true); @mkdir($this->cacheDir); diff --git a/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php index 281efa647..ebad718cc 100644 --- a/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\Common\Annotations; +use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Annotations\SimpleAnnotationReader; class SimpleAnnotationReaderTest extends AbstractReaderTest @@ -117,7 +118,7 @@ public function testInvalidAnnotationButIgnored() self::assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); } - protected function getReader() + protected function getReader(): Reader { $reader = new SimpleAnnotationReader(); $reader->addNamespace(__NAMESPACE__);