From 622efb40c88803557dd0f329a161e4b5e7c3a566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 Jul 2020 19:37:01 +0200 Subject: [PATCH 1/7] Use phpstan >= 0.12.20 The version of webmozart/assert we use conflicts with lower versions. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 32b39b8ad..869a7599d 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 From 3af75c871ab4341ca64d4f05f36edbe00cdb83ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 Jul 2020 19:52:07 +0200 Subject: [PATCH 2/7] Make type resolvable Not prefixing it with a backslash does not work as expected. --- lib/Doctrine/Common/Annotations/Annotation/Attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From 04c65fdfa738191f84179cbdada84fb25edaada3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 Jul 2020 19:52:35 +0200 Subject: [PATCH 3/7] Document actual type --- lib/Doctrine/Common/Annotations/Annotation/Target.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 32333dd6030658689a7fd65761852f18d0d752fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 Jul 2020 19:53:47 +0200 Subject: [PATCH 4/7] Replace phpdoc with type declarations --- .../Tests/Common/Annotations/AbstractReaderTest.php | 6 ++---- .../Tests/Common/Annotations/AnnotationReaderTest.php | 4 ++-- .../Doctrine/Tests/Common/Annotations/CachedReaderTest.php | 3 ++- .../Tests/Common/Annotations/FileCacheReaderTest.php | 3 ++- .../Tests/Common/Annotations/SimpleAnnotationReaderTest.php | 3 ++- 5 files changed, 10 insertions(+), 9 deletions(-) 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/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__); From fd6f70ee46ee74c961324de9083b595b36a1df0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 Jul 2020 19:54:02 +0200 Subject: [PATCH 5/7] Do adapt part of copy/paste/adapt sequence --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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[] = [ From 4efd22bfb21c9429a862ef5a58fd9a78ea01b072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 Jul 2020 19:55:25 +0200 Subject: [PATCH 6/7] Upgrade phpstan --- composer.json | 1 + phpstan.neon | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) 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/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#' From 830d8d2c5e1d43636f63abacaa84be604eaa7d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 Jul 2020 20:13:34 +0200 Subject: [PATCH 7/7] Run benchmark job on PHP 7.4 phpbench recently dropped compatibilty with PHP 7.1 When this job was introduced, 7.1 was the latest version of PHP we supported, so it makes sense to bump to 7.4 now. See https://github.com/phpbench/phpbench/releases/tag/0.17.0 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 869a7599d..4d1886b8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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