Skip to content

Commit

Permalink
Fix #40: Fix return type for callback of set_error_handler() function
Browse files Browse the repository at this point in the history
  • Loading branch information
devanych committed Jan 27, 2022
1 parent 0aff832 commit 6db8207
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
@@ -1,10 +1,9 @@
# Yii Network Utilities Change Log


## 1.0.1 under development

- no changes in this release.
- Bug #40: Fix return type for callback of `set_error_handler()` function (devanych)

## 1.0.0 March 04, 2021

- Initial release.
- Initial release.
31 changes: 13 additions & 18 deletions src/DnsHelper.php
Expand Up @@ -20,15 +20,13 @@ final class DnsHelper
*/
public static function existsMx(string $hostname): bool
{
/** @psalm-suppress InvalidArgument, MixedArgumentTypeCoercion */
set_error_handler(
static function (int $errorNumber, string $errorString) use ($hostname): ?bool {
throw new RuntimeException(
sprintf('Failed to get DNS record "%s". ', $hostname) . $errorString,
$errorNumber
);
}
);
set_error_handler(static function (int $errorNumber, string $errorString) use ($hostname): bool {
throw new RuntimeException(
sprintf('Failed to get DNS record "%s". ', $hostname) . $errorString,
$errorNumber
);
});

$hostname = rtrim($hostname, '.') . '.';
$result = dns_get_record($hostname, DNS_MX);

Expand All @@ -46,15 +44,12 @@ static function (int $errorNumber, string $errorString) use ($hostname): ?bool {
*/
public static function existsA(string $hostname): bool
{
/** @psalm-suppress InvalidArgument, MixedArgumentTypeCoercion */
set_error_handler(
static function (int $errorNumber, string $errorString) use ($hostname): ?bool {
throw new RuntimeException(
sprintf('Failed to get DNS record "%s". ', $hostname) . $errorString,
$errorNumber
);
}
);
set_error_handler(static function (int $errorNumber, string $errorString) use ($hostname): bool {
throw new RuntimeException(
sprintf('Failed to get DNS record "%s". ', $hostname) . $errorString,
$errorNumber
);
});

$result = dns_get_record($hostname, DNS_A);

Expand Down

0 comments on commit 6db8207

Please sign in to comment.