diff --git a/.github/workflows/PHP-8.yml b/.github/workflows/PHP-8.yml index 168ecce..904ecee 100644 --- a/.github/workflows/PHP-8.yml +++ b/.github/workflows/PHP-8.yml @@ -10,7 +10,11 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.0', '8.1', '8.2', '8.3'] + php: + - '8.2' + - '8.3' + - '8.4' + - '8.5' name: PHP ${{ matrix.php }} steps: - name: Checkout diff --git a/CHANGELOG-4.x.md b/CHANGELOG-4.x.md index 0cdb234..e94de23 100644 --- a/CHANGELOG-4.x.md +++ b/CHANGELOG-4.x.md @@ -1,5 +1,11 @@ CHANGELOG for 4.x ================= +## 4.4.0 +* [Pull #128](https://github.com/Badcow/DNS/pull/128/) Fix handling empty OPT. (Thank you, [@yeganemehr](https://github.com/yeganemehr)) +* [Pull #130](https://github.com/Badcow/DNS/pull/130/) Fix encoding TXT records as length-prefixed character-strings. (Thank you, [@yeganemehr](https://github.com/yeganemehr)) +* [Pull #131](https://github.com/Badcow/DNS/pull/131/) Fix encoding ResourceRecord with underscore on their name. (Thank you, [@yeganemehr](https://github.com/yeganemehr)) +* [Pull #129](https://github.com/Badcow/DNS/pull/129/) Fix stack overflow on self-referential compression pointer (Thank you, [@yeganemehr](https://github.com/yeganemehr)) +* [Pull #122](https://github.com/Badcow/DNS/pull/122/) Explicitly declare nullable types. (Thank you, [@SilvanWakker](https://github.com/SilvanWakker)) ## 4.3.0 * [Pull #118](https://github.com/Badcow/DNS/pull/118/) Remove strict hostname validator for `Question::setName`. (Thank you, [tomschlick](https://github.com/tomschlick)) diff --git a/composer.json b/composer.json index bf45a01..65a9aba 100755 --- a/composer.json +++ b/composer.json @@ -10,14 +10,14 @@ ], "minimum-stability": "stable", "require": { - "php": "^8.0", + "php": "^8.2", "rlanvin/php-ip": "^3.0", - "christian-riesen/base32": "^1.5.2" + "christian-riesen/base32": "^1.6" }, "require-dev": { - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^11.0", "friendsofphp/php-cs-fixer": "^3.5.0", - "phpstan/phpstan": "^1.4" + "phpstan/phpstan": "^2.2" }, "autoload": { "psr-4": { diff --git a/lib/Parser/ParseException.php b/lib/Parser/ParseException.php index 6d3a1da..c0f595f 100644 --- a/lib/Parser/ParseException.php +++ b/lib/Parser/ParseException.php @@ -23,7 +23,7 @@ class ParseException extends \Exception /** * ParseException constructor. */ - public function __construct(string $message = '', ?StringIterator $stringIterator = null, \Throwable $previous = null) + public function __construct(string $message = '', ?StringIterator $stringIterator = null, ?\Throwable $previous = null) { if (null !== $stringIterator) { $this->stringIterator = $stringIterator; diff --git a/phpstan.neon b/phpstan.neon index 6c51126..716d390 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,6 @@ parameters: level: max - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false + #checkMissingIterableValueType: false + #checkGenericClassInNonGenericObjectType: false paths: - lib/ \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fbfc4e9..5637965 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,15 @@ - + failOnDeprecation="true" + failOnRisky="true" + failOnWarning="true" + displayDetailsOnPhpunitDeprecations="true" +> + ./lib @@ -13,7 +17,7 @@ ./tests ./vendor - + diff --git a/tests/Parser/ParserTest.php b/tests/Parser/ParserTest.php index 2c36cd5..19b68ab 100644 --- a/tests/Parser/ParserTest.php +++ b/tests/Parser/ParserTest.php @@ -33,6 +33,7 @@ use Badcow\DNS\Zone; use Badcow\DNS\ZoneBuilder; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ParserTest extends TestCase { @@ -548,7 +549,7 @@ public function testParserHandlesOriginDot(): void $this->assertEquals($expectation, ZoneBuilder::build($zone)); } - public function dp_testParserHandlesIncludeDirective(): array + public static function dp_testParserHandlesIncludeDirective(): array { $baseDir = __DIR__.'/Resources/IncludeControlEntryTests/'; @@ -561,10 +562,10 @@ public function dp_testParserHandlesIncludeDirective(): array /** * Parser imports files specified by the $INCLUDE directive. * - * @dataProvider dp_testParserHandlesIncludeDirective * * @throws ParseException|\Exception */ + #[DataProvider('dp_testParserHandlesIncludeDirective')] public function testParserHandlesIncludeDirective(string $zoneName, int $ttl, string $zoneFilePath, string $expectationPath, int $commentOptions): void { $zoneFetcher = new class() implements ZoneFileFetcherInterface { diff --git a/tests/Rdata/DhcidTest.php b/tests/Rdata/DhcidTest.php index e71d5cd..d859fa9 100644 --- a/tests/Rdata/DhcidTest.php +++ b/tests/Rdata/DhcidTest.php @@ -16,10 +16,11 @@ use Badcow\DNS\Rdata\DHCID; use Badcow\DNS\Rdata\Factory; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class DhcidTest extends TestCase { - public function getDataProvider(): array + public static function getDataProvider(): array { return [ //[Text, IDType, Identifier, FQDN] @@ -82,9 +83,7 @@ public function testCalculateDigestThrowsExceptionIfIdentifierIsNotSet(): void $dhcid->calculateDigest(); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testToText(string $text, int $identifierType, string $identifier, string $fqdn): void { $dhcid = new DHCID(); @@ -95,9 +94,7 @@ public function testToText(string $text, int $identifierType, string $identifier $this->assertEquals($text, $dhcid->toText()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testToFromWire(string $text, int $identifierType, string $identifier, string $fqdn): void { $expectation = new DHCID(); @@ -115,10 +112,9 @@ public function testToFromWire(string $text, int $identifierType, string $identi } /** - * @dataProvider getDataProvider - * * @throws \Exception */ + #[DataProvider('getDataProvider')] public function testFromText(string $text, int $identifierType, string $identifier, string $fqdn): void { $expectation = new DHCID(); @@ -140,9 +136,7 @@ public function testFromText(string $text, int $identifierType, string $identifi $dhcid->fromText($text.'%'); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testFactory(string $text, int $identifierType, string $identifier, string $fqdn): void { $dhcid = Factory::DHCID(null, $identifierType, $identifier, $fqdn); diff --git a/tests/Rdata/FactoryTest.php b/tests/Rdata/FactoryTest.php index 832e71a..2988288 100644 --- a/tests/Rdata/FactoryTest.php +++ b/tests/Rdata/FactoryTest.php @@ -16,10 +16,11 @@ use Badcow\DNS\Rdata\Factory; use Badcow\DNS\Rdata\UnsupportedTypeException; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class FactoryTest extends TestCase { - public function getTestData(): array + public static function getTestData(): array { $namespace = '\\Badcow\\DNS\\Rdata\\'; @@ -31,10 +32,9 @@ public function getTestData(): array } /** - * @dataProvider getTestData - * * @throws UnsupportedTypeException */ + #[DataProvider('getTestData')] public function testNewRdataFromNameAndId(string $type, int $typeCode, string $classname): void { $this->assertInstanceOf($classname, Factory::newRdataFromName($type)); diff --git a/tests/Rdata/IpseckeyTest.php b/tests/Rdata/IpseckeyTest.php index 0b26199..d112c71 100644 --- a/tests/Rdata/IpseckeyTest.php +++ b/tests/Rdata/IpseckeyTest.php @@ -17,10 +17,11 @@ use Badcow\DNS\Rdata\Factory; use Badcow\DNS\Rdata\IPSECKEY; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class IpseckeyTest extends TestCase { - public function getDataProvider(): array + public static function getDataProvider(): array { return [ // Text, Precedence, GatewayType, Algorithm, Gateway, PublicKey @@ -45,9 +46,7 @@ public function testGetTypeCode(): void $this->assertEquals(45, $ipseckey->getTypeCode()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testToText(string $text, int $precedence, int $gatewayType, int $algorithm, ?string $gateway, ?string $publicKey): void { $ipseckey = new IPSECKEY(); @@ -59,10 +58,9 @@ public function testToText(string $text, int $precedence, int $gatewayType, int } /** - * @dataProvider getDataProvider - * * @throws DecodeException */ + #[DataProvider('getDataProvider')] public function testToFromWire(string $text, int $precedence, int $gatewayType, int $algorithm, ?string $gateway, ?string $publicKey): void { $ipseckey = new IPSECKEY(); @@ -82,9 +80,7 @@ public function testToFromWire(string $text, int $precedence, int $gatewayType, $this->assertEquals(3 + $rdLength, $offset); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testFromText(string $text, int $precedence, int $gatewayType, int $algorithm, ?string $gateway, ?string $publicKey): void { $ipseckey = new IPSECKEY(); @@ -97,9 +93,7 @@ public function testFromText(string $text, int $precedence, int $gatewayType, in $this->assertEquals($publicKey, $ipseckey->getPublicKey()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testFactory(string $text, int $precedence, int $gatewayType, int $algorithm, ?string $gateway, ?string $publicKey): void { $ipseckey = Factory::IPSECKEY($precedence, $gateway, $algorithm, $publicKey); diff --git a/tests/Rdata/NaptrTest.php b/tests/Rdata/NaptrTest.php index 81241d5..acf8a77 100644 --- a/tests/Rdata/NaptrTest.php +++ b/tests/Rdata/NaptrTest.php @@ -16,10 +16,11 @@ use Badcow\DNS\Rdata\Factory; use Badcow\DNS\Rdata\NAPTR; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class NaptrTest extends TestCase { - public function getDataProvider(): array + public static function getDataProvider(): array { return [ //Text Order Pref Flags Service Regexp Replacement @@ -42,9 +43,7 @@ public function testGetTypeCode(): void $this->assertEquals(35, $naptr->getTypeCode()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testToText(string $text, int $order, int $preference, string $flags, string $services, string $regexp, string $replacement): void { $naptr = new NAPTR(); @@ -58,9 +57,7 @@ public function testToText(string $text, int $order, int $preference, string $fl $this->assertEquals($text, $naptr->toText()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testToAndFromWire(string $text, int $order, int $preference, string $flags, string $services, string $regexp, string $replacement): void { $naptr = new NAPTR(); @@ -81,9 +78,7 @@ public function testToAndFromWire(string $text, int $order, int $preference, str $this->assertEquals(3 + $rdLength, $offset); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testFromText(string $text, int $order, int $preference, string $flags, string $services, string $regexp, string $replacement): void { $naptr = new NAPTR(); @@ -97,9 +92,7 @@ public function testFromText(string $text, int $order, int $preference, string $ $this->assertEquals($replacement, $naptr->getReplacement()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testFactory(string $text, int $order, int $preference, string $flags, string $services, string $regexp, string $replacement): void { $naptr = Factory::NAPTR($order, $preference, $flags, $services, $regexp, $replacement); diff --git a/tests/Rdata/Nsec3Test.php b/tests/Rdata/Nsec3Test.php index a386f4f..f35fe71 100644 --- a/tests/Rdata/Nsec3Test.php +++ b/tests/Rdata/Nsec3Test.php @@ -17,10 +17,11 @@ use Badcow\DNS\Rdata\NSEC3; use Base32\Base32Hex; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class Nsec3Test extends TestCase { - public function getDataProvider(): array + public static function getDataProvider(): array { return [ ['1 1 10 12345678 589R358VSPJUFVAJU949JPVF74D9PTGH A RRSIG', true, 10, '12345678', 'ns.sub.delzsk.example.', ['A', 'RRSIG'], '589R358VSPJUFVAJU949JPVF74D9PTGH'], @@ -40,9 +41,7 @@ public function testGetTypeCode(): void $this->assertEquals(50, $nsec3->getTypeCode()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testToText(string $text, bool $unsignedDelegationsCovered, int $iterations, string $salt, string $nextOwnerName, array $types, string $nextHashedOwnerName): void { $nsec3 = new NSEC3(); @@ -56,9 +55,7 @@ public function testToText(string $text, bool $unsignedDelegationsCovered, int $ $this->assertEquals($text, $nsec3->toText()); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testWire(string $text, bool $unsignedDelegationsCovered, int $iterations, string $salt, string $nextOwnerName, array $types, string $nextHashedOwnerName): void { $nsec3 = new NSEC3(); @@ -75,9 +72,7 @@ public function testWire(string $text, bool $unsignedDelegationsCovered, int $it $this->assertEquals($nsec3, $fromWire); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testFromText(string $text, bool $unsignedDelegationsCovered, int $iterations, string $salt, string $nextOwnerName, array $types, string $nextHashedOwnerName): void { $fromText = new NSEC3(); @@ -90,9 +85,7 @@ public function testFromText(string $text, bool $unsignedDelegationsCovered, int $this->assertEquals($fromText->getNextHashedOwnerName(), Base32Hex::decode($nextHashedOwnerName)); } - /** - * @dataProvider getDataProvider - */ + #[DataProvider('getDataProvider')] public function testFactory(string $text, bool $unsignedDelegationsCovered, int $iterations, string $salt, string $nextOwnerName, array $types, string $nextHashedOwnerName): void { $nsec3 = Factory::NSEC3($unsignedDelegationsCovered, $iterations, $salt, $nextOwnerName, $types); diff --git a/tests/Rdata/PtrTest.php b/tests/Rdata/PtrTest.php index dfae906..6ae05f1 100644 --- a/tests/Rdata/PtrTest.php +++ b/tests/Rdata/PtrTest.php @@ -15,10 +15,11 @@ use Badcow\DNS\Rdata\PTR; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class PtrTest extends TestCase { - public function provider_expandIPv6(): array + public static function provider_expandIPv6(): array { return [ ['0000:0000:0000:0000:0000:0000:0000:0001', '::1'], @@ -31,26 +32,22 @@ public function provider_expandIPv6(): array ]; } - public function provider_contractIPv6(): array + public static function provider_contractIPv6(): array { - return array_merge($this->provider_expandIPv6(), [ + return array_merge(self::provider_expandIPv6(), [ ['2001:db8:0:0:f:0:0:0', '2001:db8:0:0:f::'], ['2001:db8::ff00:42:8329', '2001:db8::ff00:42:8329'], ['2001:db8:a:bac:8099:d:f:9', '2001:db8:a:bac:8099:d:f:9'], ]); } - /** - * @dataProvider provider_expandIPv6 - */ + #[DataProvider('provider_expandIPv6')] public function testExpandIpv6(string $expectation, string $ip): void { $this->assertEquals($expectation, PTR::expandIpv6($ip)); } - /** - * @dataProvider provider_contractIPv6 - */ + #[DataProvider('provider_contractIPv6')] public function testContractIpv6(string $ip, string $expectation): void { $this->assertEquals($expectation, PTR::contractIpv6($ip)); diff --git a/tests/Rdata/SshfpTest.php b/tests/Rdata/SshfpTest.php index 34033f6..32a1fec 100644 --- a/tests/Rdata/SshfpTest.php +++ b/tests/Rdata/SshfpTest.php @@ -16,10 +16,11 @@ use Badcow\DNS\Rdata\Factory; use Badcow\DNS\Rdata\SSHFP; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class SshfpTest extends TestCase { - public function dataProvider_testExceptions(): array + public static function dataProvider_testExceptions(): array { return [ //[Algorithm, FPType, Fingerprint, ExpectedException, ExpectedExceptionMessage] @@ -41,9 +42,7 @@ public function testOutput(): void $this->assertEquals($expectation, $sshfp->toText()); } - /** - * @dataProvider dataProvider_testExceptions - */ + #[DataProvider('dataProvider_testExceptions')] public function testExceptions(int $algorithm, int $fpType, string $fingerprint, string $expectedException, string $expectedExceptionMessage): void { $this->expectException($expectedException); diff --git a/tests/Rdata/TxtTest.php b/tests/Rdata/TxtTest.php index b0a0d59..78c9cff 100644 --- a/tests/Rdata/TxtTest.php +++ b/tests/Rdata/TxtTest.php @@ -15,6 +15,7 @@ use Badcow\DNS\Rdata\TXT; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class TxtTest extends TestCase { @@ -27,7 +28,7 @@ public function testSetText(): void $this->assertEquals($text, $txt->getText()); } - public function dp_testToText(): array + public static function dp_testToText(): array { return [ //'what is tested' => [$text, $expectation] @@ -40,11 +41,10 @@ public function dp_testToText(): array } /** - * @dataProvider dp_testToText - * * @param string $text the input text value * @param string $expectation The expected output of TXT::toText() */ + #[DataProvider('dp_testToText')] public function testToText(string $text, string $expectation): void { $txt = new TXT(); @@ -53,7 +53,7 @@ public function testToText(string $text, string $expectation): void $this->assertEquals($expectation, $txt->toText()); } - public function dp_testFromTxt(): array + public static function dp_testFromTxt(): array { return [ //'what is tested' => [$text, $expectation] @@ -66,9 +66,7 @@ public function dp_testFromTxt(): array ]; } - /** - * @dataProvider dp_testFromTxt - */ + #[DataProvider('dp_testFromTxt')] public function testFromTxt(string $text, string $expectation): void { $txt = new TXT(); diff --git a/tests/Rdata/UriTest.php b/tests/Rdata/UriTest.php index aca625a..fde1cad 100644 --- a/tests/Rdata/UriTest.php +++ b/tests/Rdata/UriTest.php @@ -16,10 +16,11 @@ use Badcow\DNS\Rdata\Factory; use Badcow\DNS\Rdata\URI; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class UriTest extends TestCase { - public function dataProvider_testExceptions(): array + public static function dataProvider_testExceptions(): array { return [ //[Priority, Weight, Target, ExpectedException, ExpectedExceptionMessage] @@ -42,9 +43,7 @@ public function testOutput(): void $this->assertEquals('http://www.example.com/path', $srv->getTarget()); } - /** - * @dataProvider dataProvider_testExceptions - */ + #[DataProvider('dataProvider_testExceptions')] public function testExceptions(int $priority, int $weight, string $target, string $expectedException, string $expectedExceptionMessage): void { $this->expectException($expectedException); diff --git a/tests/ResourceRecordTest.php b/tests/ResourceRecordTest.php index 671c820..4854abc 100644 --- a/tests/ResourceRecordTest.php +++ b/tests/ResourceRecordTest.php @@ -21,6 +21,7 @@ use Exception; use InvalidArgumentException; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ResourceRecordTest extends TestCase { @@ -134,7 +135,7 @@ public function testToWireNameWithUnderscore(): void $this->assertEquals('_sip._tcp.example.com.', $decoded->getName()); } - public function dataProviderForTestToWireThrowsExceptionsIfValuesAreNotSet(): array + public static function dataProviderForTestToWireThrowsExceptionsIfValuesAreNotSet(): array { $rr_noName = new ResourceRecord(); $rr_noName->setClass(null); @@ -161,10 +162,9 @@ public function dataProviderForTestToWireThrowsExceptionsIfValuesAreNotSet(): ar } /** - * @dataProvider dataProviderForTestToWireThrowsExceptionsIfValuesAreNotSet - * * @throws UnsetValueException */ + #[DataProvider('dataProviderForTestToWireThrowsExceptionsIfValuesAreNotSet')] public function testToWireThrowsExceptionsIfValuesAreNotSet(ResourceRecord $rr, string $exception, string $exceptionMessage): void { $this->expectException($exception); diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 40f542f..08a19f4 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -19,11 +19,12 @@ use Badcow\DNS\ResourceRecord; use Badcow\DNS\Validator; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use RuntimeException; class ValidatorTest extends TestCase { - public function dp_testValidateResourceRecordName(): array + public static function dp_testValidateResourceRecordName(): array { return [ [true, 'example.com.'], @@ -47,15 +48,13 @@ public function dp_testValidateResourceRecordName(): array ]; } - /** - * @dataProvider dp_testValidateResourceRecordName - */ + #[DataProvider('dp_testValidateResourceRecordName')] public function testValidateResourceRecordName(bool $isValid, string $resourceName): void { $this->assertEquals($isValid, Validator::resourceRecordName($resourceName)); } - public function getIPv4TestDataSet(): array + public static function getIPv4TestDataSet(): array { return [ ['119.15.101.102', true], @@ -71,15 +70,13 @@ public function getIPv4TestDataSet(): array ]; } - /** - * @dataProvider getIPv4TestDataSet - */ + #[DataProvider('getIPv4TestDataSet')] public function testValidateIpv4Address(string $address, bool $isValid): void { $this->assertEquals($isValid, Validator::ipv4($address)); } - public function getIPv6TestDataSet(): array + public static function getIPv6TestDataSet(): array { return [ ['2001:0db8:0000:0000:0000:ff00:0042:8329', true], @@ -93,15 +90,13 @@ public function getIPv6TestDataSet(): array ]; } - /** - * @dataProvider getIPv6TestDataSet - */ + #[DataProvider('getIPv6TestDataSet')] public function testValidateIpv6Address(string $address, bool $isValid): void { $this->assertEquals($isValid, Validator::ipv6($address)); } - public function getIPvTestDataSet(): array + public static function getIPvTestDataSet(): array { return [ ['2001:0db8:0000:0000:0000:ff00:0042:8329', true], @@ -120,9 +115,7 @@ public function getIPvTestDataSet(): array ]; } - /** - * @dataProvider getIPvTestDataSet - */ + #[DataProvider('getIPvTestDataSet')] public function testValidateIpAddress(string $address, bool $isValid): void { $this->assertEquals($isValid, Validator::ipAddress($address)); @@ -205,7 +198,7 @@ public function testZone(): void $this->assertEquals(Validator::ZONE_OKAY, Validator::zone($zone)); } - public function getWildcardTestData(): array + public static function getWildcardTestData(): array { return [ ['*.example.com.', true], @@ -224,15 +217,14 @@ public function getWildcardTestData(): array /** * @param string $name the wildcard domain to be validated * @param bool $isValid whether the domain is valid - * - * @dataProvider getWildcardTestData */ + #[DataProvider('getWildcardTestData')] public function testWildcard(string $name, bool $isValid): void { $this->assertEquals($isValid, Validator::resourceRecordName($name)); } - public function getTestReverseIpv4DataProvider(): array + public static function getTestReverseIpv4DataProvider(): array { return [ ['10.IN-ADDR.ARPA.', true], @@ -254,15 +246,13 @@ public function getTestReverseIpv4DataProvider(): array ]; } - /** - * @dataProvider getTestReverseIpv4DataProvider - */ + #[DataProvider('getTestReverseIpv4DataProvider')] public function testReverseIpv4(string $ptr, bool $isValid): void { $this->assertEquals($isValid, Validator::reverseIpv4($ptr)); } - public function getTestReverseIpv6DataProvider(): array + public static function getTestReverseIpv6DataProvider(): array { return [ ['b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', true], @@ -271,9 +261,7 @@ public function getTestReverseIpv6DataProvider(): array ]; } - /** - * @dataProvider getTestReverseIpv6DataProvider - */ + #[DataProvider('getTestReverseIpv6DataProvider')] public function testReverseIpv6(string $ptr, bool $isValid): void { $this->assertEquals($isValid, Validator::reverseIpv6($ptr)); @@ -290,7 +278,7 @@ public function testResourceRecordName(): void $this->assertFalse(Validator::resourceRecordName($case_3)); } - public function getTestFqdnDataProvider(): array + public static function getTestFqdnDataProvider(): array { return [ ['example.com.', true], @@ -309,9 +297,7 @@ public function getTestFqdnDataProvider(): array ]; } - /** - * @dataProvider getTestFqdnDataProvider - */ + #[DataProvider('getTestFqdnDataProvider')] public function testFqdn(string $domain, bool $isValid, bool $strictHostValidation = true): void { $this->assertEquals($isValid, Validator::fullyQualifiedDomainName($domain, $strictHostValidation));