From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Sat, 5 Apr 2025 10:48:15 +0200
Subject: Modernize PHPUnit syntax

---
 tests/Constraints/BaseTestCase.php                  | 17 +++++------------
 tests/Constraints/CoerciveTest.php                  |  5 +++--
 tests/Constraints/DefaultPropertiesTest.php         | 13 ++++---------
 tests/Constraints/FactoryTest.php                   |  9 +++------
 tests/Constraints/FormatTest.php                    | 13 ++++---------
 tests/Constraints/SchemaValidationTest.php          |  9 +++------
 tests/Constraints/TypeTest.php                      |  9 +++------
 tests/Entity/JsonPointerTest.php                    |  5 ++---
 tests/RefTest.php                                   |  3 ++-
 tests/Rfc3339Test.php                               |  9 +++------
 tests/Tool/DeepComparerTest.php                     |  9 +++------
 .../Validator/RelativeReferenceValidatorTest.php    |  5 +++--
 tests/Tool/Validator/UriValidatorTest.php           |  5 +++--
 tests/Uri/UriRetrieverTest.php                      | 21 ++++++---------------
 14 files changed, 47 insertions(+), 85 deletions(-)

diff --git a/tests/Constraints/BaseTestCase.php b/tests/Constraints/BaseTestCase.php
index ba55b46..009c2d7 100644
--- a/tests/Constraints/BaseTestCase.php
+++ b/tests/Constraints/BaseTestCase.php
@@ -14,6 +14,7 @@ use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\Uri\UriResolver;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 /**
  * @package JsonSchema\Tests\Constraints
@@ -23,9 +24,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
     protected $schemaSpec = 'http://json-schema.org/draft-04/schema#';
     protected $validateSchema = false;
 
-    /**
-     * @dataProvider getInvalidTests
-     */
+    #[DataProvider('getInvalidTests')]
     public function testInvalidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL, $errors = []): void
     {
         $checkMode = $checkMode === null ? Constraint::CHECK_MODE_NORMAL : $checkMode;
@@ -52,9 +51,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
         $this->assertFalse($validator->isValid(), print_r($validator->getErrors(), true));
     }
 
-    /**
-     * @dataProvider getInvalidForAssocTests
-     */
+    #[DataProvider('getInvalidForAssocTests')]
     public function testInvalidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST, $errors = []): void
     {
         $checkMode = $checkMode === null ? Constraint::CHECK_MODE_TYPE_CAST : $checkMode;
@@ -84,9 +81,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
         $this->assertFalse($validator->isValid(), print_r($validator->getErrors(), true));
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL): void
     {
         if ($this->validateSchema) {
@@ -106,9 +101,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
         $this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true));
     }
 
-    /**
-     * @dataProvider getValidForAssocTests
-     */
+    #[DataProvider('getValidForAssocTests')]
     public function testValidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST): void
     {
         if ($this->validateSchema) {
diff --git a/tests/Constraints/CoerciveTest.php b/tests/Constraints/CoerciveTest.php
index 3c028ba..eef2fc1 100644
--- a/tests/Constraints/CoerciveTest.php
+++ b/tests/Constraints/CoerciveTest.php
@@ -13,6 +13,7 @@ use JsonSchema\Constraints\Constraint;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class CoerciveTest extends VeryBaseTestCase
 {
@@ -189,7 +190,7 @@ class CoerciveTest extends VeryBaseTestCase
         return $tests;
     }
 
-    /** @dataProvider dataCoerceCases **/
+    #[DataProvider('dataCoerceCases')]
     public function testCoerceCases($schema, $data, $startType, $endType, $endValue, $valid, $extraFlags = 0, $assoc = false): void
     {
         $validator = new Validator($this->factory);
@@ -231,7 +232,7 @@ class CoerciveTest extends VeryBaseTestCase
         }
     }
 
-    /** @dataProvider dataCoerceCases **/
+    #[DataProvider('dataCoerceCases')]
     public function testCoerceCasesUsingAssoc($schema, $data, $startType, $endType, $endValue, $valid, $early = false): void
     {
         $this->testCoerceCases($schema, $data, $startType, $endType, $endValue, $valid, $early, true);
diff --git a/tests/Constraints/DefaultPropertiesTest.php b/tests/Constraints/DefaultPropertiesTest.php
index 2849835..702de51 100644
--- a/tests/Constraints/DefaultPropertiesTest.php
+++ b/tests/Constraints/DefaultPropertiesTest.php
@@ -13,6 +13,7 @@ use JsonSchema\Constraints\Constraint;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class DefaultPropertiesTest extends VeryBaseTestCase
 {
@@ -167,9 +168,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         ];
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCases($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         if (is_string($input)) {
@@ -194,9 +193,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         }
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCasesUsingAssoc($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         $input = json_decode($input, true);
@@ -205,9 +202,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         self::testValidCases($input, $schema, $expectOutput, $checkMode);
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCasesUsingAssocWithoutTypeCast($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         $input = json_decode($input, true);
diff --git a/tests/Constraints/FactoryTest.php b/tests/Constraints/FactoryTest.php
index 9136f50..70917a4 100644
--- a/tests/Constraints/FactoryTest.php
+++ b/tests/Constraints/FactoryTest.php
@@ -17,6 +17,7 @@ use JsonSchema\Constraints\ConstraintInterface;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\Entity\JsonPointer;
 use JsonSchema\Exception\InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class MyBadConstraint
@@ -32,9 +33,7 @@ class MyStringConstraint extends Constraint
 
 class FactoryTest extends TestCase
 {
-    /**
-     * @dataProvider constraintNameProvider
-     */
+    #[DataProvider('constraintNameProvider')]
     public function testCreateInstanceForConstraintName(string $constraintName, string $expectedClass): void
     {
         $factory = new Factory();
@@ -59,9 +58,7 @@ class FactoryTest extends TestCase
         yield 'Schema' => ['schema', Constraints\SchemaConstraint::class];
     }
 
-    /**
-     * @dataProvider invalidConstraintNameProvider
-     */
+    #[DataProvider('invalidConstraintNameProvider')]
     public function testExceptionWhenCreateInstanceForInvalidConstraintName(string $constraintName): void
     {
         $factory = new Factory();
diff --git a/tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php
index 25eab1c..03a45dd 100644
--- a/tests/Constraints/FormatTest.php
+++ b/tests/Constraints/FormatTest.php
@@ -12,6 +12,7 @@ namespace JsonSchema\Tests\Constraints;
 use JsonSchema\Constraints\Constraint;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\Constraints\FormatConstraint;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class FormatTest extends BaseTestCase
 {
@@ -54,9 +55,7 @@ class FormatTest extends BaseTestCase
         $this->assertEmpty($validator->getErrors());
     }
 
-    /**
-     * @dataProvider getValidFormats
-     */
+    #[DataProvider('getValidFormats')]
     public function testValidFormat($string, $format): void
     {
         $validator = new FormatConstraint();
@@ -67,9 +66,7 @@ class FormatTest extends BaseTestCase
         $this->assertEmpty($validator->getErrors());
     }
 
-    /**
-     * @dataProvider getInvalidFormats
-     */
+    #[DataProvider('getInvalidFormats')]
     public function testInvalidFormat($string, $format): void
     {
         $validator = new FormatConstraint();
@@ -80,9 +77,7 @@ class FormatTest extends BaseTestCase
         $this->assertCount(1, $validator->getErrors(), 'Expected 1 error');
     }
 
-    /**
-     * @dataProvider getInvalidFormats
-     */
+    #[DataProvider('getInvalidFormats')]
     public function testDisabledFormat($string, $format): void
     {
         $factory = new Factory();
diff --git a/tests/Constraints/SchemaValidationTest.php b/tests/Constraints/SchemaValidationTest.php
index 65268f4..7b20061 100644
--- a/tests/Constraints/SchemaValidationTest.php
+++ b/tests/Constraints/SchemaValidationTest.php
@@ -11,6 +11,7 @@ namespace JsonSchema\Tests\Constraints;
 
 use JsonSchema\Constraints\Constraint;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class SchemaValidationTest extends TestCase
@@ -61,9 +62,7 @@ class SchemaValidationTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider getInvalidTests
-     */
+    #[DataProvider('getInvalidTests')]
     public function testInvalidCases($schema): void
     {
         $input = json_decode('{"propertyOne":"valueOne"}');
@@ -82,9 +81,7 @@ class SchemaValidationTest extends TestCase
         }
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCases($schema): void
     {
         $input = json_decode('{"propertyOne":"valueOne"}');
diff --git a/tests/Constraints/TypeTest.php b/tests/Constraints/TypeTest.php
index 1b6edc4..8056e65 100644
--- a/tests/Constraints/TypeTest.php
+++ b/tests/Constraints/TypeTest.php
@@ -11,6 +11,7 @@ namespace JsonSchema\Tests\Constraints;
 
 use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
 use JsonSchema\Constraints\TypeConstraint;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -41,9 +42,7 @@ class TypeTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider provideIndefiniteArticlesForTypes
-     */
+    #[DataProvider('provideIndefiniteArticlesForTypes')]
     public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $wording, $value = null, $label = 'NULL'): void
     {
         $constraint = new TypeConstraint();
@@ -100,9 +99,7 @@ class TypeTest extends TestCase
         return $wordings;
     }
 
-    /**
-     * @dataProvider validNameWordingDataProvider
-     */
+    #[DataProvider('validNameWordingDataProvider')]
     public function testValidateTypeNameWording($nameWording): void
     {
         $t = new TypeConstraint();
diff --git a/tests/Entity/JsonPointerTest.php b/tests/Entity/JsonPointerTest.php
index cb27c68..3f7dff6 100644
--- a/tests/Entity/JsonPointerTest.php
+++ b/tests/Entity/JsonPointerTest.php
@@ -13,6 +13,7 @@ namespace JsonSchema\Tests\Entity;
 
 use JsonSchema\Entity\JsonPointer;
 use JsonSchema\Exception\InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -22,9 +23,7 @@ use PHPUnit\Framework\TestCase;
  */
 class JsonPointerTest extends TestCase
 {
-    /**
-     * @dataProvider jsonPointerDataProvider
-     */
+    #[DataProvider('jsonPointerDataProvider')]
     public function testJsonPointer(
         string $testValue,
         string $expectedFileName,
diff --git a/tests/RefTest.php b/tests/RefTest.php
index 3b66d58..7ebaf64 100644
--- a/tests/RefTest.php
+++ b/tests/RefTest.php
@@ -10,6 +10,7 @@
 namespace JsonSchema\Tests;
 
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class RefTest extends TestCase
@@ -61,7 +62,7 @@ class RefTest extends TestCase
         ];
     }
 
-    /** @dataProvider dataRefIgnoresSiblings */
+    #[DataProvider('dataRefIgnoresSiblings')]
     public function testRefIgnoresSiblings($schema, $document, $isValid, $exception = null): void
     {
         $document = json_decode($document);
diff --git a/tests/Rfc3339Test.php b/tests/Rfc3339Test.php
index 9c2f23f..9f314b4 100644
--- a/tests/Rfc3339Test.php
+++ b/tests/Rfc3339Test.php
@@ -5,13 +5,12 @@ declare(strict_types=1);
 namespace JsonSchema\Tests;
 
 use JsonSchema\Rfc3339;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class Rfc3339Test extends TestCase
 {
-    /**
-     * @dataProvider provideValidFormats
-     */
+    #[DataProvider('provideValidFormats')]
     public function testCreateFromValidString(string $string, \DateTime $expected): void
     {
         $actual = Rfc3339::createFromString($string);
@@ -20,9 +19,7 @@ class Rfc3339Test extends TestCase
         $this->assertEquals($expected->format('U.u'), $actual->format('U.u'));
     }
 
-    /**
-     * @dataProvider provideInvalidFormats
-     */
+    #[DataProvider('provideInvalidFormats')]
     public function testCreateFromInvalidString(string $string): void
     {
         $this->assertNull(Rfc3339::createFromString($string), sprintf('String "%s" should not be converted to DateTime', $string));
diff --git a/tests/Tool/DeepComparerTest.php b/tests/Tool/DeepComparerTest.php
index cb7b02a..197e42e 100644
--- a/tests/Tool/DeepComparerTest.php
+++ b/tests/Tool/DeepComparerTest.php
@@ -5,21 +5,18 @@ declare(strict_types=1);
 namespace JsonSchema\Tests\Tool;
 
 use JsonSchema\Tool\DeepComparer;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class DeepComparerTest extends TestCase
 {
-    /**
-     * @dataProvider equalDataProvider
-     */
+    #[DataProvider('equalDataProvider')]
     public function testComparesDeepEqualForEqualLeftAndRight($left, $right): void
     {
         self::assertTrue(DeepComparer::isEqual($left, $right));
     }
 
-    /**
-     * @dataProvider notEqualDataProvider
-     */
+    #[DataProvider('notEqualDataProvider')]
     public function testComparesDeepEqualForNotEqualLeftAndRight($left, $right): void
     {
         self::assertFalse(DeepComparer::isEqual($left, $right));
diff --git a/tests/Tool/Validator/RelativeReferenceValidatorTest.php b/tests/Tool/Validator/RelativeReferenceValidatorTest.php
index 2a9b6d6..04f1bd2 100644
--- a/tests/Tool/Validator/RelativeReferenceValidatorTest.php
+++ b/tests/Tool/Validator/RelativeReferenceValidatorTest.php
@@ -5,17 +5,18 @@ declare(strict_types=1);
 namespace Tool\Validator;
 
 use JsonSchema\Tool\Validator\RelativeReferenceValidator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class RelativeReferenceValidatorTest extends TestCase
 {
-    /** @dataProvider validRelativeReferenceDataProvider */
+    #[DataProvider('validRelativeReferenceDataProvider')]
     public function testValidRelativeReferencesAreValidatedAsSuch(string $ref): void
     {
         self::assertTrue(RelativeReferenceValidator::isValid($ref));
     }
 
-    /** @dataProvider invalidRelativeReferenceDataProvider */
+    #[DataProvider('invalidRelativeReferenceDataProvider')]
     public function testInvalidRelativeReferencesAreValidatedAsSuch(string $ref): void
     {
         self::assertFalse(RelativeReferenceValidator::isValid($ref));
diff --git a/tests/Tool/Validator/UriValidatorTest.php b/tests/Tool/Validator/UriValidatorTest.php
index 80a45c8..83cc0d9 100644
--- a/tests/Tool/Validator/UriValidatorTest.php
+++ b/tests/Tool/Validator/UriValidatorTest.php
@@ -5,17 +5,18 @@ declare(strict_types=1);
 namespace Tool\Validator;
 
 use JsonSchema\Tool\Validator\UriValidator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class UriValidatorTest extends TestCase
 {
-    /** @dataProvider validUriDataProvider */
+    #[DataProvider('validUriDataProvider')]
     public function testValidUrisAreValidatedAsSuch(string $uri): void
     {
         self::assertTrue(UriValidator::isValid($uri));
     }
 
-    /** @dataProvider invalidUriDataProvider */
+    #[DataProvider('invalidUriDataProvider')]
     public function testInvalidUrisAreValidatedAsSuch(string $uri): void
     {
         self::assertFalse(UriValidator::isValid($uri));
diff --git a/tests/Uri/UriRetrieverTest.php b/tests/Uri/UriRetrieverTest.php
index e1addf8..1343dbf 100644
--- a/tests/Uri/UriRetrieverTest.php
+++ b/tests/Uri/UriRetrieverTest.php
@@ -15,6 +15,7 @@ use JsonSchema\Exception\ResourceNotFoundException;
 use JsonSchema\Exception\UriResolverException;
 use JsonSchema\Uri\UriRetriever;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -47,9 +48,7 @@ class UriRetrieverTest extends TestCase
         return $retriever;
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentValidTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -62,9 +61,7 @@ class UriRetrieverTest extends TestCase
         $this->assertTrue($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentInvalidChildTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -77,9 +74,7 @@ class UriRetrieverTest extends TestCase
         $this->assertFalse($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentInvalidParentTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -92,9 +87,7 @@ class UriRetrieverTest extends TestCase
         $this->assertFalse($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testResolveRelativeUri($childSchema, $parentSchema): void
     {
         self::setParentSchemaExtendsValue($parentSchema, 'grandparent');
@@ -422,9 +415,7 @@ EOF;
         ];
     }
 
-    /**
-     * @dataProvider combinedURITests
-     */
+    #[DataProvider('combinedURITests')]
     public function testResolveCombinedURI($uri, $baseURI, $combinedURI): void
     {
         $retriever = new UriRetriever();
