Skip to content

Commit 3843d7e

Browse files
authored
Make all data providers static (#10493)
1 parent d50ba2e commit 3843d7e

33 files changed

+74
-76
lines changed

tests/Doctrine/Tests/ORM/AbstractQueryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testCallingSettersWithoutArgumentsIsDeprecated(string $setter):
8383
}
8484

8585
/** @return array<string, array{string}> */
86-
public function provideSettersWithDeprecatedDefault(): array
86+
public static function provideSettersWithDeprecatedDefault(): array
8787
{
8888
return [
8989
'setHydrationCacheProfile' => ['setHydrationCacheProfile'],

tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp(): void
4646
}
4747

4848
/** @psalm-return Generator<string, mixed[]> */
49-
public function getMethodParameters(): Generator
49+
public static function getMethodParameters(): Generator
5050
{
5151
$class = new ReflectionClass(EntityManagerInterface::class);
5252

@@ -55,12 +55,12 @@ public function getMethodParameters(): Generator
5555
continue;
5656
}
5757

58-
yield $method->getName() => $this->getParameters($method);
58+
yield $method->getName() => self::getParameters($method);
5959
}
6060
}
6161

6262
/** @return mixed[] */
63-
private function getParameters(ReflectionMethod $method): array
63+
private static function getParameters(ReflectionMethod $method): array
6464
{
6565
/** Special case EntityManager::createNativeQuery() */
6666
if ($method->getName() === 'createNativeQuery') {

tests/Doctrine/Tests/ORM/EntityManagerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function testAffectedByErrorIfClosedException(string $methodName): void
198198
}
199199

200200
/** @return Generator<array{mixed}> */
201-
public function dataToBeReturnedByWrapInTransaction(): Generator
201+
public static function dataToBeReturnedByWrapInTransaction(): Generator
202202
{
203203
yield [[]];
204204
yield [[1]];

tests/Doctrine/Tests/ORM/Functional/EnumTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public function testEnumWithNonMatchingDatabaseValueThrowsException(string $card
384384
}
385385

386386
/** @return array<string, array{class-string}> */
387-
public function provideCardClasses(): array
387+
public static function provideCardClasses(): array
388388
{
389389
return [
390390
Card::class => [Card::class],

tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp(): void
3333
}
3434

3535
/** @psalm-return list<array{int}> */
36-
public function provideDataForHydrationMode(): array
36+
public static function provideDataForHydrationMode(): array
3737
{
3838
return [
3939
[Query::HYDRATE_ARRAY],

tests/Doctrine/Tests/ORM/Functional/PaginationTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -736,17 +736,17 @@ public function populate(): void
736736
$this->_em->flush();
737737
}
738738

739-
/** @psalm-return list<array{bool, bool}> */
740-
public function useOutputWalkers(): array
739+
/** @psalm-return list<array{bool}> */
740+
public static function useOutputWalkers(): array
741741
{
742742
return [
743743
[true],
744744
[false],
745745
];
746746
}
747747

748-
/** @psalm-return list<array{bool, bool}> */
749-
public function fetchJoinCollection(): array
748+
/** @psalm-return list<array{bool}> */
749+
public static function fetchJoinCollection(): array
750750
{
751751
return [
752752
[true],
@@ -755,7 +755,7 @@ public function fetchJoinCollection(): array
755755
}
756756

757757
/** @psalm-return list<array{bool, bool}> */
758-
public function useOutputWalkersAndFetchJoinCollection(): array
758+
public static function useOutputWalkersAndFetchJoinCollection(): array
759759
{
760760
return [
761761
[true, false],

tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public function testDateSub(string $unit, int $amount, int $delta = 0): void
364364
);
365365
}
366366

367-
public function dateAddSubProvider(): array
367+
public static function dateAddSubProvider(): array
368368
{
369369
$secondsInDay = 86400;
370370

tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testPersistenceOfEntityWithSchemaMapping(string $className): voi
7777
*
7878
* @return string[][]
7979
*/
80-
public function getTestedClasses(): array
80+
public static function getTestedClasses(): array
8181
{
8282
return [
8383
[ExplicitSchemaAndTable::class, 'explicit_schema', 'explicit_table'],

tests/Doctrine/Tests/ORM/Functional/Ticket/GH10387Test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testSchemaToolCreatesColumnForFieldInTheMiddleClass(array $class
3232
self::assertNotNull($schema->getTable('root')->getColumn('leaf_class_field'));
3333
}
3434

35-
public function classHierachies(): Generator
35+
public static function classHierachies(): Generator
3636
{
3737
yield 'hierarchy with Entity classes only' => [[GH10387EntitiesOnlyRoot::class, GH10387EntitiesOnlyMiddle::class, GH10387EntitiesOnlyLeaf::class]];
3838
yield 'MappedSuperclass in the middle of the hierarchy' => [[GH10387MappedSuperclassRoot::class, GH10387MappedSuperclassMiddle::class, GH10387MappedSuperclassLeaf::class]];

tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testUpdateSchemaSql(): void
7575
}
7676

7777
/** @return array<array<string|callable|null>> */
78-
public function provideUpdateSchemaSqlWithSchemaAssetFilter(): array
78+
public static function provideUpdateSchemaSqlWithSchemaAssetFilter(): array
7979
{
8080
return [
8181
['/^(?!my_enti)/', null],

tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testLoadFieldsFromAllClassesInHierarchy(string $queryClass): voi
4141
self::assertSame('leaf', $loadedEntity->leaf);
4242
}
4343

44-
public function queryClasses(): array
44+
public static function queryClasses(): array
4545
{
4646
return [
4747
'query via root entity' => [GH8127Root::class],

tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function tearDown(): void
3737
/**
3838
* This does not work before the fix in PR#9663, but is does work after the fix is applied
3939
*/
40-
public function failingValuesBeforeFix(): array
40+
public static function failingValuesBeforeFix(): array
4141
{
4242
return [
4343
'string=""' => ['name', '', 'test name'],
@@ -66,7 +66,7 @@ public function failingValuesBeforeFix(): array
6666
/**
6767
* This already works before the fix in PR#9663 is applied because none of these are falsy values in php
6868
*/
69-
public function succeedingValuesBeforeFix(): array
69+
public static function succeedingValuesBeforeFix(): array
7070
{
7171
return [
7272
'string="test"' => ['name', 'test', 'test2'],

tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public function testThrowsExceptionOnInfiniteEmbeddableNesting(
345345
}
346346

347347
/** @psalm-return list<array{string, string}> */
348-
public function getInfiniteEmbeddableNestingData(): array
348+
public static function getInfiniteEmbeddableNestingData(): array
349349
{
350350
return [
351351
['DDCInfiniteNestingEmbeddable', 'DDCInfiniteNestingEmbeddable'],

tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class ArrayHydratorTest extends HydrationTestCase
1818
{
1919
/** @psalm-return list<array{mixed}> */
20-
public function provideDataForUserEntityResult(): array
20+
public static function provideDataForUserEntityResult(): array
2121
{
2222
return [
2323
[0],

tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ObjectHydratorTest extends HydrationTestCase
3535
use MockBuilderCompatibilityTools;
3636

3737
/** @psalm-return list<array{mixed}> */
38-
public function provideDataForUserEntityResult(): array
38+
public static function provideDataForUserEntityResult(): array
3939
{
4040
return [
4141
[0],
@@ -44,7 +44,7 @@ public function provideDataForUserEntityResult(): array
4444
}
4545

4646
/** @psalm-return list<array{mixed, mixed}> */
47-
public function provideDataForMultipleRootEntityResult(): array
47+
public static function provideDataForMultipleRootEntityResult(): array
4848
{
4949
return [
5050
[0, 0],
@@ -55,7 +55,7 @@ public function provideDataForMultipleRootEntityResult(): array
5555
}
5656

5757
/** @psalm-return list<array{mixed}> */
58-
public function provideDataForProductEntityResult(): array
58+
public static function provideDataForProductEntityResult(): array
5959
{
6060
return [
6161
[0],

tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testThrowsExceptionIfIdNotAssigned($entity): void
3737
$this->assignedGen->generateId($this->entityManager, $entity);
3838
}
3939

40-
public function entitiesWithoutId(): array
40+
public static function entitiesWithoutId(): array
4141
{
4242
return [
4343
'single' => [new AssignedSingleIdEntity()],

tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners(): voi
154154
}
155155

156156
/** @psalm-return list<array{int}> */
157-
public function invocationFlagProvider(): array
157+
public static function invocationFlagProvider(): array
158158
{
159159
return [
160160
[ListenersInvoker::INVOKE_LISTENERS],

tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function testLengthForDiscriminatorColumn(string $class, int $expectedLen
276276
self::assertSame($expectedLength, $metadata->discriminatorColumn['length']);
277277
}
278278

279-
public function provideDiscriminatorColumnTestcases(): Generator
279+
public static function provideDiscriminatorColumnTestcases(): Generator
280280
{
281281
yield [DiscriminatorColumnWithNullLength::class, 255];
282282
yield [DiscriminatorColumnWithNoLength::class, 255];

tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php

+14-16
Original file line numberDiff line numberDiff line change
@@ -69,49 +69,47 @@ public function testWillSkipReadingPropertiesFromNullEmbeddable(
6969
}
7070

7171
/**
72-
* Data provider
73-
*
7472
* @return ReflectionProperty[][]|string[][]
7573
*/
76-
public function getTestedReflectionProperties(): array
74+
public static function getTestedReflectionProperties(): array
7775
{
7876
return [
7977
[
80-
$this->getReflectionProperty(BooleanModel::class, 'id'),
81-
$this->getReflectionProperty(BooleanModel::class, 'id'),
78+
self::getReflectionProperty(BooleanModel::class, 'id'),
79+
self::getReflectionProperty(BooleanModel::class, 'id'),
8280
BooleanModel::class,
8381
],
8482
// reflection on embeddables that have properties defined in abstract ancestors:
8583
[
86-
$this->getReflectionProperty(BooleanModel::class, 'id'),
87-
$this->getReflectionProperty(AbstractEmbeddable::class, 'propertyInAbstractClass'),
84+
self::getReflectionProperty(BooleanModel::class, 'id'),
85+
self::getReflectionProperty(AbstractEmbeddable::class, 'propertyInAbstractClass'),
8886
ConcreteEmbeddable::class,
8987
],
9088
[
91-
$this->getReflectionProperty(BooleanModel::class, 'id'),
92-
$this->getReflectionProperty(ConcreteEmbeddable::class, 'propertyInConcreteClass'),
89+
self::getReflectionProperty(BooleanModel::class, 'id'),
90+
self::getReflectionProperty(ConcreteEmbeddable::class, 'propertyInConcreteClass'),
9391
ConcreteEmbeddable::class,
9492
],
9593
// reflection on classes extending internal PHP classes:
9694
[
97-
$this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
98-
$this->getReflectionProperty(ArrayObjectExtendingClass::class, 'privateProperty'),
95+
self::getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
96+
self::getReflectionProperty(ArrayObjectExtendingClass::class, 'privateProperty'),
9997
ArrayObjectExtendingClass::class,
10098
],
10199
[
102-
$this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
103-
$this->getReflectionProperty(ArrayObjectExtendingClass::class, 'protectedProperty'),
100+
self::getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
101+
self::getReflectionProperty(ArrayObjectExtendingClass::class, 'protectedProperty'),
104102
ArrayObjectExtendingClass::class,
105103
],
106104
[
107-
$this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
108-
$this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
105+
self::getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
106+
self::getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'),
109107
ArrayObjectExtendingClass::class,
110108
],
111109
];
112110
}
113111

114-
private function getReflectionProperty(string $className, string $propertyName): ReflectionProperty
112+
private static function getReflectionProperty(string $className, string $propertyName): ReflectionProperty
115113
{
116114
$reflectionProperty = new ReflectionProperty($className, $propertyName);
117115

tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
use Doctrine\ORM\ORMInvalidArgumentException;
88
use PHPUnit\Framework\TestCase;
99
use stdClass;
10-
use Stringable;
1110

1211
use function spl_object_id;
13-
use function uniqid;
1412

1513
/** @covers \Doctrine\ORM\ORMInvalidArgumentException */
1614
class ORMInvalidArgumentExceptionTest extends TestCase
@@ -29,7 +27,7 @@ public function testInvalidEntityName($value, string $expectedMessage): void
2927
}
3028

3129
/** @psalm-return list<array{mixed, string}> */
32-
public function invalidEntityNames(): array
30+
public static function invalidEntityNames(): array
3331
{
3432
return [
3533
[null, 'Entity name must be a string, null given'],
@@ -49,30 +47,32 @@ public function testNewEntitiesFoundThroughRelationships(array $newEntities, str
4947
self::assertSame($expectedMessage, $exception->getMessage());
5048
}
5149

52-
public function newEntitiesFoundThroughRelationshipsErrorMessages(): array
50+
public static function newEntitiesFoundThroughRelationshipsErrorMessages(): array
5351
{
54-
$stringEntity3 = uniqid('entity3', true);
55-
$entity1 = new stdClass();
56-
$entity2 = new stdClass();
57-
$entity3 = $this->createMock(Stringable::class);
58-
$association1 = [
52+
$entity1 = new stdClass();
53+
$entity2 = new stdClass();
54+
$entity3 = new class {
55+
public function __toString(): string
56+
{
57+
return 'ThisIsAStringRepresentationOfEntity3';
58+
}
59+
};
60+
$association1 = [
5961
'sourceEntity' => 'foo1',
6062
'fieldName' => 'bar1',
6163
'targetEntity' => 'baz1',
6264
];
63-
$association2 = [
65+
$association2 = [
6466
'sourceEntity' => 'foo2',
6567
'fieldName' => 'bar2',
6668
'targetEntity' => 'baz2',
6769
];
68-
$association3 = [
70+
$association3 = [
6971
'sourceEntity' => 'foo3',
7072
'fieldName' => 'bar3',
7173
'targetEntity' => 'baz3',
7274
];
7375

74-
$entity3->method('__toString')->willReturn($stringEntity3);
75-
7676
return [
7777
'one entity found' => [
7878
[
@@ -121,7 +121,7 @@ public function newEntitiesFoundThroughRelationshipsErrorMessages(): array
121121
],
122122
],
123123
'A new entity was found through the relationship \'foo3#bar3\' that was not configured to cascade '
124-
. 'persist operations for entity: ' . $stringEntity3
124+
. 'persist operations for entity: ThisIsAStringRepresentationOfEntity3'
125125
. '. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity '
126126
. 'or configure cascade persist this association in the mapping for example '
127127
. '@ManyToOne(..,cascade={"persist"}).',

tests/Doctrine/Tests/ORM/Query/ExprTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function testIsMemberOfExpr(): void
278278
self::assertEquals(':groupId MEMBER OF u.groups', (string) $this->expr->isMemberOf(':groupId', 'u.groups'));
279279
}
280280

281-
public function provideIterableValue(): Generator
281+
public static function provideIterableValue(): Generator
282282
{
283283
$gen = static function () {
284284
yield from [1, 2, 3];
@@ -288,7 +288,7 @@ public function provideIterableValue(): Generator
288288
yield 'generator' => [$gen()];
289289
}
290290

291-
public function provideLiteralIterableValue(): Generator
291+
public static function provideLiteralIterableValue(): Generator
292292
{
293293
$gen = static function () {
294294
yield from ['foo', 'bar'];

tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testRejectsInvalidDQL(string $dql): void
8888
}
8989

9090
/** @psalm-return list<array{string}> */
91-
public function invalidDQL(): array
91+
public static function invalidDQL(): array
9292
{
9393
return [
9494

tests/Doctrine/Tests/ORM/Query/LexerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function testScannerTokenizesASimpleQueryCorrectly(): void
226226
}
227227

228228
/** @psalm-return list<array{int, string}> */
229-
public function provideTokens(): array
229+
public static function provideTokens(): array
230230
{
231231
return [
232232
[Lexer::T_IDENTIFIER, 'u'], // one char

0 commit comments

Comments
 (0)