From 7d87cad5056a3268d0a1b64efec31be538945301 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sat, 4 Sep 2021 09:53:35 +0200 Subject: [PATCH] Add parameter type hints to tests --- phpcs.xml.dist | 5 +- .../AggregationOperatorsProviderTrait.php | 3 ++ .../MongoDB/Tests/Aggregation/ExprTest.php | 9 +++- .../Tests/Aggregation/Stage/GeoNearTest.php | 4 +- .../Tests/Aggregation/Stage/GroupTest.php | 8 +++- .../Aggregation/Stage/MatchStageTest.php | 5 +- .../Tests/Aggregation/Stage/OperatorTest.php | 5 +- .../Tests/Aggregation/Stage/ProjectTest.php | 7 ++- .../Tests/Aggregation/Stage/SortTest.php | 8 +++- tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php | 2 +- .../Tests/Events/LifecycleCallbacksTest.php | 2 +- .../Tests/Events/LifecycleListenersTest.php | 4 +- .../MongoDB/Tests/Functional/AlsoLoadTest.php | 2 +- .../Tests/Functional/AtomicSetTest.php | 5 ++ .../MongoDB/Tests/Functional/BinDataTest.php | 5 +- .../Functional/CommitImprovementTest.php | 2 +- .../Functional/CustomCollectionsTest.php | 2 +- .../ODM/MongoDB/Tests/Functional/DateTest.php | 7 +++ .../Functional/DocumentPersisterTest.php | 25 +++++++--- .../Functional/EmbeddedReferenceTest.php | 4 +- .../MongoDB/Tests/Functional/FlushTest.php | 2 +- .../Tests/Functional/FunctionalTest.php | 13 +++-- .../ODM/MongoDB/Tests/Functional/IdTest.php | 17 ++++--- .../MongoDB/Tests/Functional/IndexesTest.php | 5 +- .../Iterator/CachingIteratorTest.php | 4 +- .../Iterator/HydratingIteratorTest.php | 2 +- .../Iterator/UnrewindableIteratorTest.php | 4 +- .../Tests/Functional/MappedSuperclassTest.php | 14 ++++-- .../Tests/Functional/MemoryUsageTest.php | 3 ++ .../Functional/NestedCollectionsTest.php | 5 +- .../MongoDB/Tests/Functional/RawTypeTest.php | 2 + .../Tests/Functional/ReadPreferenceTest.php | 4 +- .../SplObjectHashCollisionsTest.php | 19 +++++--- .../Tests/Functional/Ticket/GH1011Test.php | 4 +- .../Tests/Functional/Ticket/GH1058Test.php | 4 +- .../Tests/Functional/Ticket/GH1275Test.php | 14 +++--- .../Tests/Functional/Ticket/GH1572Test.php | 2 +- .../Tests/Functional/Ticket/GH2002Test.php | 4 +- .../Tests/Functional/Ticket/GH232Test.php | 4 +- .../Tests/Functional/Ticket/GH267Test.php | 2 +- .../Tests/Functional/Ticket/GH453Test.php | 33 ++++++++++--- .../Tests/Functional/Ticket/GH560Test.php | 11 ++++- .../Tests/Functional/Ticket/GH597Test.php | 8 ++-- .../Tests/Functional/Ticket/GH602Test.php | 5 +- .../Tests/Functional/Ticket/GH880Test.php | 6 +-- .../Tests/Functional/Ticket/GH999Test.php | 6 +-- .../Tests/Functional/Ticket/MODM45Test.php | 2 +- .../Tests/Functional/Ticket/MODM47Test.php | 2 +- .../Tests/Functional/Ticket/MODM48Test.php | 4 +- .../Tests/Functional/Ticket/MODM56Test.php | 4 +- .../Tests/Functional/Ticket/MODM70Test.php | 4 +- .../Tests/Functional/Ticket/MODM83Test.php | 2 +- .../Tests/Functional/Ticket/MODM90Test.php | 2 +- .../Tests/Functional/Ticket/MODM91Test.php | 2 +- .../Tests/Mapping/ClassMetadataTest.php | 6 ++- .../Tests/Performance/MemoryUsageTest.php | 2 +- .../Persisters/PersistenceBuilderTest.php | 2 +- .../ODM/MongoDB/Tests/Query/BuilderTest.php | 21 +++++--- .../ODM/MongoDB/Tests/Query/ExprTest.php | 12 ++++- .../Doctrine/ODM/MongoDB/Tests/QueryTest.php | 4 +- .../DefaultGridFSRepositoryTest.php | 7 ++- .../ODM/MongoDB/Tests/SchemaManagerTest.php | 4 +- .../ODM/MongoDB/Tests/Tools/GH297/Address.php | 2 +- .../Tests/Types/DateImmutableTypeTest.php | 10 +++- .../ODM/MongoDB/Tests/Types/DateTypeTest.php | 10 +++- .../ODM/MongoDB/Tests/Types/IdTypeTest.php | 2 + .../ODM/MongoDB/Tests/Types/TypeTest.php | 4 ++ .../ODM/MongoDB/Tests/UnitOfWorkTest.php | 19 +++++--- tests/Documents/Address.php | 8 ++-- tests/Documents/Album.php | 6 +-- tests/Documents/Article.php | 2 +- tests/Documents/Bars/Bar.php | 8 +++- tests/Documents/BaseCategory.php | 2 +- tests/Documents/BaseDocument.php | 2 +- tests/Documents/BaseEmployee.php | 16 +++---- tests/Documents/CmsUser.php | 2 +- tests/Documents/CustomUser.php | 6 +-- tests/Documents/Ecommerce/Currency.php | 14 ++++-- tests/Documents/Ecommerce/Money.php | 3 +- tests/Documents/Ecommerce/Option.php | 2 +- tests/Documents/Ecommerce/StockItem.php | 4 +- tests/Documents/Employee.php | 2 +- tests/Documents/Event.php | 4 +- tests/Documents/Functional/FavoritesUser.php | 2 +- .../Functional/PreUpdateTestProduct.php | 2 +- .../Functional/PreUpdateTestSeller.php | 2 +- .../Functional/VirtualHostDirective.php | 18 ++++--- tests/Documents/IdentifiedChapter.php | 2 +- tests/Documents/Issue.php | 10 ++-- tests/Documents/Message.php | 6 +-- tests/Documents/Page.php | 4 +- tests/Documents/Phonebook.php | 2 +- tests/Documents/ProfileNotify.php | 21 ++++++-- tests/Documents/Project.php | 2 +- tests/Documents/Song.php | 6 +-- tests/Documents/Task.php | 6 +-- tests/Documents/Tournament/Tournament.php | 6 +-- tests/Documents/User.php | 48 +++++++++++++------ tests/Documents/VersionedUser.php | 2 +- 99 files changed, 442 insertions(+), 216 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 1543cd4ce7..861bda735c 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -31,7 +31,6 @@ - @@ -70,6 +69,10 @@ */lib/* + + */lib/* + + */tests/Doctrine/ODM/MongoDB/Tests/PersistentCollection/Coll* diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php index df73d0385a..43e0007b17 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php @@ -613,6 +613,9 @@ protected function createExpr(): Expr return new Expr($this->dm, new ClassMetadata(User::class)); } + /** + * @param mixed $args + */ protected function resolveArgs($args): array { if (is_array($args)) { diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php index 0829bb3ce0..292b4f2257 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php @@ -5,6 +5,7 @@ namespace Doctrine\ODM\MongoDB\Tests\Aggregation; use BadMethodCallException; +use Closure; use Doctrine\ODM\MongoDB\Aggregation\Expr; use Doctrine\ODM\MongoDB\Tests\BaseTest; use LogicException; @@ -14,9 +15,11 @@ class ExprTest extends BaseTest use AggregationOperatorsProviderTrait; /** + * @param array|Closure $args + * * @dataProvider provideAllOperators */ - public function testGenericOperator($expected, $operator, $args): void + public function testGenericOperator(array $expected, string $operator, $args): void { $expr = $this->createExpr(); $args = $this->resolveArgs($args); @@ -26,9 +29,11 @@ public function testGenericOperator($expected, $operator, $args): void } /** + * @param array|Closure $args + * * @dataProvider provideAllOperators */ - public function testGenericOperatorWithField($expected, $operator, $args): void + public function testGenericOperatorWithField(array $expected, string $operator, $args): void { $expr = $this->createExpr(); $args = $this->resolveArgs($args); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php index 6b0ab43bc9..23951a696e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php @@ -38,9 +38,11 @@ public function testGeoNearFromBuilder(): void } /** + * @param mixed $value + * * @dataProvider provideOptionalSettings */ - public function testOptionalSettings($field, $value): void + public function testOptionalSettings(string $field, $value): void { $geoNearStage = new GeoNear($this->getTestAggregationBuilder(), 0, 0); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php index 38f1010a70..454d032843 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php @@ -4,6 +4,7 @@ namespace Doctrine\ODM\MongoDB\Tests\Aggregation\Stage; +use Closure; use Doctrine\ODM\MongoDB\Aggregation\Expr; use Doctrine\ODM\MongoDB\Aggregation\Stage\Group; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationOperatorsProviderTrait; @@ -16,9 +17,11 @@ class GroupTest extends BaseTest use AggregationOperatorsProviderTrait; /** + * @param Closure|array $args + * * @dataProvider provideProxiedExprMethods */ - public function testProxiedExprMethods($method, $args = []): void + public function testProxiedExprMethods(string $method, $args = []): void { $args = $this->resolveArgs($args); @@ -39,6 +42,9 @@ public function setExpr(Expr $expr): void $this->assertSame($stage, $stage->$method(...$args)); } + /** + * @return array + */ public function provideProxiedExprMethods(): array { return [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MatchStageTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MatchStageTest.php index ef28cb5a45..e330384391 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MatchStageTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MatchStageTest.php @@ -42,7 +42,7 @@ public function testMatchFromBuilder(): void /** * @dataProvider provideProxiedExprMethods */ - public function testProxiedExprMethods($method, array $args = []): void + public function testProxiedExprMethods(string $method, array $args = []): void { $expr = $this->getMockQueryExpr(); $expr @@ -61,6 +61,9 @@ public function setQuery(Expr $query): void $this->assertSame($stage, $stage->$method(...$args)); } + /** + * @return array + */ public function provideProxiedExprMethods(): array { return [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php index a58791998d..826c7bdcb0 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php @@ -5,6 +5,7 @@ namespace Doctrine\ODM\MongoDB\Tests\Aggregation\Stage; use BadMethodCallException; +use Closure; use Doctrine\ODM\MongoDB\Aggregation\Expr; use Doctrine\ODM\MongoDB\Aggregation\Stage\Operator; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationOperatorsProviderTrait; @@ -17,9 +18,11 @@ class OperatorTest extends BaseTest use AggregationOperatorsProviderTrait; /** + * @param Closure|array $args + * * @dataProvider provideExpressionOperators */ - public function testProxiedExpressionOperators($expected, $operator, $args): void + public function testProxiedExpressionOperators(array $expected, string $operator, $args): void { $stage = $this->getStubStage(); $args = $this->resolveArgs($args); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php index 2d72826098..119194cc99 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php @@ -44,7 +44,7 @@ public function testProjectFromBuilder(): void /** * @dataProvider provideAccumulators */ - public function testAccumulatorsWithMultipleArguments($operator): void + public function testAccumulatorsWithMultipleArguments(string $operator): void { $projectStage = new Project($this->getTestAggregationBuilder()); $projectStage @@ -66,7 +66,7 @@ public function provideAccumulators(): array /** * @dataProvider provideProxiedExprMethods */ - public function testProxiedExprMethods($method, $args = []): void + public function testProxiedExprMethods(string $method, array $args = []): void { $expr = $this->getMockAggregationExpr(); $expr @@ -85,6 +85,9 @@ public function setExpr(Expr $expr): void $this->assertSame($stage, $stage->$method(...$args)); } + /** + * @return array + */ public static function provideProxiedExprMethods(): array { return [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php index c3d7945c12..6892e40f68 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php @@ -13,9 +13,11 @@ class SortTest extends BaseTest use AggregationTestTrait; /** + * @param string|array $field + * * @dataProvider provideSortOptions */ - public function testSortStage($expectedSort, $field, $order = null): void + public function testSortStage(array $expectedSort, $field, ?string $order = null): void { $sortStage = new Sort($this->getTestAggregationBuilder(), $field, $order); @@ -23,9 +25,11 @@ public function testSortStage($expectedSort, $field, $order = null): void } /** + * @param string|array $field + * * @dataProvider provideSortOptions */ - public function testSortFromBuilder($expectedSort, $field, $order = null): void + public function testSortFromBuilder(array $expectedSort, $field, ?string $order = null): void { $builder = $this->getTestAggregationBuilder(); $builder->sort($field, $order); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php b/tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php index eea0333167..e97fc64202 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php @@ -93,7 +93,7 @@ protected function getConfiguration(): Configuration * * @deprecated */ - public static function assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = ''): void + public static function assertArraySubset(array $subset, array $array, bool $checkForObjectIdentity = false, string $message = ''): void { foreach ($subset as $key => $value) { self::assertArrayHasKey($key, $array, $message); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php index beb6a96fda..c63b5fd490 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php @@ -13,7 +13,7 @@ class LifecycleCallbacksTest extends BaseTest { - private function createUser($name = 'jon', $fullName = 'Jonathan H. Wage'): User + private function createUser(string $name = 'jon', string $fullName = 'Jonathan H. Wage'): User { $user = new User(); $user->name = $name; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php index 105496e726..7af0c741da 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php @@ -225,7 +225,7 @@ class MyEventListener /** @psalm-var array> */ public $called = []; - public function __call($method, $args) + public function __call(string $method, array $args) { $document = $args[0]->getDocument(); $className = get_class($document); @@ -245,7 +245,7 @@ class PostCollectionLoadEventListener /** @var TestCase */ private $phpunit; - public function __construct($phpunit) + public function __construct(TestCase $phpunit) { $this->phpunit = $phpunit; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php index fd5a880bd1..3e7ff6f346 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AlsoLoadTest.php @@ -317,7 +317,7 @@ class AlsoLoadDocument public $testOlder; /** @ODM\AlsoLoad({"name", "fullName"}) */ - public function populateFirstAndLastName($name): void + public function populateFirstAndLastName(string $name): void { [$this->firstName, $this->lastName] = explode(' ', $name); } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php index 10f8d69bb8..aea41851cb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php @@ -90,6 +90,8 @@ public function testAtomicUpsert(): void } /** + * @param array|ArrayCollection|null $clearWith + * * @dataProvider provideAtomicCollectionUnset */ public function testAtomicCollectionUnset($clearWith): void @@ -119,6 +121,9 @@ public function testAtomicCollectionUnset($clearWith): void $this->assertCount(0, $user->phonenumbers); } + /** + * @return array + */ public function provideAtomicCollectionUnset(): array { return [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php index 5b930faf7d..122ed9e1d5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php @@ -15,7 +15,7 @@ class BinDataTest extends BaseTest /** * @dataProvider provideData */ - public function testBinData($field, $data, $type): void + public function testBinData(string $field, string $data, int $type): void { $test = new BinDataTestUser(); $test->$field = $data; @@ -28,6 +28,9 @@ public function testBinData($field, $data, $type): void $this->assertEquals($data, $check[$field]->getData()); } + /** + * @return array + */ public function provideData(): array { return [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CommitImprovementTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CommitImprovementTest.php index 1fc762eeff..7aa6d98d45 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CommitImprovementTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CommitImprovementTest.php @@ -158,7 +158,7 @@ public function getSubscribedEvents(): array ]; } - public function __call($eventName, $args) + public function __call(string $eventName, array $args) { $document = $args[0]->getDocument(); if (! ($document instanceof User)) { diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php index 5b6265f5ff..b45c3db6d8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php @@ -291,7 +291,7 @@ public function getEnabled(): MyEmbedsCollection }); } - public function move($i, $j): void + public function move(int $i, int $j): void { $tmp = $this->get($i); $this->set($i, $this->get($j)); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php index d5d1589240..5f1d320269 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php @@ -38,6 +38,9 @@ public function testDates(): void } /** + * @param DateTime|UTCDateTime $oldValue + * @param DateTime|UTCDateTime $newValue + * * @dataProvider provideEquivalentDates */ public function testDateInstanceChangeDoesNotCauseUpdateIfValueIsTheSame($oldValue, $newValue): void @@ -55,6 +58,9 @@ public function testDateInstanceChangeDoesNotCauseUpdateIfValueIsTheSame($oldVal $this->assertEmpty($changeset); } + /** + * @return array + */ public function provideEquivalentDates(): array { return [ @@ -76,6 +82,7 @@ public function testDateInstanceValueChangeDoesCauseUpdateIfValueIsTheSame(): vo $this->dm->clear(); $user = $this->dm->getRepository(get_class($user))->findOneBy([]); + $this->assertInstanceOf(DateTime::class, $user->getCreatedAt()); $user->getCreatedAt()->setTimestamp(time() - 3600); $this->dm->getUnitOfWork()->computeChangeSets(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php index c9f227331b..f82c2bd053 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php @@ -123,7 +123,7 @@ public function testLoadAllWithSortLimitAndSkip(): void /** * @dataProvider getTestPrepareFieldNameData */ - public function testPrepareFieldName($fieldName, $expected): void + public function testPrepareFieldName(string $fieldName, string $expected): void { $this->assertEquals($expected, $this->documentPersister->prepareFieldName($fieldName)); } @@ -172,9 +172,11 @@ public function testExistsInQuery(): void } /** + * @param array $hashId + * * @dataProvider provideHashIdentifiers */ - public function testPrepareQueryOrNewObjWithHashId($hashId): void + public function testPrepareQueryOrNewObjWithHashId(array $hashId): void { $class = DocumentPersisterTestHashIdDocument::class; $documentPersister = $this->uow->getDocumentPersister($class); @@ -186,9 +188,11 @@ public function testPrepareQueryOrNewObjWithHashId($hashId): void } /** + * @param array $hashId + * * @dataProvider provideHashIdentifiers */ - public function testPrepareQueryOrNewObjWithHashIdAndInOperators($hashId): void + public function testPrepareQueryOrNewObjWithHashIdAndInOperators(array $hashId): void { $class = DocumentPersisterTestHashIdDocument::class; $documentPersister = $this->uow->getDocumentPersister($class); @@ -379,9 +383,11 @@ static function (DocumentManager $dm) use ($getReference): array { } /** + * @param array $hashId + * * @dataProvider provideHashIdentifiers */ - public function testPrepareQueryOrNewObjWithSimpleReferenceToTargetDocumentWithHashIdType($hashId): void + public function testPrepareQueryOrNewObjWithSimpleReferenceToTargetDocumentWithHashIdType(array $hashId): void { $class = DocumentPersisterTestDocument::class; $documentPersister = $this->uow->getDocumentPersister($class); @@ -456,9 +462,11 @@ public function testPrepareQueryOrNewObjWithDBRefReferenceToTargetDocumentWithNo } /** + * @param array $hashId + * * @dataProvider provideHashIdentifiers */ - public function testPrepareQueryOrNewObjWithDBRefReferenceToTargetDocumentWithHashIdType($hashId): void + public function testPrepareQueryOrNewObjWithDBRefReferenceToTargetDocumentWithHashIdType(array $hashId): void { $class = DocumentPersisterTestDocument::class; $documentPersister = $this->uow->getDocumentPersister($class); @@ -570,9 +578,11 @@ public function testPrepareQueryOrNewObjWithEmbeddedReferenceToTargetDocumentWit } /** + * @param array $hashId + * * @dataProvider provideHashIdentifiers */ - public function testPrepareQueryOrNewObjWithEmbeddedReferenceToTargetDocumentWithHashIdType($hashId): void + public function testPrepareQueryOrNewObjWithEmbeddedReferenceToTargetDocumentWithHashIdType(array $hashId): void { $class = DocumentPersisterTestDocument::class; $documentPersister = $this->uow->getDocumentPersister($class); @@ -1067,6 +1077,9 @@ public function convertToPHPValue($value) throw self::createException($value); } + /** + * @param mixed $value + */ private static function createException($value): InvalidArgumentException { return new InvalidArgumentException( diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php index 64b01692d7..e4c8856ec3 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EmbeddedReferenceTest.php @@ -133,11 +133,11 @@ class ReferencedDocument /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FlushTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FlushTest.php index 7b99969138..ced7e43707 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FlushTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FlushTest.php @@ -59,7 +59,7 @@ public function testFlush(): void $this->assertSize(1); } - protected function assertSize($size): void + protected function assertSize(int $size): void { $this->assertEquals($size, $this->dm->getUnitOfWork()->size()); } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php index 8f206efa6d..6e6e769ec5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php @@ -82,6 +82,9 @@ public function tearDown(): void bcscale($this->initialScale); } + /** + * @return array + */ public function provideUpsertObjects(): array { return [ @@ -92,9 +95,11 @@ public function provideUpsertObjects(): array } /** + * @param ObjectId|string $id + * * @dataProvider provideUpsertObjects */ - public function testUpsertObject($className, $id, $discriminator): void + public function testUpsertObject(string $className, $id, string $discriminator): void { $user = new $className(); $user->id = (string) $id; @@ -277,8 +282,8 @@ public function testCollection(): void { $user = new User(); $user->setUsername('joncolltest'); - $user->log(['test']); - $user->log(['test']); + $user->log('test'); + $user->log('test'); $this->dm->persist($user); $this->dm->flush(); $this->dm->clear(); @@ -289,7 +294,7 @@ public function testCollection(): void $document = $this->dm->getRepository(User::class)->findOneBy(['username' => 'joncolltest']); $this->assertCount(2, $document->getLogs()); - $document->log(['test']); + $document->log('test'); $this->dm->flush(); $this->dm->clear(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php index a3900d8e99..0282f882f2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php @@ -163,9 +163,11 @@ public function testIdGeneratorInstance(): void } /** + * @param int|float $user2Id + * * @dataProvider provideEqualButNotIdenticalIds */ - public function testEqualButNotIdenticalIds($user1Id, $user2Id): void + public function testEqualButNotIdenticalIds(string $user1Id, $user2Id): void { $this->assertNotSame($user1Id, $user2Id); @@ -207,9 +209,12 @@ public function provideEqualButNotIdenticalIds(): array } /** + * @param mixed $id + * @param mixed $expected + * * @dataProvider getTestIdTypesAndStrategiesData */ - public function testIdTypesAndStrategies($type, $strategy, $id = null, $expected = null, $expectedMongoType = null): void + public function testIdTypesAndStrategies(string $type, string $strategy, $id = null, $expected = null, ?string $expectedMongoType = null): void { $className = $this->createIdTestClass($type, $strategy); @@ -306,7 +311,7 @@ public function getTestIdTypesAndStrategiesData(): array /** * @dataProvider getTestBinIdsData */ - public function testBinIds($type, $expectedMongoBinDataType, $id): void + public function testBinIds(string $type, int $expectedMongoBinDataType, string $id): void { $className = $this->createIdTestClass($type, 'none'); @@ -357,7 +362,7 @@ public function testStrategyAutoWithNotValidIdThrowsException(): void $this->dm->persist($user); } - private function createIdTestClass($type, $strategy): string + private function createIdTestClass(string $type, string $strategy): string { $shortClassName = sprintf('TestIdTypes%s%sUser', ucfirst($type), ucfirst($strategy)); $className = sprintf(__NAMESPACE__ . '\\%s', $shortClassName); @@ -559,7 +564,7 @@ class AlnumCharsUser */ public $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } @@ -571,7 +576,7 @@ class CustomIdUser /** * @ODM\Id(strategy="none", nullable=true) * - * @var int|null + * @var int|string|null */ public $id; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php index 52083e3c50..46ea5b5317 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php @@ -11,7 +11,10 @@ class IndexesTest extends BaseTest { - private function uniqueTest($class): void + /** + * @param class-string $class + */ + private function uniqueTest(string $class): void { $this->dm->getSchemaManager()->ensureDocumentIndexes($class); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php index deab50fbe5..b4e314c84d 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php @@ -110,14 +110,14 @@ public function testToArrayAfterPartialIteration(): void $this->assertSame([1, 2, 3], $iterator->toArray()); } - private function getTraversable($items): Generator + private function getTraversable(array $items): Generator { foreach ($items as $item) { yield $item; } } - private function getTraversableThatThrows($items): Generator + private function getTraversableThatThrows(array $items): Generator { foreach ($items as $item) { if ($item instanceof Exception) { diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/HydratingIteratorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/HydratingIteratorTest.php index 0ae2171b62..5bf9d5f819 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/HydratingIteratorTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/HydratingIteratorTest.php @@ -48,7 +48,7 @@ public function testIterationWithEmptySet(): void $this->assertFalse($iterator->valid()); } - private function getTraversable($items = null): Generator + private function getTraversable(?array $items = null): Generator { if (! is_array($items)) { $items = [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/UnrewindableIteratorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/UnrewindableIteratorTest.php index 6157dfd817..c2c773778b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/UnrewindableIteratorTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/UnrewindableIteratorTest.php @@ -120,14 +120,14 @@ public function testToArrayAfterPartialIteration(): void $iterator->toArray(); } - private function getTraversable($items): Generator + private function getTraversable(array $items): Generator { foreach ($items as $item) { yield $item; } } - private function getTraversableThatThrows($items): Generator + private function getTraversableThatThrows(array $items): Generator { foreach ($items as $item) { if ($item instanceof Exception) { diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php index 6d81a510ed..253e09f0c2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MappedSuperclassTest.php @@ -44,7 +44,7 @@ class MappedSuperclassBase /** * @ODM\Field(type="string") * - * @var string|null + * @var int|string|null */ private $mapped1; @@ -62,17 +62,23 @@ class MappedSuperclassBase */ private $mappedRelated1; + /** + * @param int|string $val + */ public function setMapped1($val): void { $this->mapped1 = $val; } - public function getMapped1(): ?string + /** + * @return int|string|null + */ + public function getMapped1() { return $this->mapped1; } - public function setMapped2($val): void + public function setMapped2(string $val): void { $this->mapped2 = $val; } @@ -82,7 +88,7 @@ public function getMapped2(): ?string return $this->mapped2; } - public function setMappedRelated1($mappedRelated1): void + public function setMappedRelated1(MappedSuperclassRelated1 $mappedRelated1): void { $this->mappedRelated1 = $mappedRelated1; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php index d5d370754e..31f6b45ab3 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php @@ -57,6 +57,9 @@ public function testMemoryUsage(): void echo sprintf('Memory increased by %s', $this->formatMemory($increase)); } + /** + * @param int|float $size + */ private function formatMemory($size): string { $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb']; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php index 093f0a53bc..650bdc7bbe 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php @@ -18,7 +18,7 @@ class NestedCollectionsTest extends BaseTest /** * @dataProvider provideStrategy */ - public function testStrategy($field): void + public function testStrategy(string $field): void { $doc = new DocWithNestedCollections(); $privateBook = new Phonebook('Private'); @@ -67,6 +67,9 @@ public function testStrategy($field): void $this->assertEquals('10203040', $publicBook->getPhonenumbers()->get(0)->getPhonenumber()); } + /** + * @return array{array{string}} + */ public function provideStrategy(): array { return [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php index 0f87a76134..dea5f2f804 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php @@ -14,6 +14,8 @@ class RawTypeTest extends BaseTest { /** + * @param mixed $value + * * @dataProvider getTestRawTypeData */ public function testRawType($value): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php index 7ff6f8f410..73d3c62b4b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php @@ -44,7 +44,7 @@ public function testHintIsNotSetByDefault(): void /** * @dataProvider provideReadPreferenceHints */ - public function testHintIsSetOnQuery($readPreference, array $tags = []): void + public function testHintIsSetOnQuery(int $readPreference, array $tags = []): void { $this->skipTestIfSharded(User::class); @@ -98,7 +98,7 @@ public function testDocumentLevelReadPreferenceCanBeOverriddenInQueryBuilder(): $this->assertReadPreferenceHint(ReadPreference::RP_SECONDARY, $query->getQuery()['readPreference']); } - private function assertReadPreferenceHint($mode, $readPreference, array $tags = []): void + private function assertReadPreferenceHint(int $mode, ReadPreference $readPreference, array $tags = []): void { $this->assertInstanceOf(ReadPreference::class, $readPreference); $this->assertEquals($mode, $readPreference->getMode()); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php index 821d615f75..f52a5cd23f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php @@ -15,9 +15,11 @@ class SplObjectHashCollisionsTest extends BaseTest { /** + * @param callable(DocumentManager, object=): void $f + * * @dataProvider provideParentAssociationsIsCleared */ - public function testParentAssociationsIsCleared($f): void + public function testParentAssociationsIsCleared(callable $f): void { $d = new SplColDoc(); $d->one = new SplColEmbed('d.one.v1'); @@ -33,9 +35,11 @@ public function testParentAssociationsIsCleared($f): void } /** + * @param callable(DocumentManager, object=): void $f + * * @dataProvider provideParentAssociationsIsCleared */ - public function testParentAssociationsLeftover($f, $leftover): void + public function testParentAssociationsLeftover(callable $f, int $leftover): void { $d = new SplColDoc(); $d->one = new SplColEmbed('d.one.v1'); @@ -52,23 +56,26 @@ public function testParentAssociationsLeftover($f, $leftover): void $this->expectCount('embeddedDocumentsRegistry', $leftover); } + /** + * @return array + */ public function provideParentAssociationsIsCleared(): array { return [ [ - static function (DocumentManager $dm) { + static function (DocumentManager $dm): void { $dm->clear(); }, 0, ], [ - static function (DocumentManager $dm, $doc) { + static function (DocumentManager $dm, $doc): void { $dm->clear(get_class($doc)); }, 1, ], [ - static function (DocumentManager $dm, $doc) { + static function (DocumentManager $dm, $doc): void { $dm->detach($doc); }, 1, @@ -76,7 +83,7 @@ static function (DocumentManager $dm, $doc) { ]; } - private function expectCount($prop, $expected): void + private function expectCount(string $prop, int $expected): void { $ro = new ReflectionObject($this->uow); $rp = $ro->getProperty($prop); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php index 4ac9620bd8..e35f04c6c4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1011Test.php @@ -72,11 +72,11 @@ class GH1011Embedded /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php index a8662908cc..e97fb3acf4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php @@ -83,7 +83,7 @@ public function getId(): ?string return $this->id; } - public function setValue($value): void + public function setValue(string $value): void { $this->value = $value; } @@ -120,7 +120,7 @@ final public function generateId(): void $this->id = (string) new ObjectId(); } - public function setValue($value): void + public function setValue(string $value): void { $this->value = $value; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php index c0f39926cf..a2abd61d76 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php @@ -152,7 +152,7 @@ public static function getCollectionStrategies(): array /** * @dataProvider getCollectionStrategies */ - public function testResortEmbedManyCollection($strategy): void + public function testResortEmbedManyCollection(string $strategy): void { $getNameCallback = static function (Element $element) { return $element->name; @@ -203,14 +203,14 @@ class Item /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $name; /** @var Container */ protected $container; - public function __construct(Container $c, $name) + public function __construct(Container $c, string $name) { $this->container = $c; $this->name = $name; @@ -232,11 +232,11 @@ class Element /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } @@ -356,7 +356,7 @@ public function add(Item $item): void $this->firstItem = $item; } - public function flip($a, $b): void + public function flip(int $a, int $b): void { $itemA = $this->items->get($a); $itemB = $this->items->get($b); @@ -365,7 +365,7 @@ public function flip($a, $b): void $this->items->set($a, $itemB); } - public function move(Item $item, $move): void + public function move(Item $item, int $move): void { if ($move === 0) { return; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php index 2615ad2bdd..9d1c6dc03a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1572Test.php @@ -101,7 +101,7 @@ public function __construct(GH1572Blog $blog) class GH1572PostRepository extends DocumentRepository { - public function getPostsForBlog($blog): Iterator + public function getPostsForBlog(GH1572Blog $blog): Iterator { return $this->createQueryBuilder() ->field('blog') diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php index 844cc7a03e..c21ac9a424 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php @@ -16,7 +16,7 @@ class GH2002Test extends BaseTest /** * @dataProvider getValidReferenceData */ - public function testBuildingReferenceCreatesCorrectStructure(array $expectedReference, $document): void + public function testBuildingReferenceCreatesCorrectStructure(array $expectedReference, object $document): void { $this->dm->persist($document); @@ -61,7 +61,7 @@ public function getValidReferenceData(): array /** * @dataProvider getInvalidReferenceData */ - public function testBuildingReferenceForUnlistedClassCausesException(string $expectedExceptionMessage, $document): void + public function testBuildingReferenceForUnlistedClassCausesException(string $expectedExceptionMessage, object $document): void { $this->dm->persist($document); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php index fc65e7506a..936fe1a0c6 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH232Test.php @@ -51,7 +51,7 @@ class Product /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $name; @@ -69,7 +69,7 @@ class Product */ public $subproducts = []; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; $this->subproducts = new ArrayCollection(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php index f0dc77b84d..68689a8b2e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH267Test.php @@ -141,7 +141,7 @@ class GH267Company */ protected $users; - public function setId($id): void + public function setId(string $id): void { $this->id = $id; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php index 0a0280f0ed..c72f105f90 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php @@ -240,17 +240,26 @@ public function testReferenceMany(): void $this->assertBsonArray($doc->id, 'referenceManyAddToSet'); } - private function assertBsonArray($documentId, $fieldName): void + /** + * @param mixed $documentId + */ + private function assertBsonArray($documentId, string $fieldName): void { $this->assertBsonType(4, $documentId, $fieldName); } - private function assertBsonObject($documentId, $fieldName): void + /** + * @param mixed $documentId + */ + private function assertBsonObject($documentId, string $fieldName): void { $this->assertBsonType(3, $documentId, $fieldName); } - private function assertBsonType($bsonType, $documentId, $fieldName): void + /** + * @param mixed $documentId + */ + private function assertBsonType(int $bsonType, $documentId, string $fieldName): void { $criteria = ['_id' => $documentId]; @@ -264,17 +273,29 @@ private function assertBsonType($bsonType, $documentId, $fieldName): void $this->assertNotNull($this->dm->getRepository(GH453Document::class)->findOneBy($criteria)); } - private function assertBsonArrayAndValue($expectedValue, $documentId, $fieldName): void + /** + * @param mixed $expectedValue + * @param mixed $documentId + */ + private function assertBsonArrayAndValue($expectedValue, $documentId, string $fieldName): void { $this->assertBsonTypeAndValue(4, $expectedValue, $documentId, $fieldName); } - private function assertBsonObjectAndValue($expectedValue, $documentId, $fieldName): void + /** + * @param mixed $expectedValue + * @param mixed $documentId + */ + private function assertBsonObjectAndValue($expectedValue, $documentId, string $fieldName): void { $this->assertBsonTypeAndValue(3, $expectedValue, $documentId, $fieldName); } - private function assertBsonTypeAndValue($bsonType, $expectedValue, $documentId, $fieldName): void + /** + * @param mixed $expectedValue + * @param mixed $documentId + */ + private function assertBsonTypeAndValue(int $bsonType, $expectedValue, $documentId, string $fieldName): void { if ($bsonType === 4) { $expectedValue = array_values((array) $expectedValue); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php index 90bedbbd88..f50a125996 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php @@ -14,6 +14,8 @@ class GH560Test extends BaseTest { /** + * @param int|string $id + * * @dataProvider provideDocumentIds */ public function testPersistListenersAreCalled($id): void @@ -39,6 +41,8 @@ public function testPersistListenersAreCalled($id): void } /** + * @param int|string $id + * * @dataProvider provideDocumentIds */ public function testDocumentWithCustomIdStrategyIsSavedAndFoundFromDatabase($id): void @@ -53,6 +57,8 @@ public function testDocumentWithCustomIdStrategyIsSavedAndFoundFromDatabase($id) } /** + * @param int|string $id + * * @dataProvider provideDocumentIds */ public function testUpdateListenersAreCalled($id): void @@ -108,7 +114,7 @@ public function getSubscribedEvents(): array return $this->events; } - public function __call($eventName, $args) + public function __call(string $eventName, array $args) { $this->called[] = [$eventName, get_class($args[0]->getDocument())]; } @@ -131,6 +137,9 @@ class GH560Document */ public $name; + /** + * @param int|string $id + */ public function __construct($id, string $name) { $this->id = $id; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php index ca6cf2db14..97005f4c3e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH597Test.php @@ -172,11 +172,11 @@ class GH597Comment /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $comment; - public function __construct($comment) + public function __construct(string $comment) { $this->comment = $comment; } @@ -196,11 +196,11 @@ class GH597ReferenceMany /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $field; - public function __construct($field) + public function __construct(string $field) { $this->field = $field; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php index 67b894ee18..3611019d8c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH602Test.php @@ -92,7 +92,10 @@ public function testReferenceManyInverseSidePreparesFilterCriteriaForDifferentCl $this->assertEquals($user1->getId(), $thing1likedBy[0]->getId()); } - private function enableDeletedFilter($class): void + /** + * @psaml-param class-string $class + */ + private function enableDeletedFilter(string $class): void { $this->dm->getFilterCollection()->enable('testFilter'); $filter = $this->dm->getFilterCollection()->getFilter('testFilter'); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php index aec92ab520..be9272bf3b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH880Test.php @@ -53,18 +53,18 @@ class GH880Document /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $status; /** * @ODM\Field(type="int") * - * @var int|null + * @var int */ public $category; - public function __construct($status = '', $category = 0) + public function __construct(string $status = '', int $category = 0) { $this->status = $status; $this->category = $category; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php index a241920d82..4ea555addf 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH999Test.php @@ -56,11 +56,11 @@ class GH999Document /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ private $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } @@ -75,7 +75,7 @@ public function getName(): ?string return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php index 1002f3c6a6..da76857790 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php @@ -67,7 +67,7 @@ class MODM45B */ protected $val; - public function setVal($val): void + public function setVal(string $val): void { $this->val = $val; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php index 0e84982640..c06255ba9e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php @@ -41,7 +41,7 @@ class MODM47A public $b = 'tmp'; /** @ODM\AlsoLoad("c") */ - public function renameC($c): void + public function renameC(string $c): void { $this->b = $c; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php index 101642d270..404714dccc 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php @@ -57,7 +57,7 @@ public function getB(): ?MODM48B return $this->b; } - public function setB($b): void + public function setB(MODM48B $b): void { $this->b = $b; } @@ -73,7 +73,7 @@ class MODM48B */ public $val; - public function setVal($val): void + public function setVal(string $val): void { $this->val = $val; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php index 198974e063..7c7e3041fa 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM56Test.php @@ -48,7 +48,7 @@ class MODM56Parent /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ public $name; @@ -66,7 +66,7 @@ class MODM56Parent */ public $children = []; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php index fb394a8514..f13b6936e3 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM70Test.php @@ -146,7 +146,7 @@ class AvatarPart */ protected $color; - public function __construct($color = null) + public function __construct(string $color) { $this->color = $color; } @@ -156,7 +156,7 @@ public function getColor(): string return $this->color; } - public function setColor($color): void + public function setColor(string $color): void { $this->color = $color; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php index 3694c2ecda..d35313ec45 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php @@ -63,7 +63,7 @@ class MODM83EventListener /** @var array */ public $called = []; - public function __call($method, $args) + public function __call(string $method, array $args) { $document = $args[0]->getDocument(); $className = get_class($document); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php index ac70964de3..389b703cd0 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php @@ -79,7 +79,7 @@ class MODM90EventListener /** @var array */ public $called = []; - public function __call($method, $args) + public function __call(string $method, array $args) { $document = $args[0]->getDocument(); $className = get_class($document); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php index 7f278aa39c..72728ad84f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php @@ -55,7 +55,7 @@ class MODM91EventListener /** @var array */ public $called = []; - public function __call($method, $args) + public function __call(string $method, array $args) { $document = $args[0]->getDocument(); $className = get_class($document); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php index dffef4353f..9091494f94 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php @@ -533,9 +533,11 @@ public function testSimpleAsStringReferenceRequiresTargetDocument(): void } /** + * @param mixed $value + * * @dataProvider provideRepositoryMethodCanNotBeCombinedWithSkipLimitAndSort */ - public function testRepositoryMethodCanNotBeCombinedWithSkipLimitAndSort($prop, $value): void + public function testRepositoryMethodCanNotBeCombinedWithSkipLimitAndSort(string $prop, $value): void { $cm = new ClassMetadata('stdClass'); @@ -616,7 +618,7 @@ public function testDefaultStorageStrategyOfEmbeddedDocumentFields(): void /** * @dataProvider provideOwningAndInversedRefsNeedTargetDocument */ - public function testOwningAndInversedRefsNeedTargetDocument($config): void + public function testOwningAndInversedRefsNeedTargetDocument(array $config): void { $config = array_merge($config, [ 'fieldName' => 'many', diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php index eb5449cf5b..50a8b382a4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php @@ -59,7 +59,7 @@ public function testMemoryUsage(): void echo sprintf('Memory increased by %s', $this->formatMemory($increase)) . PHP_EOL; } - private function formatMemory($size): string + private function formatMemory(int $size): string { $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb']; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php index 43f9428fcd..9053b1422c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php @@ -212,7 +212,7 @@ public function testPrepareUpsertData(): void /** * @dataProvider getDocumentsAndExpectedData */ - public function testPrepareInsertData($document, array $expectedData): void + public function testPrepareInsertData(object $document, array $expectedData): void { $this->dm->persist($document); $this->uow->computeChangeSets(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php index b844eeaaaa..bf396e5808 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php @@ -188,9 +188,11 @@ public function testIncludesReferenceToThrowsSpecializedExceptionForConflictingM } /** + * @param class-string $class + * * @dataProvider provideArrayUpdateOperatorsOnReferenceMany */ - public function testArrayUpdateOperatorsOnReferenceMany($class, $field): void + public function testArrayUpdateOperatorsOnReferenceMany(string $class, string $field): void { $f = new Feature('Smarter references'); $this->dm->persist($f); @@ -212,9 +214,11 @@ public function provideArrayUpdateOperatorsOnReferenceMany(): Generator } /** + * @param class-string $class + * * @dataProvider provideArrayUpdateOperatorsOnReferenceOne */ - public function testArrayUpdateOperatorsOnReferenceOne($class, $field): void + public function testArrayUpdateOperatorsOnReferenceOne(string $class, string $field): void { $f = new Feature('Smarter references'); $this->dm->persist($f); @@ -472,7 +476,7 @@ public function testDeepClone(): void /** * @dataProvider provideProxiedExprMethods */ - public function testProxiedExprMethods($method, array $args = []): void + public function testProxiedExprMethods(string $method, array $args = []): void { $expr = $this->getMockExpr(); $expr @@ -488,6 +492,9 @@ public function testProxiedExprMethods($method, array $args = []): void $this->assertSame($qb, $qb->$method(...$args)); } + /** + * @return array + */ public function provideProxiedExprMethods(): array { return [ @@ -695,9 +702,11 @@ public function testSortWithFieldNameAndDefaultOrder(): void } /** + * @param string|int $order + * * @dataProvider provideSortOrders */ - public function testSortWithFieldNameAndOrder($order, $expectedOrder): void + public function testSortWithFieldNameAndOrder($order, int $expectedOrder): void { $qb = $this->getTestQueryBuilder() ->sort('foo', $order); @@ -750,7 +759,7 @@ public function testSortMetaDoesNotProjectExistingField(): void /** * @dataProvider provideCurrentDateOptions */ - public function testCurrentDateUpdateQuery($type): void + public function testCurrentDateUpdateQuery(string $type): void { $qb = $this->getTestQueryBuilder() ->updateOne() @@ -875,7 +884,7 @@ private function getMockGeometry() /** * @return MockObject&Point */ - private function getMockPoint($json) + private function getMockPoint(array $json) { $point = $this->getMockBuilder(Point::class) ->disableOriginalConstructor() diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php index a5a212c9e0..1419da2634 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php @@ -409,6 +409,8 @@ public function provideGeoJsonPoint(): array } /** + * @param mixed $point + * * @dataProvider provideGeoJsonPoint */ public function testNearWithGeoJsonPoint($point, array $expected): void @@ -428,6 +430,8 @@ public function testNearWithLegacyCoordinates(): void } /** + * @param mixed $point + * * @dataProvider provideGeoJsonPoint */ public function testNearSphereWithGeoJsonPoint($point, array $expected): void @@ -540,6 +544,8 @@ public function testPushWithPosition(): void } /** + * @param mixed $geometry + * * @dataProvider provideGeoJsonPolygon */ public function testGeoIntersects($geometry, array $expected): void @@ -566,6 +572,8 @@ public function provideGeoJsonPolygon(): array } /** + * @param mixed $geometry + * * @dataProvider provideGeoJsonPolygon */ public function testGeoWithin($geometry, array $expected): void @@ -694,7 +702,7 @@ private function createExpr(): Expr /** * @return MockObject&Point */ - private function getMockPoint($json) + private function getMockPoint(array $json) { $point = $this->getMockBuilder(Point::class) ->disableOriginalConstructor() @@ -710,7 +718,7 @@ private function getMockPoint($json) /** * @return MockObject&Polygon */ - private function getMockPolygon($json) + private function getMockPolygon(array $json) { $point = $this->getMockBuilder(Polygon::class) ->disableOriginalConstructor() diff --git a/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php b/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php index 79db9b76d1..cde77568f7 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php @@ -423,7 +423,7 @@ public function testConstructorShouldThrowExceptionForInvalidType(): void /** * @dataProvider provideQueryTypesThatDoNotReturnAnIterator */ - public function testGetIteratorShouldThrowExceptionWithoutExecutingForTypesThatDoNotReturnAnIterator($type, $method): void + public function testGetIteratorShouldThrowExceptionWithoutExecutingForTypesThatDoNotReturnAnIterator(int $type, string $method): void { $collection = $this->getMockCollection(); $collection->expects($this->never())->method($method); @@ -652,7 +652,7 @@ class Person */ public $pet; - public function __construct($firstName) + public function __construct(string $firstName) { $this->firstName = $firstName; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Repository/DefaultGridFSRepositoryTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Repository/DefaultGridFSRepositoryTest.php index 237bc51126..426754c32e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Repository/DefaultGridFSRepositoryTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Repository/DefaultGridFSRepositoryTest.php @@ -255,7 +255,10 @@ public function testUploadFileWithoutChunkSize(): void self::assertSame(261120, $file->getChunkSize()); } - private function getRepository($className = File::class): GridFSRepository + /** + * @param class-string $className + */ + private function getRepository(string $className = File::class): GridFSRepository { $repository = $this->dm->getRepository($className); @@ -264,7 +267,7 @@ private function getRepository($className = File::class): GridFSRepository return $repository; } - private function uploadFile($filename, ?UploadOptions $uploadOptions = null): File + private function uploadFile(string $filename, ?UploadOptions $uploadOptions = null): File { $fileResource = fopen($filename, 'r'); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php index daf9b6d1f8..dbf813dd10 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php @@ -748,7 +748,7 @@ public function testDropDatabases(array $expectedWriteOptions, ?int $maxTimeMs, /** * @dataProvider dataIsMongoIndexEquivalentToDocumentIndex */ - public function testIsMongoIndexEquivalentToDocumentIndex($expected, $mongoIndex, $documentIndex): void + public function testIsMongoIndexEquivalentToDocumentIndex(bool $expected, array $mongoIndex, array $documentIndex): void { $defaultMongoIndex = [ 'key' => ['foo' => 1, 'bar' => -1], @@ -958,7 +958,7 @@ public function dataIsMongoIndexEquivalentToDocumentIndex(): array /** * @dataProvider dataIsMongoTextIndexEquivalentToDocumentIndex */ - public function testIsMongoIndexEquivalentToDocumentIndexWithTextIndexes($expected, $mongoIndex, $documentIndex): void + public function testIsMongoIndexEquivalentToDocumentIndexWithTextIndexes(bool $expected, array $mongoIndex, array $documentIndex): void { $defaultMongoIndex = [ 'key' => ['_fts' => 'text', '_ftsx' => 1], diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Tools/GH297/Address.php b/tests/Doctrine/ODM/MongoDB/Tests/Tools/GH297/Address.php index bb49082339..6b921ea0a6 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Tools/GH297/Address.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Tools/GH297/Address.php @@ -21,7 +21,7 @@ public function getStreet(): ?string return $this->street; } - public function setStreet($street): void + public function setStreet(string $street): void { $this->street = $street; } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php index ca20edead6..77433d5365 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php @@ -76,6 +76,8 @@ public function testConvertOldDate(): void } /** + * @param mixed $value + * * @dataProvider provideInvalidDateValues */ public function testConvertToDatabaseValueWithInvalidValues($value): void @@ -97,9 +99,11 @@ public function provideInvalidDateValues(): array } /** + * @param mixed $input + * * @dataProvider provideDatabaseToPHPValues */ - public function testConvertToPHPValue($input, $output): void + public function testConvertToPHPValue($input, DateTimeImmutable $output): void { $type = Type::getType(Type::DATE_IMMUTABLE); $return = $type->convertToPHPValue($input); @@ -116,9 +120,11 @@ public function testConvertToPHPValueDoesNotConvertNull(): void } /** + * @param mixed $input + * * @dataProvider provideDatabaseToPHPValues */ - public function testClosureToPHP($input, $output): void + public function testClosureToPHP($input, DateTimeImmutable $output): void { $type = Type::getType(Type::DATE_IMMUTABLE); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php index 0d70a6e881..e0b072a377 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php @@ -76,6 +76,8 @@ public function testConvertOldDate(): void } /** + * @param mixed $value + * * @dataProvider provideInvalidDateValues */ public function testConvertToDatabaseValueWithInvalidValues($value): void @@ -97,9 +99,11 @@ public function provideInvalidDateValues(): array } /** + * @param mixed $input + * * @dataProvider provideDatabaseToPHPValues */ - public function testConvertToPHPValue($input, $output): void + public function testConvertToPHPValue($input, DateTime $output): void { $type = Type::getType(Type::DATE); $return = $type->convertToPHPValue($input); @@ -116,9 +120,11 @@ public function testConvertToPHPValueDoesNotConvertNull(): void } /** + * @param mixed $input + * * @dataProvider provideDatabaseToPHPValues */ - public function testClosureToPHP($input, $output): void + public function testClosureToPHP($input, DateTime $output): void { $type = Type::getType(Type::DATE); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php index f2facdbd5f..61fad14522 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php @@ -21,6 +21,8 @@ public function testConvertToDatabaseValue(): void } /** + * @param mixed $value + * * @dataProvider provideInvalidObjectIdConstructorArguments */ public function testConvertToDatabaseValueShouldGenerateObjectIds($value): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php index 65d6c06147..3644030ec1 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php @@ -24,6 +24,8 @@ class TypeTest extends BaseTest { /** + * @param mixed $test + * * @dataProvider provideTypes */ public function testConversion(Type $type, $test): void @@ -62,6 +64,8 @@ public function provideTypes(): array } /** + * @param mixed $test + * * @dataProvider provideTypesForIdempotent */ public function testConversionIsIdempotent(Type $type, $test): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php b/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php index f1c5253f06..930c035235 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php @@ -251,7 +251,7 @@ public function testComputingChangesetForFileWithoutMetadataThrowsNoError(): voi /** * @dataProvider getScheduleForUpdateWithArraysTests */ - public function testScheduleForUpdateWithArrays($origData, $updateData, $shouldInUpdate): void + public function testScheduleForUpdateWithArrays(?array $origData, ?array $updateData, bool $shouldInUpdate): void { $arrayTest = new ArrayTest($origData); $this->uow->persist($arrayTest); @@ -605,7 +605,7 @@ public function getId(): ?int return $this->id; } - public function setId($id): void + public function setId(int $id): void { $this->id = $id; } @@ -615,7 +615,7 @@ public function getData(): ?string return $this->data; } - public function setData($data): void + public function setData(string $data): void { if ($data === $this->data) { return; @@ -630,6 +630,9 @@ public function getItems(): Collection return $this->items; } + /** + * @param mixed $value + */ public function setTransient($value): void { if ($value === $this->transient) { @@ -645,7 +648,11 @@ public function addPropertyChangedListener(PropertyChangedListener $listener) $this->_listeners[] = $listener; } - protected function onPropertyChanged($propName, $oldValue, $newValue): void + /** + * @param mixed $oldValue + * @param mixed $newValue + */ + protected function onPropertyChanged(string $propName, $oldValue, $newValue): void { foreach ($this->_listeners as $listener) { $listener->propertyChanged($this, $propName, $oldValue, $newValue); @@ -675,7 +682,7 @@ public function getId(): ?int return $this->id; } - public function setId($id): void + public function setId(int $id): void { $this->id = $id; } @@ -685,7 +692,7 @@ public function getOwner(): ?NotifyChangedDocument return $this->owner; } - public function setOwner($owner): void + public function setOwner(NotifyChangedDocument $owner): void { $this->owner = $owner; } diff --git a/tests/Documents/Address.php b/tests/Documents/Address.php index 34098d6dc1..820451c394 100644 --- a/tests/Documents/Address.php +++ b/tests/Documents/Address.php @@ -73,7 +73,7 @@ public function getAddress(): ?string return $this->address; } - public function setAddress($address): void + public function setAddress(string $address): void { $this->address = $address; } @@ -83,7 +83,7 @@ public function getCity(): ?string return $this->city; } - public function setCity($city): void + public function setCity(string $city): void { $this->city = $city; } @@ -93,7 +93,7 @@ public function getState(): ?string return $this->state; } - public function setState($state): void + public function setState(string $state): void { $this->state = $state; } @@ -103,7 +103,7 @@ public function getZipcode(): ?string return $this->zipcode; } - public function setZipcode($zipcode): void + public function setZipcode(string $zipcode): void { $this->zipcode = $zipcode; } diff --git a/tests/Documents/Album.php b/tests/Documents/Album.php index 0c300295cd..fb62b01316 100644 --- a/tests/Documents/Album.php +++ b/tests/Documents/Album.php @@ -21,7 +21,7 @@ class Album /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ private $name; @@ -32,7 +32,7 @@ class Album */ private $songs; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; $this->songs = new ArrayCollection(); @@ -43,7 +43,7 @@ public function getId(): ?string return $this->id; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/Article.php b/tests/Documents/Article.php index a3b0b030be..0650395d13 100644 --- a/tests/Documents/Article.php +++ b/tests/Documents/Article.php @@ -61,7 +61,7 @@ public function getTitle(): ?string return $this->title; } - public function setTitle($title): void + public function setTitle(string $title): void { $this->title = $title; } diff --git a/tests/Documents/Bars/Bar.php b/tests/Documents/Bars/Bar.php index 352f17c17b..7d4b301420 100644 --- a/tests/Documents/Bars/Bar.php +++ b/tests/Documents/Bars/Bar.php @@ -58,12 +58,18 @@ public function addLocation(Location $location): void $this->locations[] = $location; } + /** + * @return Collection + */ public function getLocations(): Collection { return $this->locations; } - public function setLocations($locations): void + /** + * @param Collection $locations + */ + public function setLocations(Collection $locations): void { $this->locations = $locations; } diff --git a/tests/Documents/BaseCategory.php b/tests/Documents/BaseCategory.php index 5cb905892f..60c5421904 100644 --- a/tests/Documents/BaseCategory.php +++ b/tests/Documents/BaseCategory.php @@ -29,7 +29,7 @@ public function __construct(?string $name = null) $this->name = $name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/BaseDocument.php b/tests/Documents/BaseDocument.php index 55342d1765..eb73c165ce 100644 --- a/tests/Documents/BaseDocument.php +++ b/tests/Documents/BaseDocument.php @@ -19,7 +19,7 @@ abstract class BaseDocument */ protected $inheritedProperty; - public function setInheritedProperty($value): void + public function setInheritedProperty(string $value): void { $this->inheritedProperty = $value; } diff --git a/tests/Documents/BaseEmployee.php b/tests/Documents/BaseEmployee.php index 567787b704..3789fe9a21 100644 --- a/tests/Documents/BaseEmployee.php +++ b/tests/Documents/BaseEmployee.php @@ -71,7 +71,7 @@ public function getId(): ?string return $this->id; } - public function setId($val): BaseEmployee + public function setId(string $val): BaseEmployee { $this->id = $val; @@ -83,7 +83,7 @@ public function getChanges(): int return $this->changes; } - public function incrementChanges($num): BaseEmployee + public function incrementChanges(int $num): BaseEmployee { $this->changes += $num; @@ -95,7 +95,7 @@ public function getNotes(): array return $this->notes; } - public function addNote($note): BaseEmployee + public function addNote(string $note): BaseEmployee { $this->notes[] = $note; @@ -107,7 +107,7 @@ public function getName(): ?string return $this->name; } - public function setName($val): BaseEmployee + public function setName(string $val): BaseEmployee { $this->name = $val; @@ -119,7 +119,7 @@ public function getSalary(): ?float return $this->salary; } - public function setSalary($val): BaseEmployee + public function setSalary(float $val): BaseEmployee { $this->salary = $val; @@ -131,7 +131,7 @@ public function getStarted(): ?DateTime return $this->started; } - public function setStarted($val): BaseEmployee + public function setStarted(DateTime $val): BaseEmployee { $this->started = $val; @@ -143,7 +143,7 @@ public function getLeft(): ?DateTime return $this->left; } - public function setLeft($val): BaseEmployee + public function setLeft(DateTime $val): BaseEmployee { $this->left = $val; @@ -155,7 +155,7 @@ public function getAddress(): ?Address return $this->address; } - public function setAddress($val): BaseEmployee + public function setAddress(Address $val): BaseEmployee { $this->address = $val; diff --git a/tests/Documents/CmsUser.php b/tests/Documents/CmsUser.php index 2910195dea..9872504056 100644 --- a/tests/Documents/CmsUser.php +++ b/tests/Documents/CmsUser.php @@ -132,7 +132,7 @@ public function getGroups(): Collection return $this->groups; } - public function removePhonenumber($index): bool + public function removePhonenumber(int $index): bool { if (isset($this->phonenumbers[$index])) { $ph = $this->phonenumbers[$index]; diff --git a/tests/Documents/CustomUser.php b/tests/Documents/CustomUser.php index ef3e514c16..0ceaaf4a1e 100644 --- a/tests/Documents/CustomUser.php +++ b/tests/Documents/CustomUser.php @@ -42,12 +42,12 @@ public function getId(): ?string return $this->id; } - public function setId($id): void + public function setId(string $id): void { $this->id = $id; } - public function setUsername($username): void + public function setUsername(string $username): void { $this->username = $username; } @@ -57,7 +57,7 @@ public function getUsername(): ?string return $this->username; } - public function setPassword($password): void + public function setPassword(string $password): void { $this->password = $password; } diff --git a/tests/Documents/Ecommerce/Currency.php b/tests/Documents/Ecommerce/Currency.php index ee7e3d481c..8e76f07341 100644 --- a/tests/Documents/Ecommerce/Currency.php +++ b/tests/Documents/Ecommerce/Currency.php @@ -29,7 +29,7 @@ class Currency /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ protected $name; @@ -40,9 +40,11 @@ class Currency */ protected $multiplier; - public function __construct($name, $multiplier = 1) + /** + * @param float|int $multiplier + */ + public function __construct(string $name, $multiplier = 1) { - $name = (string) $name; if (! in_array($name, self::getAll())) { throw new InvalidArgumentException( 'Currency must be one of ' . implode(', ', self::getAll()) . @@ -69,6 +71,9 @@ public function getMultiplier(): float return $this->multiplier; } + /** + * @param float|int|string $multiplier + */ public function setMultiplier($multiplier): void { $multiplier = (float) $multiplier; @@ -81,6 +86,9 @@ public function setMultiplier($multiplier): void $this->multiplier = $multiplier; } + /** + * @return string[] + */ public static function getAll(): array { return [ diff --git a/tests/Documents/Ecommerce/Money.php b/tests/Documents/Ecommerce/Money.php index 9ffdfce988..bf736c69b6 100644 --- a/tests/Documents/Ecommerce/Money.php +++ b/tests/Documents/Ecommerce/Money.php @@ -24,9 +24,8 @@ class Money */ protected $currency; - public function __construct($amount, Currency $currency) + public function __construct(float $amount, Currency $currency) { - $amount = (float) $amount; if (empty($amount) || $amount <= 0) { throw new InvalidArgumentException( 'money amount cannot be empty, equal or less than 0' diff --git a/tests/Documents/Ecommerce/Option.php b/tests/Documents/Ecommerce/Option.php index 86c32dbe9b..fe5e8bde60 100644 --- a/tests/Documents/Ecommerce/Option.php +++ b/tests/Documents/Ecommerce/Option.php @@ -63,7 +63,7 @@ public function getName(): string /** * @return float|Money */ - public function getPrice($object = false) + public function getPrice(?bool $object = false) { if ($object === true) { return $this->money; diff --git a/tests/Documents/Ecommerce/StockItem.php b/tests/Documents/Ecommerce/StockItem.php index 27ca949133..c18d95c7d0 100644 --- a/tests/Documents/Ecommerce/StockItem.php +++ b/tests/Documents/Ecommerce/StockItem.php @@ -83,9 +83,9 @@ public function getCost(): float return $this->cost->getAmount(); } - public function setInventory($inventory): StockItem + public function setInventory(int $inventory): StockItem { - $this->inventory = (int) $inventory; + $this->inventory = $inventory; return $this; } diff --git a/tests/Documents/Employee.php b/tests/Documents/Employee.php index e944fc302d..eb7b2554aa 100644 --- a/tests/Documents/Employee.php +++ b/tests/Documents/Employee.php @@ -21,7 +21,7 @@ public function getManager(): ?Manager return $this->manager; } - public function setManager($val): Employee + public function setManager(Manager $val): Employee { $this->manager = $val; diff --git a/tests/Documents/Event.php b/tests/Documents/Event.php index f750d3e4fd..36976fbd41 100644 --- a/tests/Documents/Event.php +++ b/tests/Documents/Event.php @@ -57,7 +57,7 @@ public function getTitle(): ?string return $this->title; } - public function setTitle($title): void + public function setTitle(string $title): void { $this->title = $title; } @@ -67,7 +67,7 @@ public function getType(): ?string return $this->type; } - public function setType($type): void + public function setType(string $type): void { $this->type = $type; } diff --git a/tests/Documents/Functional/FavoritesUser.php b/tests/Documents/Functional/FavoritesUser.php index 255e795635..04e91a09d1 100644 --- a/tests/Documents/Functional/FavoritesUser.php +++ b/tests/Documents/Functional/FavoritesUser.php @@ -71,7 +71,7 @@ public function getId(): ?string return $this->id; } - public function setFavorite($favorite): void + public function setFavorite(object $favorite): void { $this->favorite = $favorite; } diff --git a/tests/Documents/Functional/PreUpdateTestProduct.php b/tests/Documents/Functional/PreUpdateTestProduct.php index d749d9de87..d97c513831 100644 --- a/tests/Documents/Functional/PreUpdateTestProduct.php +++ b/tests/Documents/Functional/PreUpdateTestProduct.php @@ -37,7 +37,7 @@ public function getName(): ?string return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/Functional/PreUpdateTestSeller.php b/tests/Documents/Functional/PreUpdateTestSeller.php index b867911a55..5944d7f5e5 100644 --- a/tests/Documents/Functional/PreUpdateTestSeller.php +++ b/tests/Documents/Functional/PreUpdateTestSeller.php @@ -28,7 +28,7 @@ public function getName(): ?string return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/Functional/VirtualHostDirective.php b/tests/Documents/Functional/VirtualHostDirective.php index c15f666437..670c14ff35 100644 --- a/tests/Documents/Functional/VirtualHostDirective.php +++ b/tests/Documents/Functional/VirtualHostDirective.php @@ -54,7 +54,7 @@ public function getRecId(): ?string return $this->recId; } - public function setRecId($value = null): void + public function setRecId(?string $value = null): void { if (! $value) { $value = uniqid(); @@ -68,9 +68,9 @@ public function getName(): string return $this->name; } - public function setName($value): void + public function setName(string $name): void { - $this->name = $value; + $this->name = $name; } public function getValue(): string @@ -78,11 +78,14 @@ public function getValue(): string return $this->value; } - public function setValue($value): void + public function setValue(string $value): void { $this->value = $value; } + /** + * @return Collection + */ public function getDirectives(): Collection { if (! $this->directives) { @@ -92,7 +95,10 @@ public function getDirectives(): Collection return $this->directives; } - public function setDirectives($value): VirtualHostDirective + /** + * @param Collection $value + */ + public function setDirectives(Collection $value): VirtualHostDirective { $this->directives = $value; @@ -117,7 +123,7 @@ public function hasDirective(string $name): ?VirtualHostDirective return null; } - public function getDirective($name): ?VirtualHostDirective + public function getDirective(string $name): ?VirtualHostDirective { return $this->hasDirective($name); } diff --git a/tests/Documents/IdentifiedChapter.php b/tests/Documents/IdentifiedChapter.php index f3343c2c37..574e79d22a 100644 --- a/tests/Documents/IdentifiedChapter.php +++ b/tests/Documents/IdentifiedChapter.php @@ -32,7 +32,7 @@ class IdentifiedChapter */ public $pages; - public function __construct($name = null) + public function __construct(?string $name = null) { $this->name = $name; $this->pages = new ArrayCollection(); diff --git a/tests/Documents/Issue.php b/tests/Documents/Issue.php index c68675528f..c59b209250 100644 --- a/tests/Documents/Issue.php +++ b/tests/Documents/Issue.php @@ -14,29 +14,29 @@ class Issue /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ private $name; /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ private $description; - public function __construct($name, $description) + public function __construct(string $name, string $description) { $this->name = $name; $this->description = $description; } - public function getName(): ?string + public function getName(): string { return $this->name; } - public function getDescription(): ?string + public function getDescription(): string { return $this->description; } diff --git a/tests/Documents/Message.php b/tests/Documents/Message.php index 3aa5aed0f9..63a80db6c6 100644 --- a/tests/Documents/Message.php +++ b/tests/Documents/Message.php @@ -19,11 +19,11 @@ class Message /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ private $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } @@ -33,7 +33,7 @@ public function getId(): ?string return $this->id; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/Page.php b/tests/Documents/Page.php index 2459582620..281bc0ea95 100644 --- a/tests/Documents/Page.php +++ b/tests/Documents/Page.php @@ -19,11 +19,11 @@ class Page /** * @ODM\Field(type="int") * - * @var int|null + * @var int */ public $number; - public function __construct($number) + public function __construct(int $number) { $this->number = $number; } diff --git a/tests/Documents/Phonebook.php b/tests/Documents/Phonebook.php index e0d5b6fb8d..91b261e577 100644 --- a/tests/Documents/Phonebook.php +++ b/tests/Documents/Phonebook.php @@ -36,7 +36,7 @@ public function getTitle(): string return $this->title; } - public function setTitle($title): void + public function setTitle(string $title): void { $this->title = $title; } diff --git a/tests/Documents/ProfileNotify.php b/tests/Documents/ProfileNotify.php index 90c7e2112c..6181ffa777 100644 --- a/tests/Documents/ProfileNotify.php +++ b/tests/Documents/ProfileNotify.php @@ -55,12 +55,16 @@ public function __construct() $this->images = new ProfileNotifyImagesCollection(); } - public function addPropertyChangedListener(PropertyChangedListener $listener) + public function addPropertyChangedListener(PropertyChangedListener $listener): void { $this->listeners[] = $listener; } - private function propertyChanged($propName, $oldValue, $newValue): void + /** + * @param mixed $oldValue + * @param mixed $newValue + */ + private function propertyChanged(string $propName, $oldValue, $newValue): void { foreach ($this->listeners as $listener) { $listener->propertyChanged($this, $propName, $oldValue, $newValue); @@ -72,7 +76,7 @@ public function getProfileId(): ?string return $this->profileId; } - public function setFirstName($firstName): void + public function setFirstName(string $firstName): void { $this->propertyChanged('firstName', $this->firstName, $firstName); $this->firstName = $firstName; @@ -83,7 +87,7 @@ public function getFirstName(): ?string return $this->firstName; } - public function setLastName($lastName): void + public function setLastName(string $lastName): void { $this->propertyChanged('lastName', $this->lastName, $lastName); $this->lastName = $lastName; @@ -111,8 +115,17 @@ public function getImages(): ProfileNotifyImagesCollection } } +/** + * @template TKey of array-key + * @template T + * @template-extends ArrayCollection + */ class ProfileNotifyImagesCollection extends ArrayCollection { + /** + * @param TKey $i + * @param TKey $j + */ public function move($i, $j): void { $tmp = $this->get($i); diff --git a/tests/Documents/Project.php b/tests/Documents/Project.php index 33f34e3158..334ea535ba 100644 --- a/tests/Documents/Project.php +++ b/tests/Documents/Project.php @@ -63,7 +63,7 @@ public function getName(): ?string return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/Song.php b/tests/Documents/Song.php index 154c39b2f5..67574bca96 100644 --- a/tests/Documents/Song.php +++ b/tests/Documents/Song.php @@ -12,16 +12,16 @@ class Song /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ private $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/Task.php b/tests/Documents/Task.php index ed70f70685..028c083c06 100644 --- a/tests/Documents/Task.php +++ b/tests/Documents/Task.php @@ -19,11 +19,11 @@ class Task /** * @ODM\Field(type="string") * - * @var string|null + * @var string */ private $name; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } @@ -33,7 +33,7 @@ public function getId(): ?string return $this->id; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/Tournament/Tournament.php b/tests/Documents/Tournament/Tournament.php index 728fdc8518..3ae9cce0be 100644 --- a/tests/Documents/Tournament/Tournament.php +++ b/tests/Documents/Tournament/Tournament.php @@ -24,7 +24,7 @@ class Tournament /** * @ODM\Field * - * @var string|null + * @var string */ private $name; @@ -35,7 +35,7 @@ class Tournament */ protected $participants = []; - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } @@ -45,7 +45,7 @@ public function getId(): ?string return $this->id; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Documents/User.php b/tests/Documents/User.php index 68f5aeb7b8..b5bb8818f6 100644 --- a/tests/Documents/User.php +++ b/tests/Documents/User.php @@ -5,9 +5,11 @@ namespace Documents; use DateTime; +use DateTimeInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; +use MongoDB\BSON\ObjectId; use function bcadd; @@ -20,7 +22,7 @@ class User extends BaseDocument /** * @ODM\Id * - * @var string|null + * @var ObjectId|string|null */ protected $id; @@ -41,7 +43,7 @@ class User extends BaseDocument /** * @ODM\Field(type="date") * - * @var DateTime + * @var DateTimeInterface|string */ protected $createdAt; @@ -209,7 +211,7 @@ class User extends BaseDocument /** * @ODM\Field(type="collection") * - * @var array + * @var string[] */ private $logs = []; @@ -239,6 +241,9 @@ public function __construct() $this->createdAt = new DateTime(); } + /** + * @param ObjectId|string $id + */ public function setId($id): void { $this->id = $id; @@ -249,22 +254,28 @@ public function getLogs(): array return $this->logs; } - public function setLogs($logs): void + /** + * @param string[] $logs + */ + public function setLogs(array $logs): void { $this->logs = $logs; } - public function log($log): void + public function log(string $log): void { $this->logs[] = $log; } - public function getId(): ?string + /** + * @return ObjectId|string|null + */ + public function getId() { return $this->id; } - public function setUsername($username): void + public function setUsername(string $username): void { $this->username = $username; } @@ -274,7 +285,7 @@ public function getUsername(): ?string return $this->username; } - public function setPassword($password): void + public function setPassword(string $password): void { $this->password = $password; } @@ -284,12 +295,18 @@ public function getPassword(): ?string return $this->password; } + /** + * @param DateTimeInterface|string $createdAt + */ public function setCreatedAt($createdAt): void { $this->createdAt = $createdAt; } - public function getCreatedAt(): DateTime + /** + * @return DateTime|DateTimeInterface|string + */ + public function getCreatedAt() { return $this->createdAt; } @@ -429,7 +446,10 @@ public function getUniqueGroups(): Collection return $this->uniqueGroups; } - public function setUniqueGroups($groups): void + /** + * @param Collection $groups + */ + public function setUniqueGroups(Collection $groups): void { $this->uniqueGroups = $groups; } @@ -444,7 +464,7 @@ public function getHits(): int return $this->hits; } - public function setHits($hits): void + public function setHits(int $hits): void { $this->hits = $hits; } @@ -454,7 +474,7 @@ public function getCount(): ?int return $this->count; } - public function setCount($count): void + public function setCount(?int $count): void { $this->count = $count; } @@ -464,7 +484,7 @@ public function getFloatCount(): ?float return $this->floatCount; } - public function setFloatCount($floatCount): void + public function setFloatCount(?float $floatCount): void { $this->floatCount = $floatCount; } @@ -474,7 +494,7 @@ public function getDecimal128Count(): ?string return $this->decimal128Count; } - public function setDecimal128Count($decimal128Count): void + public function setDecimal128Count(?string $decimal128Count): void { $this->decimal128Count = $decimal128Count; } diff --git a/tests/Documents/VersionedUser.php b/tests/Documents/VersionedUser.php index 72d3397fe5..35756b32ba 100644 --- a/tests/Documents/VersionedUser.php +++ b/tests/Documents/VersionedUser.php @@ -25,7 +25,7 @@ public function getVersion(): ?int return $this->version; } - public function setVersion($version): void + public function setVersion(int $version): void { $this->version = $version; }