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

Change PHPUint dataProviders methods to be static #1564

Merged
merged 1 commit into from
Mar 26, 2024
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
2 changes: 1 addition & 1 deletion tests/Analysers/ReflectionAnalyserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testTraitInheritance(): void
$this->assertEquals($expected, array_keys($annotationFactory->reflectors));
}

public function analysers(): iterable
public static function analysers(): iterable
{
return [
'docblocks-attributes' => [new ReflectionAnalyser([new DocBlockAnnotationFactory(), new AttributeAnnotationFactory()])],
Expand Down
11 changes: 4 additions & 7 deletions tests/Analysers/TokenAnalyserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function analysisFromCode(string $code): Analysis
return $analyser->fromCode('<?php ' . $code, $this->getContext());
}

public function singleDefinitionCases(): iterable
public static function singleDefinitionCases(): iterable
{
return [
'global-class' => ['class AClass {}', '\AClass', 'AClass', 'classes', 'class'],
Expand Down Expand Up @@ -53,7 +53,7 @@ public function testSingleDefinition(string $code, string $fqdn, string $name, s
$this->assertSame([], $definition['methods']);
}

public function extendsDefinitionCases(): iterable
public static function extendsDefinitionCases(): iterable
{
return [
'global-class' => ['class BClass extends Other {}', '\BClass', 'BClass', '\Other', 'classes', 'class'],
Expand Down Expand Up @@ -91,7 +91,7 @@ public function testExtendsDefinition(string $code, string $fqdn, string $name,
$this->assertSame($extends, $definition['extends']);
}

public function usesDefinitionCases(): iterable
public static function usesDefinitionCases(): iterable
{
return [
'global-class-use' => ['class YClass { use Other; }', '\YClass', 'YClass', ['\Other'], 'classes', 'class'],
Expand Down Expand Up @@ -167,10 +167,7 @@ public function testAnonymousClassProducesNoError(): void
}
}

/**
* dataprovider.
*/
public function descriptions(): iterable
public static function descriptions(): iterable
{
return [
'class' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Analysers/TokenScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class TokenScannerTest extends OpenApiTestCase
{
public function scanCases(): iterable
public static function scanCases(): iterable
{
if (\PHP_VERSION_ID >= 80100) {
yield 'abstract' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Annotations/AbstractAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function testTypeValidation(): void
$parameter->validate();
}

public function nestedMatches(): iterable
public static function nestedMatches(): iterable
{
$parameterMatch = (object) ['key' => OA\Parameter::class, 'value' => ['parameters']];

Expand Down
2 changes: 1 addition & 1 deletion tests/Annotations/OperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class OperationTest extends OpenApiTestCase
{
public function securityData(): iterable
public static function securityData(): iterable
{
return [
'empty' => [
Expand Down
6 changes: 3 additions & 3 deletions tests/ExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class ExamplesTest extends OpenApiTestCase
{
public function exampleDetails(): iterable
public static function exampleDetails(): iterable
{
yield 'example-object' => [
'version' => OA\OpenApi::VERSION_3_0_0,
Expand Down Expand Up @@ -185,14 +185,14 @@ public function exampleDetails(): iterable
}
}

public function exampleMappings(): iterable
public static function exampleMappings(): iterable
{
$analysers = [
'token' => new TokenAnalyser(),
'reflection' => new ReflectionAnalyser([new DocBlockAnnotationFactory(), new AttributeAnnotationFactory()]),
];

foreach ($this->exampleDetails() as $exampleKey => $example) {
foreach (static::exampleDetails() as $exampleKey => $example) {
$exampleAnalysers = $example['analysers'];
unset($example['analysers']);
foreach ($exampleAnalysers as $analyserKey) {
Expand Down
8 changes: 4 additions & 4 deletions tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class GeneratorTest extends OpenApiTestCase
{
public function sourcesProvider(): iterable
public static function sourcesProvider(): iterable
{
$sourceDir = $this->example('swagger-spec/petstore-simple');
$sourceDir = static::example('swagger-spec/petstore-simple');

yield 'dir-list' => [$sourceDir, [$sourceDir]];
yield 'file-list' => [$sourceDir, ["$sourceDir/SimplePet.php", "$sourceDir/SimplePetsController.php", "$sourceDir/OpenApiSpec.php"]];
Expand Down Expand Up @@ -46,7 +46,7 @@ public function testScanInvalidSource(): void
->generate(['/tmp/__swagger_php_does_not_exist__']);
}

public function processorCases(): iterable
public static function processorCases(): iterable
{
return [
[new OperationId(), true],
Expand Down Expand Up @@ -124,7 +124,7 @@ protected function assertOperationIdHash(Generator $generator, bool $expected):
}
}

public function configCases(): iterable
public static function configCases(): iterable
{
return [
'default' => [[], true],
Expand Down
14 changes: 7 additions & 7 deletions tests/OpenApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ protected function createOpenApiWithInfo(): OA\OpenApi
]);
}

public function example(string $name): string
public static function example(string $name): string
{
return __DIR__ . '/../Examples/' . $name;
}

public function fixture(string $file): ?string
public static function fixture(string $file): ?string
{
$fixtures = $this->fixtures([$file]);
$fixtures = static::fixtures([$file]);

return $fixtures ? $fixtures[0] : null;
}
Expand All @@ -219,14 +219,14 @@ public function fixture(string $file): ?string
*
* @return array resolved filenames for loading scanning etc
*/
public function fixtures(array $files): array
public static function fixtures(array $files): array
{
return array_map(function ($file) {
return __DIR__ . '/Fixtures/' . $file;
}, $files);
}

public function processors(array $strip = [], array $add = []): array
public static function processors(array $strip = [], array $add = []): array
{
$processors = (new Generator())->getProcessors();

Expand Down Expand Up @@ -264,7 +264,7 @@ protected function annotationsFromDocBlockParser(string $docBlock, array $extraA
/**
* Collect list of all non-abstract annotation classes.
*/
public function allAnnotationClasses(): array
public static function allAnnotationClasses(): array
{
$classes = [];
$dir = new \DirectoryIterator(__DIR__ . '/../src/Annotations');
Expand All @@ -285,7 +285,7 @@ public function allAnnotationClasses(): array
/**
* Collect list of all non-abstract attribute classes.
*/
public function allAttributeClasses(): array
public static function allAttributeClasses(): array
{
$classes = [];
$dir = new \DirectoryIterator(__DIR__ . '/../src/Attributes');
Expand Down
2 changes: 1 addition & 1 deletion tests/Processors/AugmentParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testAugmentParameter(): void
$this->assertEquals('ItemName', $openapi->components->parameters[0]->parameter, 'When no @OA\Parameter()->parameter is specified, use @OA\Parameter()->name');
}

public function tagCases(): iterable
public static function tagCases(): iterable
{
yield 'complete' => [
'@param string $foo The foo parameter.',
Expand Down
4 changes: 2 additions & 2 deletions tests/Processors/CleanUnusedComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

class CleanUnusedComponentsTest extends OpenApiTestCase
{
public function countCases(): iterable
public static function countCases(): iterable
{
$defaultProcessors = $this->processors([CleanUnusedComponents::class]);
$defaultProcessors = static::processors([CleanUnusedComponents::class]);

return [
'var-default' => [$defaultProcessors, 'UsingVar.php', 2, 5],
Expand Down
2 changes: 1 addition & 1 deletion tests/Processors/ExpandEnumsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testExpandBackedStringEnum(): void
$this->assertEquals('string', $schema->type);
}

public function expandEnumClassStringFixtures(): iterable
public static function expandEnumClassStringFixtures(): iterable
{
if (!class_exists('\\ReflectionEnum')) {
// otherwise PHPUnit will run this for all PHP versions
Expand Down
10 changes: 5 additions & 5 deletions tests/ScratchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

class ScratchTest extends OpenApiTestCase
{
public function scratchTests(): iterable
public static function scratchTests(): iterable
{
foreach (glob($this->fixture('Scratch/*.php')) as $fixture) {
foreach (glob(static::fixture('Scratch/*.php')) as $fixture) {
$name = pathinfo($fixture, PATHINFO_FILENAME);

if (0 === strpos($name, 'Abstract')) {
continue;
}

$scratch = $this->fixture("Scratch/$name.php");
$scratch = static::fixture("Scratch/$name.php");
$specs = [
$this->fixture("Scratch/{$name}3.1.0.yaml") => OA\OpenApi::VERSION_3_1_0,
$this->fixture("Scratch/{$name}3.0.0.yaml") => OA\OpenApi::VERSION_3_0_0,
static::fixture("Scratch/{$name}3.1.0.yaml") => OA\OpenApi::VERSION_3_1_0,
static::fixture("Scratch/{$name}3.0.0.yaml") => OA\OpenApi::VERSION_3_0_0,
];

$expectedLogs = [
Expand Down
2 changes: 1 addition & 1 deletion tests/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testFinder(): void
$this->assertArrayNotHasKey($directory_path, $finder_result_array, 'The directory should not be a path in the finder.');
}

public function shortenFixtures(): iterable
public static function shortenFixtures(): iterable
{
return [
[[OA\Get::class], ['@OA\Get']],
Expand Down