Skip to content

Commit 104dc95

Browse files
committed
Add attributes in addition to docblocks
Added in PHPUnit 10, in 11 docblocks with no attributes throw something like 3) Metadata found in doc-comment for method Spaze\PHPStan\Rules\Disallowed\Identifier\IdentifierTest::testMatches(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.
1 parent 75d9f4c commit 104dc95

8 files changed

+16
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"require-dev": {
2828
"nette/neon": "^3.2",
2929
"nikic/php-parser": "^4.13 || ^5.0",
30-
"phpunit/phpunit": "^8.5 || ^10.1",
30+
"phpunit/phpunit": "^8.5 || ^10.1 || ^11.0",
3131
"php-parallel-lint/php-parallel-lint": "^1.2",
3232
"php-parallel-lint/php-console-highlighter": "^1.0",
3333
"spaze/coding-standard": "^1.7"

tests/Allowed/AllowedPathTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PHPStan\Reflection\ReflectionProvider;
1212
use PHPStan\ShouldNotHappenException;
1313
use PHPStan\Testing\PHPStanTestCase;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Spaze\PHPStan\Rules\Disallowed\File\FilePath;
1516
use Traits\TestClass;
1617
use Traits\TestTrait;
@@ -44,6 +45,7 @@ protected function setUp(): void
4445
/**
4546
* @dataProvider pathProvider
4647
*/
48+
#[DataProvider('pathProvider')]
4749
public function testMatches(string $allowedPath, string $file, string $fileWithRootDir): void
4850
{
4951
$context = ScopeContext::create($file);

tests/Calls/FunctionCallsNamedParamsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
use PHPStan\Rules\Rule;
77
use PHPStan\ShouldNotHappenException;
88
use PHPStan\Testing\RuleTestCase;
9+
use PHPUnit\Framework\Attributes\RequiresPhp;
910
use Spaze\PHPStan\Rules\Disallowed\DisallowedCallFactory;
1011
use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallsRuleErrors;
1112

1213
/**
1314
* @requires PHP >= 8.0
1415
*/
16+
#[RequiresPhp('>= 8.0')]
1517
class FunctionCallsNamedParamsTest extends RuleTestCase
1618
{
1719

tests/DisallowedSuperglobalFactoryTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Generator;
77
use PHPStan\ShouldNotHappenException;
88
use PHPStan\Testing\PHPStanTestCase;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910

1011
class DisallowedSuperglobalFactoryTest extends PHPStanTestCase
1112
{
@@ -16,6 +17,7 @@ class DisallowedSuperglobalFactoryTest extends PHPStanTestCase
1617
* @param class-string|null $exceptionClass
1718
* @throws ShouldNotHappenException
1819
*/
20+
#[DataProvider('superglobalsProvider')]
1921
public function testNonSuperglobalInConfig(string $superglobal, ?string $exceptionClass)
2022
{
2123
if ($exceptionClass) {

tests/File/FilePathTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Generator;
77
use PHPStan\File\FileHelper;
88
use PHPStan\Testing\PHPStanTestCase;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910

1011
class FilePathTest extends PHPStanTestCase
1112
{
@@ -28,6 +29,7 @@ protected function setUp(): void
2829
/**
2930
* @dataProvider pathProvider
3031
*/
32+
#[DataProvider('pathProvider')]
3133
public function testFnMatch(string $path, string $file, string $fileWithRootDir): void
3234
{
3335
$this->assertTrue($this->filePath->fnMatch($path, $file));

tests/Identifier/IdentifierTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Generator;
77
use PHPStan\Testing\PHPStanTestCase;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89

910
class IdentifierTest extends PHPStanTestCase
1011
{
@@ -26,6 +27,7 @@ protected function setUp(): void
2627
* @return void
2728
* @dataProvider matchesProvider
2829
*/
30+
#[DataProvider('matchesProvider')]
2931
public function testMatches(string $pattern, string $value, ?array $excludes): void
3032
{
3133
$this->assertTrue($this->identifier->matches($pattern, $value, $excludes));
@@ -39,6 +41,7 @@ public function testMatches(string $pattern, string $value, ?array $excludes): v
3941
* @return void
4042
* @dataProvider doesNotMatchProvider
4143
*/
44+
#[DataProvider('doesNotMatchProvider')]
4245
public function testDoesNotMatch(string $pattern, string $value, ?array $excludes): void
4346
{
4447
$this->assertFalse($this->identifier->matches($pattern, $value, $excludes));

tests/Usages/ClassConstantEnumUsagesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Enums\Enum;
88
use PHPStan\Rules\Rule;
99
use PHPStan\Testing\RuleTestCase;
10+
use PHPUnit\Framework\Attributes\RequiresPhp;
1011
use Spaze\PHPStan\Rules\Disallowed\DisallowedConstantFactory;
1112
use Spaze\PHPStan\Rules\Disallowed\Formatter\Formatter;
1213
use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedConstantRuleErrors;
@@ -15,6 +16,7 @@
1516
/**
1617
* @requires PHP >= 8.1
1718
*/
19+
#[RequiresPhp('>= 8.1')]
1820
class ClassConstantEnumUsagesTest extends RuleTestCase
1921
{
2022

tests/Usages/NamespaceUsagesTypesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55

66
use PHPStan\Rules\Rule;
77
use PHPStan\Testing\RuleTestCase;
8+
use PHPUnit\Framework\Attributes\RequiresPhp;
89
use Spaze\PHPStan\Rules\Disallowed\DisallowedNamespaceFactory;
910
use Spaze\PHPStan\Rules\Disallowed\Normalizer\Normalizer;
1011
use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedNamespaceRuleErrors;
1112

1213
/**
1314
* @requires PHP >= 8.1
1415
*/
16+
#[RequiresPhp('>= 8.1')]
1517
class NamespaceUsagesTypesTest extends RuleTestCase
1618
{
1719

0 commit comments

Comments
 (0)