Skip to content

Commit 2dbc132

Browse files
committed
Data providers with attributes
1 parent f520540 commit 2dbc132

File tree

190 files changed

+732
-1191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+732
-1191
lines changed

tests/PHPStan/Analyser/AnalyserTest.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use PHPStan\Rules\Properties\ReadWritePropertiesExtensionProvider;
3131
use PHPStan\Testing\PHPStanTestCase;
3232
use PHPStan\Type\FileTypeMapper;
33+
use PHPUnit\Framework\Attributes\DataProvider;
3334
use stdClass;
3435
use function array_map;
3536
use function array_merge;
@@ -195,9 +196,9 @@ public static function dataIgnoreErrorByPathAndCount(): iterable
195196
}
196197

197198
/**
198-
* @dataProvider dataIgnoreErrorByPathAndCount
199199
* @param mixed[] $ignoreErrors
200200
*/
201+
#[DataProvider('dataIgnoreErrorByPathAndCount')]
201202
public function testIgnoreErrorByPathAndCount(array $ignoreErrors): void
202203
{
203204
$result = $this->runAnalyser($ignoreErrors, true, __DIR__ . '/data/two-fails.php', false);
@@ -212,9 +213,7 @@ public static function dataTrueAndFalse(): array
212213
];
213214
}
214215

215-
/**
216-
* @dataProvider dataTrueAndFalse
217-
*/
216+
#[DataProvider('dataTrueAndFalse')]
218217
public function testIgnoreErrorByPathAndIdentifierCountsCorrectly(bool $onlyFiles): void
219218
{
220219
$ignoreErrors = [
@@ -238,9 +237,7 @@ public function testIgnoreErrorByPathAndIdentifierCountsCorrectly(bool $onlyFile
238237
$this->assertNoErrors($result);
239238
}
240239

241-
/**
242-
* @dataProvider dataTrueAndFalse
243-
*/
240+
#[DataProvider('dataTrueAndFalse')]
244241
public function testIgnoreErrorByPathAndCountMoreThanExpected(bool $onlyFiles): void
245242
{
246243
$ignoreErrors = [
@@ -269,9 +266,7 @@ public function testIgnoreErrorByPathAndCountMoreThanExpected(bool $onlyFiles):
269266
$this->assertSamePaths(__DIR__ . '/data/two-fails.php', $result[2]->getFile());
270267
}
271268

272-
/**
273-
* @dataProvider dataTrueAndFalse
274-
*/
269+
#[DataProvider('dataTrueAndFalse')]
275270
public function testIgnoreErrorByPathAndCountLessThanExpected(bool $onlyFiles): void
276271
{
277272
$ignoreErrors = [
@@ -434,9 +429,7 @@ public static function dataIgnoreErrorInTraitUsingClassFilePath(): array
434429
];
435430
}
436431

437-
/**
438-
* @dataProvider dataIgnoreErrorInTraitUsingClassFilePath
439-
*/
432+
#[DataProvider('dataIgnoreErrorInTraitUsingClassFilePath')]
440433
public function testIgnoreErrorInTraitUsingClassFilePath(string $pathToIgnore): void
441434
{
442435
$ignoreErrors = [
@@ -487,9 +480,7 @@ public function testReportMultipleParserErrorsAtOnce(): void
487480
$this->assertSame(10, $errorTwo->getLine());
488481
}
489482

490-
/**
491-
* @dataProvider dataTrueAndFalse
492-
*/
483+
#[DataProvider('dataTrueAndFalse')]
493484
public function testDoNotReportUnmatchedIgnoredErrorsFromPathIfPathWasNotAnalysed(bool $onlyFiles): void
494485
{
495486
$ignoreErrors = [
@@ -508,9 +499,7 @@ public function testDoNotReportUnmatchedIgnoredErrorsFromPathIfPathWasNotAnalyse
508499
$this->assertNoErrors($result);
509500
}
510501

511-
/**
512-
* @dataProvider dataTrueAndFalse
513-
*/
502+
#[DataProvider('dataTrueAndFalse')]
514503
public function testDoNotReportUnmatchedIgnoredErrorsFromPathWithCountIfPathWasNotAnalysed(bool $onlyFiles): void
515504
{
516505
$ignoreErrors = [
@@ -559,9 +548,7 @@ public function testIgnoreNextLineUnmatched(): void
559548
}
560549
}
561550

562-
/**
563-
* @dataProvider dataTrueAndFalse
564-
*/
551+
#[DataProvider('dataTrueAndFalse')]
565552
public function testIgnoreLine(bool $reportUnmatchedIgnoredErrors): void
566553
{
567554
$result = $this->runAnalyser([], $reportUnmatchedIgnoredErrors, [

tests/PHPStan/Analyser/ArgumentsNormalizerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PHPStan\Type\StringType;
1818
use PHPStan\Type\Type;
1919
use PHPStan\Type\VerbosityLevel;
20+
use PHPUnit\Framework\Attributes\DataProvider;
2021
use function count;
2122

2223
class ArgumentsNormalizerTest extends PHPStanTestCase
@@ -245,11 +246,11 @@ public static function dataReorderValid(): iterable
245246
}
246247

247248
/**
248-
* @dataProvider dataReorderValid
249249
* @param array<int, array{non-empty-string, bool, bool, ?Type}> $parameterSettings
250250
* @param array<int, array{Type, ?non-empty-string}> $argumentSettings
251251
* @param array<int, Type> $expectedArgumentTypes
252252
*/
253+
#[DataProvider('dataReorderValid')]
253254
public function testReorderValid(
254255
array $parameterSettings,
255256
array $argumentSettings,
@@ -325,10 +326,10 @@ public static function dataReorderInvalid(): iterable
325326
}
326327

327328
/**
328-
* @dataProvider dataReorderInvalid
329329
* @param array<int, array{non-empty-string, bool, bool, ?Type}> $parameterSettings
330330
* @param array<int, array{Type, ?non-empty-string}> $argumentSettings
331331
*/
332+
#[DataProvider('dataReorderInvalid')]
332333
public function testReorderInvalid(
333334
array $parameterSettings,
334335
array $argumentSettings,

tests/PHPStan/Analyser/AssertStubTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class AssertStubTest extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/Bug10922Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class Bug10922Test extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/Bug10980Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class Bug10980Test extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/Bug11009Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class Bug11009Test extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/Bug9307Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class Bug9307Test extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/ClassConstantStubFileTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class ClassConstantStubFileTest extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/ConditionalReturnTypeFromMethodStubTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class ConditionalReturnTypeFromMethodStubTest extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/DoNotPolluteScopeWithBlockTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class DoNotPolluteScopeWithBlockTest extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/DoNotRememberPossiblyImpureFunctionValuesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class DoNotRememberPossiblyImpureFunctionValuesTest extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataAsserts')]
1920
public function testAsserts(
2021
string $assertType,
2122
string $file,

tests/PHPStan/Analyser/DynamicMethodThrowTypeExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67
use const PHP_VERSION_ID;
78

89
class DynamicMethodThrowTypeExtensionTest extends TypeInferenceTestCase
@@ -19,9 +20,9 @@ public static function dataFileAsserts(): iterable
1920
}
2021

2122
/**
22-
* @dataProvider dataFileAsserts
2323
* @param mixed ...$args
2424
*/
25+
#[DataProvider('dataFileAsserts')]
2526
public function testFileAsserts(
2627
string $assertType,
2728
string $file,

tests/PHPStan/Analyser/DynamicReturnTypeExtensionTypeInferenceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67
use const PHP_VERSION_ID;
78

89
class DynamicReturnTypeExtensionTypeInferenceTest extends TypeInferenceTestCase
@@ -22,9 +23,9 @@ public static function dataAsserts(): iterable
2223
}
2324

2425
/**
25-
* @dataProvider dataAsserts
2626
* @param mixed ...$args
2727
*/
28+
#[DataProvider('dataAsserts')]
2829
public function testAsserts(
2930
string $assertType,
3031
string $file,

tests/PHPStan/Analyser/ErrorTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\PHPStanTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class ErrorTest extends PHPStanTestCase
89
{
@@ -29,9 +30,7 @@ public static function dataValidIdentifier(): iterable
2930
yield ['3m.blah'];
3031
}
3132

32-
/**
33-
* @dataProvider dataValidIdentifier
34-
*/
33+
#[DataProvider('dataValidIdentifier')]
3534
public function testValidIdentifier(string $identifier): void
3635
{
3736
$this->assertTrue(Error::validateIdentifier($identifier));
@@ -48,9 +47,7 @@ public static function dataInvalidIdentifier(): iterable
4847
yield ['.'];
4948
}
5049

51-
/**
52-
* @dataProvider dataInvalidIdentifier
53-
*/
50+
#[DataProvider('dataInvalidIdentifier')]
5451
public function testInvalidIdentifier(string $identifier): void
5552
{
5653
$this->assertFalse(Error::validateIdentifier($identifier));

tests/PHPStan/Analyser/ExpressionTypeResolverExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
class ExpressionTypeResolverExtensionTest extends TypeInferenceTestCase
89
{
@@ -13,9 +14,9 @@ public static function dataFileAsserts(): iterable
1314
}
1415

1516
/**
16-
* @dataProvider dataFileAsserts
1717
* @param mixed ...$args
1818
*/
19+
#[DataProvider('dataFileAsserts')]
1920
public function testFileAsserts(
2021
string $assertType,
2122
string $file,

0 commit comments

Comments
 (0)