Skip to content

Commit

Permalink
Fix psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Aug 2, 2024
1 parent f5c94ca commit 6242c91
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'phpunit.xml.dist'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -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']
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
3 changes: 3 additions & 0 deletions src/DnsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public static function existsA(string $hostname): bool
public static function acceptsEmails(string $hostnameOrEmail): bool
{
if (strpos($hostnameOrEmail, '@') !== false) {
/**
* @psalm-suppress PossiblyUndefinedArrayOffset In this cse `explode()` always returns array with 2 elements.
*/
[, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 2);

Check warning on line 76 in src/DnsHelper.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ /** * @psalm-suppress PossiblyUndefinedArrayOffset In this cse `explode()` always returns array with 2 elements. */ - [, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 2); + [, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 3); } return self::existsMx($hostnameOrEmail) || self::existsA($hostnameOrEmail); } }

Check warning on line 76 in src/DnsHelper.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ /** * @psalm-suppress PossiblyUndefinedArrayOffset In this cse `explode()` always returns array with 2 elements. */ - [, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 2); + [, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 3); } return self::existsMx($hostnameOrEmail) || self::existsA($hostnameOrEmail); } }
}
return self::existsMx($hostnameOrEmail) || self::existsA($hostnameOrEmail);

Check warning on line 78 in src/DnsHelper.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "LogicalOr": --- Original +++ New @@ @@ */ [, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 2); } - return self::existsMx($hostnameOrEmail) || self::existsA($hostnameOrEmail); + return self::existsMx($hostnameOrEmail) && self::existsA($hostnameOrEmail); } }

Check warning on line 78 in src/DnsHelper.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "LogicalOr": --- Original +++ New @@ @@ */ [, $hostnameOrEmail] = explode('@', $hostnameOrEmail, 2); } - return self::existsMx($hostnameOrEmail) || self::existsA($hostnameOrEmail); + return self::existsMx($hostnameOrEmail) && self::existsA($hostnameOrEmail); } }
Expand Down
2 changes: 1 addition & 1 deletion src/IpHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {@see IPV4} or {@see IPV6}.
* @return int Value of {@see IPV4} or {@see IPV6} constants.
*/
public static function getIpVersion(string $ip, bool $validate = true): int
{
Expand Down

0 comments on commit 6242c91

Please sign in to comment.