From 40bb72810b468a2d46f4f5b98e3334f367671bdf Mon Sep 17 00:00:00 2001 From: XternalSoft <1142472+XternalSoft@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:10:17 +0200 Subject: [PATCH 1/4] chore: add PHP 8.5 support and modernize nullable type hints - Updated GitHub Actions workflow to include PHP 8.3, 8.4, and 8.5 in the test matrix. - Migrated CI to use `shivammathur/setup-php` on Ubuntu 24.04 for better environment management. - Relaxed PHPUnit version constraints in `composer.json` to support versions 9.0 through 11.0. - Refactored various classes to use explicit nullable type hints (`?Type`) for parameters with null default values. - Ensured strict PHP 8.x compatibility by resolving potential deprecation warnings related to implicit nullability. --- .github/workflows/tests.yml | 16 +++++++++++----- composer.json | 2 +- .../Whois/Exceptions/ConnectionException.php | 2 +- .../Whois/Exceptions/ServerMismatchException.php | 2 +- src/Iodev/Whois/Exceptions/WhoisException.php | 2 +- src/Iodev/Whois/Factory.php | 14 +++++++------- src/Iodev/Whois/Modules/Asn/AsnModule.php | 4 ++-- src/Iodev/Whois/Modules/Tld/TldModule.php | 4 ++-- src/Iodev/Whois/Modules/Tld/TldServer.php | 4 ++-- src/Iodev/Whois/WhoisDeprecated.php | 2 +- 10 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e04312c5..92fc9b54 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,19 +3,25 @@ on: [push, pull_request] jobs: php-intl: - runs-on: ubuntu-18.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: - php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] steps: - uses: actions/checkout@v2 with: fetch-depth: 1 - - run: php${{ matrix.php-version }} -v - - run: php${{ matrix.php-version }} -m + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: curl, mbstring, json, intl + + - run: php -v + - run: php -m - run: composer -V - run: composer install - - run: php${{ matrix.php-version }} vendor/bin/phpunit --bootstrap tests/bootstrap.php tests + - run: vendor/bin/phpunit --bootstrap tests/bootstrap.php tests diff --git a/composer.json b/composer.json index 873402c0..1975d9de 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "symfony/polyfill-intl-idn": "^1.27" }, "require-dev" : { - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0" }, "autoload": { "psr-4": { diff --git a/src/Iodev/Whois/Exceptions/ConnectionException.php b/src/Iodev/Whois/Exceptions/ConnectionException.php index 960333d8..519be8c4 100644 --- a/src/Iodev/Whois/Exceptions/ConnectionException.php +++ b/src/Iodev/Whois/Exceptions/ConnectionException.php @@ -9,7 +9,7 @@ class ConnectionException extends Exception { - public function __construct($message = "", $code = 0, Throwable $previous = null) + public function __construct($message = "", $code = 0, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Iodev/Whois/Exceptions/ServerMismatchException.php b/src/Iodev/Whois/Exceptions/ServerMismatchException.php index be7eb45f..e3a0d93b 100644 --- a/src/Iodev/Whois/Exceptions/ServerMismatchException.php +++ b/src/Iodev/Whois/Exceptions/ServerMismatchException.php @@ -8,7 +8,7 @@ class ServerMismatchException extends \Exception { - public function __construct($message = "", $code = 0, Throwable $previous = null) + public function __construct($message = "", $code = 0, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Iodev/Whois/Exceptions/WhoisException.php b/src/Iodev/Whois/Exceptions/WhoisException.php index cd3bda85..f33eb928 100644 --- a/src/Iodev/Whois/Exceptions/WhoisException.php +++ b/src/Iodev/Whois/Exceptions/WhoisException.php @@ -8,7 +8,7 @@ class WhoisException extends \Exception { - public function __construct($message = "", $code = 0, Throwable $previous = null) + public function __construct($message = "", $code = 0, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Iodev/Whois/Factory.php b/src/Iodev/Whois/Factory.php index 8d880f7a..027c7d03 100644 --- a/src/Iodev/Whois/Factory.php +++ b/src/Iodev/Whois/Factory.php @@ -42,7 +42,7 @@ public function createPunycode(): IPunycode * @param ILoader|null $loader * @return Whois */ - public function createWhois(ILoader $loader = null): Whois + public function createWhois(?ILoader $loader = null): Whois { $whois = new Whois($loader ?: $this->createLoader()); $whois->setFactory($this); @@ -84,7 +84,7 @@ public function createTldModule(Whois $ehois): TldModule * @param TldParser|null $defaultParser * @return TldServer[] */ - public function createTldSevers($configs = null, TldParser $defaultParser = null): array + public function createTldSevers($configs = null, ?TldParser $defaultParser = null): array { $configs = is_array($configs) ? $configs : Config::load("module.tld.servers"); $defaultParser = $defaultParser ?: $this->createTldParser(); @@ -100,7 +100,7 @@ public function createTldSevers($configs = null, TldParser $defaultParser = null * @param TldParser|null $defaultParser * @return TldServer */ - public function createTldSever(array $config, TldParser $defaultParser = null): TldServer + public function createTldSever(array $config, ?TldParser $defaultParser = null): TldServer { return new TldServer( $config['zone'] ?? '', @@ -116,7 +116,7 @@ public function createTldSever(array $config, TldParser $defaultParser = null): * @param TldParser|null $defaultParser * @return TldParser */ - public function createTldSeverParser(array $config, TldParser $defaultParser = null): TldParser + public function createTldSeverParser(array $config, ?TldParser $defaultParser = null): TldParser { $options = $config['parserOptions'] ?? []; if (isset($config['parserClass'])) { @@ -204,7 +204,7 @@ public function getTldParserConfigByType($type) * @param AsnParser $defaultParser * @return AsnServer[] */ - public function createAsnSevers($configs = null, AsnParser $defaultParser = null): array + public function createAsnSevers($configs = null, ?AsnParser $defaultParser = null): array { $configs = is_array($configs) ? $configs : Config::load("module.asn.servers"); $defaultParser = $defaultParser ?: $this->createAsnParser(); @@ -220,7 +220,7 @@ public function createAsnSevers($configs = null, AsnParser $defaultParser = null * @param AsnParser $defaultParser * @return AsnServer */ - public function createAsnSever($config, AsnParser $defaultParser = null) + public function createAsnSever($config, ?AsnParser $defaultParser = null) { return new AsnServer( $config['host'] ?? '', @@ -234,7 +234,7 @@ public function createAsnSever($config, AsnParser $defaultParser = null) * @param AsnParser|null $defaultParser * @return AsnParser */ - public function createAsnSeverParser(array $config, AsnParser $defaultParser = null): AsnParser + public function createAsnSeverParser(array $config, ?AsnParser $defaultParser = null): AsnParser { if (isset($config['parserClass'])) { return $this->createAsnParserByClass($config['parserClass']); diff --git a/src/Iodev/Whois/Modules/Asn/AsnModule.php b/src/Iodev/Whois/Modules/Asn/AsnModule.php index 82e8c1cf..ace1d2f7 100644 --- a/src/Iodev/Whois/Modules/Asn/AsnModule.php +++ b/src/Iodev/Whois/Modules/Asn/AsnModule.php @@ -57,7 +57,7 @@ public function setServers($servers) * @throws ConnectionException * @throws WhoisException */ - public function lookupAsn($asn, AsnServer $server = null) + public function lookupAsn($asn, ?AsnServer $server = null) { if ($server) { return $this->loadResponse($asn, $server); @@ -73,7 +73,7 @@ public function lookupAsn($asn, AsnServer $server = null) * @throws ConnectionException * @throws WhoisException */ - public function loadAsnInfo($asn, AsnServer $server = null) + public function loadAsnInfo($asn, ?AsnServer $server = null) { if ($server) { $resp = $this->loadResponse($asn, $server); diff --git a/src/Iodev/Whois/Modules/Tld/TldModule.php b/src/Iodev/Whois/Modules/Tld/TldModule.php index c2b501ba..84273c49 100644 --- a/src/Iodev/Whois/Modules/Tld/TldModule.php +++ b/src/Iodev/Whois/Modules/Tld/TldModule.php @@ -116,7 +116,7 @@ public function isDomainAvailable($domain) * @throws ConnectionException * @throws WhoisException */ - public function lookupDomain($domain, TldServer $server = null) + public function lookupDomain($domain, ?TldServer $server = null) { $servers = $server ? [$server] : $this->matchServers($domain); list ($response) = $this->loadDomainData($domain, $servers); @@ -131,7 +131,7 @@ public function lookupDomain($domain, TldServer $server = null) * @throws ConnectionException * @throws WhoisException */ - public function loadDomainInfo($domain, TldServer $server = null) + public function loadDomainInfo($domain, ?TldServer $server = null) { $servers = $server ? [$server] : $this->matchServers($domain); list (, $info) = $this->loadDomainData($domain, $servers); diff --git a/src/Iodev/Whois/Modules/Tld/TldServer.php b/src/Iodev/Whois/Modules/Tld/TldServer.php index e3b9dc95..cfa1170d 100644 --- a/src/Iodev/Whois/Modules/Tld/TldServer.php +++ b/src/Iodev/Whois/Modules/Tld/TldServer.php @@ -20,7 +20,7 @@ class TldServer * @param TldParser $defaultParser * @return TldServer */ - public static function fromData($data, TldParser $defaultParser = null) + public static function fromData($data, ?TldParser $defaultParser = null) { return Factory::get()->createTldSever($data, $defaultParser); } @@ -30,7 +30,7 @@ public static function fromData($data, TldParser $defaultParser = null) * @param TldParser $defaultParser * @return TldServer[] */ - public static function fromDataList($dataList, TldParser $defaultParser = null) + public static function fromDataList($dataList, ?TldParser $defaultParser = null) { return Factory::get()->createTldSevers($dataList, $defaultParser); } diff --git a/src/Iodev/Whois/WhoisDeprecated.php b/src/Iodev/Whois/WhoisDeprecated.php index 93f1cb98..d7dd07d8 100644 --- a/src/Iodev/Whois/WhoisDeprecated.php +++ b/src/Iodev/Whois/WhoisDeprecated.php @@ -13,7 +13,7 @@ trait WhoisDeprecated * @param ILoader $loader * @return Whois */ - public static function create(ILoader $loader = null) + public static function create(?ILoader $loader = null) { return Factory::get()->createWhois($loader); } From 08b2ba24b977355f7af2f4b89eb446e10de0668e Mon Sep 17 00:00:00 2001 From: XternalSoft <1142472+XternalSoft@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:18:08 +0200 Subject: [PATCH 2/4] fix: resolve PHP 8.5 test failures and PHPUnit compatibility - Updated `TextHelper::toUtf8` to use an explicit encoding list for `mb_detect_encoding`, ensuring correct handling of non-UTF8 text (e.g., ISO-8859-1). - Applied `#[AllowDynamicProperties]` to `TldParser` to suppress deprecation warnings when setting dynamic configuration properties. - Converted `TldParsingTest::getTestData` to a static method to comply with PHPUnit 10+ requirements. - Verified all 460 tests are passing on PHP 8.5. --- src/Iodev/Whois/Helpers/TextHelper.php | 2 +- src/Iodev/Whois/Modules/Tld/TldParser.php | 1 + tests/Iodev/Whois/Modules/Tld/TldParsingTest.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Iodev/Whois/Helpers/TextHelper.php b/src/Iodev/Whois/Helpers/TextHelper.php index be96554a..6dc6e120 100644 --- a/src/Iodev/Whois/Helpers/TextHelper.php +++ b/src/Iodev/Whois/Helpers/TextHelper.php @@ -12,7 +12,7 @@ class TextHelper */ public static function toUtf8($text) { - $srcEncoding = mb_detect_encoding($text); + $srcEncoding = mb_detect_encoding($text, ['UTF-8', 'ISO-8859-1', 'Windows-1251', 'Windows-1252'], true); if (!empty($srcEncoding) && strtolower($srcEncoding) !== 'utf-8') { return mb_convert_encoding($text, 'utf-8', strtolower($srcEncoding)); } diff --git a/src/Iodev/Whois/Modules/Tld/TldParser.php b/src/Iodev/Whois/Modules/Tld/TldParser.php index 2dff24a9..c2e40c65 100644 --- a/src/Iodev/Whois/Modules/Tld/TldParser.php +++ b/src/Iodev/Whois/Modules/Tld/TldParser.php @@ -4,6 +4,7 @@ namespace Iodev\Whois\Modules\Tld; +#[\AllowDynamicProperties] abstract class TldParser { use TldParserDeprecated; diff --git a/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php b/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php index 48ae48dd..459e9dab 100644 --- a/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php +++ b/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php @@ -157,7 +157,7 @@ public function testResponseParsing($domain, $srcTextFilename, $expectedJsonFile ); } - public function getTestData() + public static function getTestData() { $resolveKeys = function($list) { $result = []; From 9ca2f7c1bbcfc08e48d29838ceb0fc7245091289 Mon Sep 17 00:00:00 2001 From: XternalSoft <1142472+XternalSoft@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:19:19 +0200 Subject: [PATCH 3/4] ci: upgrade actions/checkout to v4 for Node.js 24 compatibility - Updated `actions/checkout` from v2 to v4 to resolve Node.js 20 deprecation warnings. - Ensures the CI workflow remains functional on newer GitHub Actions runners. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 92fc9b54..6c16fadf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 1 From 4ec8c338aedcfaf4843bcf38294f49a8b7c5f836 Mon Sep 17 00:00:00 2001 From: XternalSoft <1142472+XternalSoft@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:21:20 +0200 Subject: [PATCH 4/4] ci: upgrade actions/checkout to v6 and force Node.js 24 runtime - Upgraded `actions/checkout` from v4 to v6 to support Node.js 24 natively. - Added `FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true` at the workflow level to resolve deprecation warnings for all other actions. - This ensures the CI environment is future-proof and avoids warnings related to Node.js 20 removal. --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6c16fadf..1237f9dc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,8 @@ on: [push, pull_request] +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + jobs: php-intl: @@ -10,7 +13,7 @@ jobs: php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: 1