Skip to content

Commit

Permalink
Add attributes in addition to docblocks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spaze committed Mar 19, 2024
1 parent 75d9f4c commit 104dc95
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"require-dev": {
"nette/neon": "^3.2",
"nikic/php-parser": "^4.13 || ^5.0",
"phpunit/phpunit": "^8.5 || ^10.1",
"phpunit/phpunit": "^8.5 || ^10.1 || ^11.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"php-parallel-lint/php-console-highlighter": "^1.0",
"spaze/coding-standard": "^1.7"
Expand Down
2 changes: 2 additions & 0 deletions tests/Allowed/AllowedPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\ShouldNotHappenException;
use PHPStan\Testing\PHPStanTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Spaze\PHPStan\Rules\Disallowed\File\FilePath;
use Traits\TestClass;
use Traits\TestTrait;
Expand Down Expand Up @@ -44,6 +45,7 @@ protected function setUp(): void
/**
* @dataProvider pathProvider
*/
#[DataProvider('pathProvider')]
public function testMatches(string $allowedPath, string $file, string $fileWithRootDir): void
{
$context = ScopeContext::create($file);
Expand Down
2 changes: 2 additions & 0 deletions tests/Calls/FunctionCallsNamedParamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
use PHPStan\Rules\Rule;
use PHPStan\ShouldNotHappenException;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;
use Spaze\PHPStan\Rules\Disallowed\DisallowedCallFactory;
use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallsRuleErrors;

/**
* @requires PHP >= 8.0
*/
#[RequiresPhp('>= 8.0')]
class FunctionCallsNamedParamsTest extends RuleTestCase
{

Expand Down
2 changes: 2 additions & 0 deletions tests/DisallowedSuperglobalFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Generator;
use PHPStan\ShouldNotHappenException;
use PHPStan\Testing\PHPStanTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class DisallowedSuperglobalFactoryTest extends PHPStanTestCase
{
Expand All @@ -16,6 +17,7 @@ class DisallowedSuperglobalFactoryTest extends PHPStanTestCase
* @param class-string|null $exceptionClass
* @throws ShouldNotHappenException
*/
#[DataProvider('superglobalsProvider')]
public function testNonSuperglobalInConfig(string $superglobal, ?string $exceptionClass)
{
if ($exceptionClass) {
Expand Down
2 changes: 2 additions & 0 deletions tests/File/FilePathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Generator;
use PHPStan\File\FileHelper;
use PHPStan\Testing\PHPStanTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class FilePathTest extends PHPStanTestCase
{
Expand All @@ -28,6 +29,7 @@ protected function setUp(): void
/**
* @dataProvider pathProvider
*/
#[DataProvider('pathProvider')]
public function testFnMatch(string $path, string $file, string $fileWithRootDir): void
{
$this->assertTrue($this->filePath->fnMatch($path, $file));
Expand Down
3 changes: 3 additions & 0 deletions tests/Identifier/IdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Generator;
use PHPStan\Testing\PHPStanTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class IdentifierTest extends PHPStanTestCase
{
Expand All @@ -26,6 +27,7 @@ protected function setUp(): void
* @return void
* @dataProvider matchesProvider
*/
#[DataProvider('matchesProvider')]
public function testMatches(string $pattern, string $value, ?array $excludes): void
{
$this->assertTrue($this->identifier->matches($pattern, $value, $excludes));
Expand All @@ -39,6 +41,7 @@ public function testMatches(string $pattern, string $value, ?array $excludes): v
* @return void
* @dataProvider doesNotMatchProvider
*/
#[DataProvider('doesNotMatchProvider')]
public function testDoesNotMatch(string $pattern, string $value, ?array $excludes): void
{
$this->assertFalse($this->identifier->matches($pattern, $value, $excludes));
Expand Down
2 changes: 2 additions & 0 deletions tests/Usages/ClassConstantEnumUsagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Enums\Enum;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;
use Spaze\PHPStan\Rules\Disallowed\DisallowedConstantFactory;
use Spaze\PHPStan\Rules\Disallowed\Formatter\Formatter;
use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedConstantRuleErrors;
Expand All @@ -15,6 +16,7 @@
/**
* @requires PHP >= 8.1
*/
#[RequiresPhp('>= 8.1')]
class ClassConstantEnumUsagesTest extends RuleTestCase
{

Expand Down
2 changes: 2 additions & 0 deletions tests/Usages/NamespaceUsagesTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;
use Spaze\PHPStan\Rules\Disallowed\DisallowedNamespaceFactory;
use Spaze\PHPStan\Rules\Disallowed\Normalizer\Normalizer;
use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedNamespaceRuleErrors;

/**
* @requires PHP >= 8.1
*/
#[RequiresPhp('>= 8.1')]
class NamespaceUsagesTypesTest extends RuleTestCase
{

Expand Down

0 comments on commit 104dc95

Please sign in to comment.