From 6242c91b2098fa7495ed808b99712e4619d839bd Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Fri, 2 Aug 2024 16:52:29 +0300 Subject: [PATCH 1/5] Fix psalm --- .github/workflows/static.yml | 4 +++- composer.json | 2 +- psalm.xml | 2 ++ src/DnsHelper.php | 3 +++ src/IpHelper.php | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 40ac260..05dad6a 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -10,6 +10,8 @@ on: - 'phpunit.xml.dist' push: + branches: + - master paths-ignore: - 'docs/**' - 'README.md' @@ -28,4 +30,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['7.4', '8.0', '8.1'] + ['7.4', '8.0', '8.1', '8.2', '8.3'] diff --git a/composer.json b/composer.json index 8c75f63..f7ea6c9 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "phpunit/phpunit": "^9.5", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.18" + "vimeo/psalm": "^4.30|^5.25" }, "autoload": { "psr-4": { diff --git a/psalm.xml b/psalm.xml index 752a2ca..2f9469c 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,8 @@ Date: Fri, 2 Aug 2024 16:58:47 +0300 Subject: [PATCH 2/5] Fix incorrect check error occurred while converting IP address to bits representation in PHP 8.0+ --- CHANGELOG.md | 4 ++-- src/IpHelper.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d019093..efffecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,11 @@ ## 1.0.2 under development -- no changes in this release. +- Bug #59: Fix incorrect check error occurred while converting IP address to bits representation in PHP 8.0+ (@vjik) ## 1.0.1 January 27, 2022 -- Bug #40: Fix return type for callback of `set_error_handler()` function (devanych) +- Bug #40: Fix return type for callback of `set_error_handler()` function (@devanych) ## 1.0.0 March 04, 2021 diff --git a/src/IpHelper.php b/src/IpHelper.php index 726f316..f6d8d10 100644 --- a/src/IpHelper.php +++ b/src/IpHelper.php @@ -173,7 +173,7 @@ public static function ip2bin(string $ip): string $result = ''; for ($i = 0, $iMax = strlen($ipBinary); $i < $iMax; $i += 4) { $data = substr($ipBinary, $i, 4); - if (!is_string($data)) { + if (empty($data)) { throw new RuntimeException('An error occurred while converting IP address to bits representation.'); } /** @psalm-suppress MixedArgument */ From cfbd49ea1d68e2056ac409ff469afe5f063b63d3 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 6 Aug 2024 09:42:33 +0300 Subject: [PATCH 3/5] Update src/IpHelper.php Co-authored-by: Alexander Makarov --- src/IpHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IpHelper.php b/src/IpHelper.php index f6d8d10..437cc12 100644 --- a/src/IpHelper.php +++ b/src/IpHelper.php @@ -52,7 +52,7 @@ final class IpHelper * @param string $ip The valid IPv4 or IPv6 address. * @param bool $validate Enable perform IP address validation. False is best practice if the data comes from a trusted source. * - * @return int Value of {@see IPV4} or {@see IPV6} constants. + * @return int Value of either {@see IPV4} or {@see IPV6} constant. */ public static function getIpVersion(string $ip, bool $validate = true): int { From 9cad752e57f1de27a0149be4c6e16a40fa47c558 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 6 Aug 2024 09:42:45 +0300 Subject: [PATCH 4/5] Update src/DnsHelper.php Co-authored-by: Alexander Makarov --- src/DnsHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DnsHelper.php b/src/DnsHelper.php index d7a54d7..8cf3f61 100644 --- a/src/DnsHelper.php +++ b/src/DnsHelper.php @@ -71,7 +71,7 @@ public static function acceptsEmails(string $hostnameOrEmail): bool { if (strpos($hostnameOrEmail, '@') !== false) { /** - * @psalm-suppress PossiblyUndefinedArrayOffset In this cse `explode()` always returns array with 2 elements. + * @psalm-suppress PossiblyUndefinedArrayOffset In this case `explode()` always returns an array with 2 elements. */ [, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 2); } From 629b63c5a3ba3269a76899fa5ab65f1cf9c75868 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 6 Aug 2024 09:42:58 +0300 Subject: [PATCH 5/5] Update CHANGELOG.md Co-authored-by: Alexander Makarov --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efffecb..53dd318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.0.2 under development -- Bug #59: Fix incorrect check error occurred while converting IP address to bits representation in PHP 8.0+ (@vjik) +- Bug #59: Fix error while converting IP address to bits representation in PHP 8.0+ (@vjik) ## 1.0.1 January 27, 2022