Skip to content

Commit

Permalink
Migrate to static data providers using rector/rector
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored and nicolas-grekas committed Feb 14, 2023
1 parent 9a44c26 commit 38ceb9e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/PropertyInfoPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testServicesAreOrderedAccordingToPriority($index, $tag)
$this->assertEquals($expected, $definition->getArgument($index));
}

public function provideTags()
public static function provideTags()
{
return [
[0, 'property_info.list_extractor'],
Expand Down
24 changes: 12 additions & 12 deletions Tests/Extractor/PhpStanExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testParamTagTypeIsOmitted()
$this->assertNull($this->extractor->getTypes(PhpStanOmittedParamTagTypeDocBlock::class, 'omittedType'));
}

public function invalidTypesProvider()
public static function invalidTypesProvider()
{
return [
'pub' => ['pub'],
Expand Down Expand Up @@ -86,7 +86,7 @@ public function testExtractTypesWithNoPrefixes($property, array $type = null)
$this->assertEquals($type, $noPrefixExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}

public function typesProvider()
public static function typesProvider()
{
return [
['foo', null],
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testExtractCollection($property, array $type = null)
$this->testExtract($property, $type);
}

public function provideCollectionTypes()
public static function provideCollectionTypes()
{
return [
['iteratorCollection', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Iterator', true, null, new Type(Type::BUILTIN_TYPE_STRING))]],
Expand Down Expand Up @@ -197,7 +197,7 @@ public function testExtractTypesWithCustomPrefixes($property, array $type = null
$this->assertEquals($type, $customExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}

public function typesWithCustomPrefixesProvider()
public static function typesWithCustomPrefixesProvider()
{
return [
['foo', null],
Expand Down Expand Up @@ -235,7 +235,7 @@ public function typesWithCustomPrefixesProvider()
];
}

public function typesWithNoPrefixesProvider()
public static function typesWithNoPrefixesProvider()
{
return [
['foo', null],
Expand Down Expand Up @@ -273,7 +273,7 @@ public function typesWithNoPrefixesProvider()
];
}

public function dockBlockFallbackTypesProvider()
public static function dockBlockFallbackTypesProvider()
{
return [
'pub' => [
Expand Down Expand Up @@ -304,7 +304,7 @@ public function testPropertiesDefinedByTraits(string $property, Type $type)
$this->assertEquals([$type], $this->extractor->getTypes(DummyUsingTrait::class, $property));
}

public function propertiesDefinedByTraitsProvider(): array
public static function propertiesDefinedByTraitsProvider(): array
{
return [
['propertyInTraitPrimitiveType', new Type(Type::BUILTIN_TYPE_STRING)],
Expand All @@ -321,7 +321,7 @@ public function testPropertiesStaticType(string $class, string $property, Type $
$this->assertEquals([$type], $this->extractor->getTypes($class, $property));
}

public function propertiesStaticTypeProvider(): array
public static function propertiesStaticTypeProvider(): array
{
return [
[ParentDummy::class, 'propertyTypeStatic', new Type(Type::BUILTIN_TYPE_OBJECT, false, ParentDummy::class)],
Expand All @@ -337,7 +337,7 @@ public function testPropertiesParentType(string $class, string $property, ?array
$this->assertEquals($types, $this->extractor->getTypes($class, $property));
}

public function propertiesParentTypeProvider(): array
public static function propertiesParentTypeProvider(): array
{
return [
[ParentDummy::class, 'parentAnnotationNoParent', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'parent')]],
Expand All @@ -353,7 +353,7 @@ public function testExtractConstructorTypes($property, array $type = null)
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
}

public function constructorTypesProvider()
public static function constructorTypesProvider()
{
return [
['date', [new Type(Type::BUILTIN_TYPE_INT)]],
Expand All @@ -372,7 +372,7 @@ public function testExtractorUnionTypes(string $property, ?array $types)
$this->assertEquals($types, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DummyUnionType', $property));
}

public function unionTypesProvider(): array
public static function unionTypesProvider(): array
{
return [
['a', [new Type(Type::BUILTIN_TYPE_STRING), new Type(Type::BUILTIN_TYPE_INT)]],
Expand Down Expand Up @@ -410,7 +410,7 @@ public function testExtractorIntRangeType(string $property, ?array $types)
$this->assertEquals($types, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\IntRangeDummy', $property));
}

public function intRangeTypeProvider(): array
public static function intRangeTypeProvider(): array
{
return [
['a', [new Type(Type::BUILTIN_TYPE_INT)]],
Expand Down
28 changes: 14 additions & 14 deletions Tests/Extractor/ReflectionExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function testExtractors($property, array $type = null)
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property, []));
}

public function typesProvider()
public static function typesProvider()
{
return [
['a', null],
Expand All @@ -234,7 +234,7 @@ public function testExtractPhp7Type(string $class, string $property, array $type
$this->assertEquals($type, $this->extractor->getTypes($class, $property, []));
}

public function php7TypesProvider()
public static function php7TypesProvider()
{
return [
[Php7Dummy::class, 'foo', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)]],
Expand All @@ -255,7 +255,7 @@ public function testExtractPhp71Type($property, array $type = null)
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php71Dummy', $property, []));
}

public function php71TypesProvider()
public static function php71TypesProvider()
{
return [
['foo', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]],
Expand All @@ -276,7 +276,7 @@ public function testExtractPhp80Type($property, array $type = null)
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php80Dummy', $property, []));
}

public function php80TypesProvider()
public static function php80TypesProvider()
{
return [
['foo', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]],
Expand All @@ -300,7 +300,7 @@ public function testExtractPhp81Type($property, array $type = null)
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php81Dummy', $property, []));
}

public function php81TypesProvider()
public static function php81TypesProvider()
{
return [
['nothing', null],
Expand All @@ -326,7 +326,7 @@ public function testExtractPhp82Type($property, array $type = null)
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php82Dummy', $property, []));
}

public function php82TypesProvider(): iterable
public static function php82TypesProvider(): iterable
{
yield ['nil', null];
yield ['false', [new Type(Type::BUILTIN_TYPE_FALSE)]];
Expand All @@ -344,7 +344,7 @@ public function testExtractWithDefaultValue($property, $type)
$this->assertEquals($type, $this->extractor->getTypes(DefaultValue::class, $property, []));
}

public function defaultValueProvider()
public static function defaultValueProvider()
{
return [
['defaultInt', [new Type(Type::BUILTIN_TYPE_INT, false)]],
Expand All @@ -366,7 +366,7 @@ public function testIsReadable($property, $expected)
);
}

public function getReadableProperties()
public static function getReadableProperties()
{
return [
['bar', false],
Expand Down Expand Up @@ -397,7 +397,7 @@ public function testIsWritable($property, $expected)
);
}

public function getWritableProperties()
public static function getWritableProperties()
{
return [
['bar', false],
Expand Down Expand Up @@ -451,7 +451,7 @@ public function testIsInitializable(string $class, string $property, bool $expec
$this->assertSame($expected, $this->extractor->isInitializable($class, $property));
}

public function getInitializableProperties(): array
public static function getInitializableProperties(): array
{
return [
[Php71Dummy::class, 'string', true],
Expand All @@ -475,7 +475,7 @@ public function testExtractTypeConstructor(string $class, string $property, arra
$this->assertNull($this->extractor->getTypes($class, $property, ['enable_constructor_extraction' => false]));
}

public function constructorTypesProvider(): array
public static function constructorTypesProvider(): array
{
return [
// php71 dummy has following constructor: __construct(string $string, int $intPrivate)
Expand Down Expand Up @@ -534,7 +534,7 @@ public function testGetReadAccessor($class, $property, $found, $type, $name, $vi
$this->assertSame($static, $readAcessor->isStatic());
}

public function readAccessorProvider(): array
public static function readAccessorProvider(): array
{
return [
[Dummy::class, 'bar', true, PropertyReadInfo::TYPE_PROPERTY, 'bar', PropertyReadInfo::VISIBILITY_PRIVATE, false],
Expand Down Expand Up @@ -592,7 +592,7 @@ public function testGetWriteMutator($class, $property, $allowConstruct, $found,
}
}

public function writeMutatorProvider(): array
public static function writeMutatorProvider(): array
{
return [
[Dummy::class, 'bar', false, true, PropertyWriteInfo::TYPE_PROPERTY, 'bar', null, null, PropertyWriteInfo::VISIBILITY_PRIVATE, false],
Expand Down Expand Up @@ -650,7 +650,7 @@ public function testExtractConstructorTypes(string $property, array $type = null
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
}

public function extractConstructorTypesProvider(): array
public static function extractConstructorTypesProvider(): array
{
return [
['timezone', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeZone')]],
Expand Down

0 comments on commit 38ceb9e

Please sign in to comment.