Change PHPUint dataProviders methods to be static (#1564)
This commit is contained in:
parent
2357fafbb0
commit
a268913f2e
|
@ -72,7 +72,7 @@ class ReflectionAnalyserTest extends OpenApiTestCase
|
|||
$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()])],
|
||||
|
|
|
@ -25,7 +25,7 @@ class TokenAnalyserTest extends OpenApiTestCase
|
|||
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'],
|
||||
|
@ -53,7 +53,7 @@ class TokenAnalyserTest extends OpenApiTestCase
|
|||
$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'],
|
||||
|
@ -91,7 +91,7 @@ class TokenAnalyserTest extends OpenApiTestCase
|
|||
$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'],
|
||||
|
@ -167,10 +167,7 @@ class TokenAnalyserTest extends OpenApiTestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dataprovider.
|
||||
*/
|
||||
public function descriptions(): iterable
|
||||
public static function descriptions(): iterable
|
||||
{
|
||||
return [
|
||||
'class' => [
|
||||
|
|
|
@ -11,7 +11,7 @@ use OpenApi\Tests\OpenApiTestCase;
|
|||
|
||||
class TokenScannerTest extends OpenApiTestCase
|
||||
{
|
||||
public function scanCases(): iterable
|
||||
public static function scanCases(): iterable
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 80100) {
|
||||
yield 'abstract' => [
|
||||
|
|
|
@ -106,7 +106,7 @@ END;
|
|||
$parameter->validate();
|
||||
}
|
||||
|
||||
public function nestedMatches(): iterable
|
||||
public static function nestedMatches(): iterable
|
||||
{
|
||||
$parameterMatch = (object) ['key' => OA\Parameter::class, 'value' => ['parameters']];
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use OpenApi\Tests\OpenApiTestCase;
|
|||
|
||||
class OperationTest extends OpenApiTestCase
|
||||
{
|
||||
public function securityData(): iterable
|
||||
public static function securityData(): iterable
|
||||
{
|
||||
return [
|
||||
'empty' => [
|
||||
|
|
|
@ -18,7 +18,7 @@ use OpenApi\Serializer;
|
|||
|
||||
class ExamplesTest extends OpenApiTestCase
|
||||
{
|
||||
public function exampleDetails(): iterable
|
||||
public static function exampleDetails(): iterable
|
||||
{
|
||||
yield 'example-object' => [
|
||||
'version' => OA\OpenApi::VERSION_3_0_0,
|
||||
|
@ -185,14 +185,14 @@ class ExamplesTest extends OpenApiTestCase
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -13,9 +13,9 @@ use OpenApi\Util;
|
|||
|
||||
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"]];
|
||||
|
@ -46,7 +46,7 @@ class GeneratorTest extends OpenApiTestCase
|
|||
->generate(['/tmp/__swagger_php_does_not_exist__']);
|
||||
}
|
||||
|
||||
public function processorCases(): iterable
|
||||
public static function processorCases(): iterable
|
||||
{
|
||||
return [
|
||||
[new OperationId(), true],
|
||||
|
@ -124,7 +124,7 @@ class GeneratorTest extends OpenApiTestCase
|
|||
}
|
||||
}
|
||||
|
||||
public function configCases(): iterable
|
||||
public static function configCases(): iterable
|
||||
{
|
||||
return [
|
||||
'default' => [[], true],
|
||||
|
|
|
@ -202,14 +202,14 @@ class OpenApiTestCase extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -219,14 +219,14 @@ class OpenApiTestCase extends TestCase
|
|||
*
|
||||
* @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();
|
||||
|
||||
|
@ -264,7 +264,7 @@ class OpenApiTestCase extends TestCase
|
|||
/**
|
||||
* Collect list of all non-abstract annotation classes.
|
||||
*/
|
||||
public function allAnnotationClasses(): array
|
||||
public static function allAnnotationClasses(): array
|
||||
{
|
||||
$classes = [];
|
||||
$dir = new \DirectoryIterator(__DIR__ . '/../src/Annotations');
|
||||
|
@ -285,7 +285,7 @@ class OpenApiTestCase extends TestCase
|
|||
/**
|
||||
* Collect list of all non-abstract attribute classes.
|
||||
*/
|
||||
public function allAttributeClasses(): array
|
||||
public static function allAttributeClasses(): array
|
||||
{
|
||||
$classes = [];
|
||||
$dir = new \DirectoryIterator(__DIR__ . '/../src/Attributes');
|
||||
|
|
|
@ -23,7 +23,7 @@ class AugmentParametersTest extends OpenApiTestCase
|
|||
$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.',
|
||||
|
|
|
@ -11,9 +11,9 @@ use OpenApi\Tests\OpenApiTestCase;
|
|||
|
||||
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],
|
||||
|
|
|
@ -68,7 +68,7 @@ class ExpandEnumsTest extends OpenApiTestCase
|
|||
$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
|
||||
|
|
|
@ -11,19 +11,19 @@ use OpenApi\Generator;
|
|||
|
||||
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 = [
|
||||
|
|
|
@ -65,7 +65,7 @@ class UtilTest extends OpenApiTestCase
|
|||
$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']],
|
||||
|
|
Loading…
Reference in New Issue