Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #225 - compatibility with PHP 8.4 #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 7 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ 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']

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/checkout@v4

- run: php${{ matrix.php-version }} -v
- run: php${{ matrix.php-version }} -m
- run: composer -V
- run: php -v
- run: php -m
- run: composer --version
- run: composer install
- run: php${{ matrix.php-version }} vendor/bin/phpunit --bootstrap tests/bootstrap.php tests
- run: php vendor/bin/phpunit --bootstrap tests/bootstrap.php tests
2 changes: 1 addition & 1 deletion src/Iodev/Whois/Exceptions/ConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Iodev/Whois/Exceptions/ServerMismatchException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Iodev/Whois/Exceptions/WhoisException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Iodev/Whois/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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'] ?? '',
Expand All @@ -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'])) {
Expand Down Expand Up @@ -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();
Expand All @@ -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'] ?? '',
Expand All @@ -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']);
Expand Down
4 changes: 2 additions & 2 deletions src/Iodev/Whois/Modules/Asn/AsnModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Iodev/Whois/Modules/Tld/Parsers/CommonParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

class CommonParser extends TldParser
{
/** @var array */
protected $parserTypes = [];

/** @var string */
protected $headerKey = 'HEADER';

Expand Down
4 changes: 2 additions & 2 deletions src/Iodev/Whois/Modules/Tld/TldModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/Iodev/Whois/Modules/Tld/TldServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -42,7 +42,7 @@ public static function fromDataList($dataList, TldParser $defaultParser = null)
* @param TldParser $parser
* @param string $queryFormat
*/
public function __construct($zone, $host, $centralized, TldParser $parser, $queryFormat = null)
public function __construct($zone, $host, $centralized, ?TldParser $parser, $queryFormat = null)
{
$this->uid = ++self::$counter;
$this->zone = strval($zone);
Expand Down Expand Up @@ -76,7 +76,7 @@ public function __construct($zone, $host, $centralized, TldParser $parser, $quer

/** @var string */
protected $host;

/** @var TldParser */
protected $parser;

Expand Down
2 changes: 1 addition & 1 deletion src/Iodev/Whois/WhoisDeprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down