Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/PHP-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG-4.x.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion lib/Parser/ParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
level: max
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
#checkMissingIterableValueType: false
#checkGenericClassInNonGenericObjectType: false
paths:
- lib/
12 changes: 8 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
convertDeprecationsToExceptions="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
failOnDeprecation="true"
failOnRisky="true"
failOnWarning="true"
displayDetailsOnPhpunitDeprecations="true"
>
<source ignoreSuppressionOfDeprecations="true">
<include>
<directory>./lib</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
</source>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="date.timezone" value="UTC"/>
Expand Down
5 changes: 3 additions & 2 deletions tests/Parser/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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/';

Expand All @@ -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 {
Expand Down
18 changes: 6 additions & 12 deletions tests/Rdata/DhcidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/Rdata/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\\';

Expand All @@ -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));
Expand Down
18 changes: 6 additions & 12 deletions tests/Rdata/IpseckeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand Down
19 changes: 6 additions & 13 deletions tests/Rdata/NaptrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand Down
19 changes: 6 additions & 13 deletions tests/Rdata/Nsec3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand Down
Loading
Loading