Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use static data providers in preparation for PHPUnit 10 #160

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/Generator/EnumGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testGenerateValidEnums(array $options, string $expected): void
* 1: non-empty-string
* }>
*/
public function validOptionSpecifications(): iterable
public static function validOptionSpecifications(): iterable
{
yield 'pure enum without namespace' => [
[
Expand Down Expand Up @@ -155,7 +155,7 @@ public function testReflectionEnumWorks(string $enumClass, string $expected): vo
* 1: non-empty-string
* }>
*/
public function validEnumSpecifications(): iterable
public static function validEnumSpecifications(): iterable
{
yield 'pure enum reflection' => [
'TestNamespace\\Environment',
Expand Down
6 changes: 3 additions & 3 deletions test/Generator/MethodGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function testCreateFromArrayWithReturnsReference($value, $expected): void
* bool
* }>
*/
public function returnsReferenceValues(): array
public static function returnsReferenceValues(): array
{
return [
[true, true],
Expand Down Expand Up @@ -432,7 +432,7 @@ public function testFrom($className, $methodName, $expectedReturnSignature)
* @return string[][]
* @psalm-return list<array{class-string, non-empty-string, non-empty-string}>
*/
public function returnTypeHintClasses()
public static function returnTypeHintClasses()
{
return [
[ReturnTypeHintedClass::class, 'voidReturn', 'void'],
Expand Down Expand Up @@ -523,7 +523,7 @@ public function testGeneratedReturnTypeForPhp80ReturnType(
/**
* @psalm-return non-empty-list<array{class-string, non-empty-string, non-empty-string, non-empty-string}>
*/
public function php80Methods(): array
public static function php80Methods(): array
{
return [
[Php80Types::class, 'mixedType', 'mixed', 'mixed'],
Expand Down
12 changes: 6 additions & 6 deletions test/Generator/ParameterGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function testFromReflectionGenerate($methodName, $expectedCode)
* @return string[][]
* @psalm-return non-empty-list<array{non-empty-string, non-empty-string}>
*/
public function dataFromReflectionGenerate(): array
public static function dataFromReflectionGenerate(): array
{
return [
['name', '$param'],
Expand Down Expand Up @@ -305,7 +305,7 @@ public function testGeneratesSimpleHints($type, $expectedType)
/**
* @return string[][]
*/
public function simpleHints()
public static function simpleHints()
{
return [
['callable', 'callable'],
Expand Down Expand Up @@ -347,7 +347,7 @@ public function testTypeHintWithValidClassName($className)
/**
* @return string[][]
*/
public function validClassName()
public static function validClassName()
{
return [
['stdClass'],
Expand Down Expand Up @@ -416,7 +416,7 @@ public function testTypeHintFromReflectionGeneratedCode($className, $methodName,
/**
* @return string[][]
*/
public function reflectionHints()
public static function reflectionHints()
{
$parameters = [
[InternalHintsClass::class, 'arrayParameter', 'foo', 'array'],
Expand Down Expand Up @@ -512,7 +512,7 @@ public function testVariadicArgumentFromReflection(
/**
* @return string[][]
*/
public function variadicHints()
public static function variadicHints()
{
return [
[VariadicParametersClass::class, 'firstVariadicParameter', 'foo', '... $foo'],
Expand Down Expand Up @@ -627,7 +627,7 @@ public function testGeneratedSignatureForPhp80ParameterType(
/**
* @psalm-return non-empty-list<array{class-string, non-empty-string, positive-int|0, string, non-empty-string}>
*/
public function php80Methods(): array
public static function php80Methods(): array
{
return [
[Php80Types::class, 'mixedType', 0, 'mixed', 'mixed $parameter'],
Expand Down
4 changes: 2 additions & 2 deletions test/Generator/PropertyGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testPropertyConstructor(): void
/**
* @return bool[][]|string[][]|int[][]|null[][]
*/
public function dataSetTypeSetValueGenerate(): array
public static function dataSetTypeSetValueGenerate(): array
{
return [
['string', 'foo', "'foo';"],
Expand Down Expand Up @@ -122,7 +122,7 @@ public function testPropertyMultilineValue(): void
self::assertSame($expectedSource, $targetSource);
}

public function visibility(): Generator
public static function visibility(): Generator
{
yield 'public' => [PropertyGenerator::FLAG_PUBLIC, 'public'];
yield 'protected' => [PropertyGenerator::FLAG_PROTECTED, 'protected'];
Expand Down
4 changes: 2 additions & 2 deletions test/Generator/TypeGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testRejectsInvalidTypeString($typeString)
* is that this library still supports generating code that is compatible with PHP 7,
* and therefore we cannot normalize nullable types to use `|null`, for now.
*/
public function validType()
public static function validType()
{
$valid = [
['\\foo', '\\foo'],
Expand Down Expand Up @@ -249,7 +249,7 @@ public function validClassName()
/**
* @return string[][]
*/
public function invalidType()
public static function invalidType()
{
$invalid = [
[''],
Expand Down
26 changes: 13 additions & 13 deletions test/Generator/ValueGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testAllowedPossibleConstantsType($constants): void
* @return object[][]
* @psalm-return array<class-string, array{SplArrayObject|StdlibArrayObject}>
*/
public function constantsType(): array
public static function constantsType(): array
{
return [
SplArrayObject::class => [new SplArrayObject()],
Expand All @@ -84,7 +84,7 @@ public function testValidConstantTypes(PropertyValueGenerator $generator, $expec
* @return array
* @psalm-return non-empty-list<array{PropertyValueGenerator, non-empty-string}>
*/
public function validConstantTypes(): array
public static function validConstantTypes(): array
{
return [
[
Expand Down Expand Up @@ -127,7 +127,7 @@ public function validConstantTypes(): array
* @param array $value
* @return array
*/
protected function generateArrayData($longOutput, array $value)
protected static function generateArrayData($longOutput, array $value)
{
$shortOutput = str_replace(
['array(', ')'],
Expand Down Expand Up @@ -164,7 +164,7 @@ protected function generateArrayData($longOutput, array $value)
*
* @return array
*/
public function simpleArray()
public static function simpleArray()
{
$value = ['foo'];

Expand All @@ -174,15 +174,15 @@ public function simpleArray()
)
EOS;

return $this->generateArrayData($longOutput, $value);
return self::generateArrayData($longOutput, $value);
}

/**
* Data provider for testPropertyDefaultValueCanHandleComplexArrayOfTypes test
*
* @return array
*/
public function complexArray()
public static function complexArray()
{
$value = [
5,
Expand Down Expand Up @@ -222,13 +222,13 @@ public function complexArray()
)
EOS;

return $this->generateArrayData($longOutput, $value);
return self::generateArrayData($longOutput, $value);
}

/**
* Data provider for testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes test
*/
public function complexArrayWCustomIndent(): array
public static function complexArrayWCustomIndent(): array
{
$value = [
'5bcf08a0a5d20' => [
Expand Down Expand Up @@ -302,15 +302,15 @@ public function complexArrayWCustomIndent(): array
)
EOS;

return $this->generateArrayData($longOutput, $value);
return self::generateArrayData($longOutput, $value);
}

/**
* Data provider for testPropertyDefaultValueCanHandleArrayWithUnsortedKeys test
*
* @return array
*/
public function unsortedKeysArray()
public static function unsortedKeysArray()
{
$value = [
1 => 'a',
Expand All @@ -330,7 +330,7 @@ public function unsortedKeysArray()
)
EOS;

return $this->generateArrayData($longOutput, $value);
return self::generateArrayData($longOutput, $value);
}

/**
Expand Down Expand Up @@ -467,7 +467,7 @@ public function testEscaping($input, $expectedEscapedValue)
*
* @return string[][]
*/
public function getEscapedParameters()
public static function getEscapedParameters()
{
return [
['\\', '\\\\'],
Expand All @@ -476,7 +476,7 @@ public function getEscapedParameters()
];
}

public function invalidValue(): Generator
public static function invalidValue(): Generator
{
yield 'object' => [new DateTime(), DateTime::class];
yield 'resource' => [fopen('php://input', 'r'), 'resource (stream)'];
Expand Down
2 changes: 1 addition & 1 deletion test/Reflection/DocBlock/Tag/VarTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testParse(
$this->assertSame($expectedDescription, $tag->getDescription());
}

public function varTagProvider(): array
public static function varTagProvider(): array
{
return [
'only type' => [
Expand Down
8 changes: 4 additions & 4 deletions test/Reflection/ParameterReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testCallableTypeHint()
* @return string[][]
* @psalm-return non-empty-list<array{non-empty-string, non-empty-string}>
*/
public function paramType(): array
public static function paramType(): array
{
return [
['one', 'int'],
Expand All @@ -101,7 +101,7 @@ public function paramType(): array
* @return string[][]
* @psalm-return non-empty-list<array{non-empty-string, non-empty-string}>
*/
public function paramTypeWithNotAllParamsDeclared(): array
public static function paramTypeWithNotAllParamsDeclared(): array
{
return [
['one', 'string'],
Expand Down Expand Up @@ -159,7 +159,7 @@ public function testDetectType($className, $methodName, $parameterName, $expecte
/**
* @return string[][]
*/
public function reflectionHints()
public static function reflectionHints()
{
return [
[InternalHintsClass::class, 'arrayParameter', 'foo', 'array'],
Expand Down Expand Up @@ -214,7 +214,7 @@ public function testDetectTypeWithDocBlockOnlyTypes($className, $methodName, $pa
/**
* @return string[][]
*/
public function docBlockHints()
public static function docBlockHints()
{
return [
[DocBlockOnlyHintsClass::class, 'arrayParameter', 'foo', 'array'],
Expand Down
2 changes: 1 addition & 1 deletion test/Reflection/ReflectionDocBlockTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function testPropertyVarDoc(
self::assertSame($expectedDescription, $varTag->getDescription());
}

public function propertyVarDocProvider(): array
public static function propertyVarDocProvider(): array
{
return [
'only type' => ['onlyType', ['string'], null, null],
Expand Down