1
0
mirror of https://github.com/danog/dns.git synced 2024-11-27 04:24:48 +01:00

Fix parameter order

This commit is contained in:
Bob Weinand 2016-02-21 21:51:06 +01:00
parent f70bd2d79f
commit 35b147d6f0

View File

@ -6,7 +6,6 @@ use Amp\Cache\ArrayCache;
use Amp\CoroutineResult; use Amp\CoroutineResult;
use Amp\Deferred; use Amp\Deferred;
use Amp\Failure; use Amp\Failure;
use Amp\File\FilesystemException;
use Amp\Success; use Amp\Success;
use LibDNS\Decoder\DecoderFactory; use LibDNS\Decoder\DecoderFactory;
use LibDNS\Encoder\EncoderFactory; use LibDNS\Encoder\EncoderFactory;
@ -69,7 +68,7 @@ function resolve($name, array $options = []) {
function query($name, $type, array $options = []) { function query($name, $type, array $options = []) {
if (!$inAddr = @\inet_pton($name)) { if (!$inAddr = @\inet_pton($name)) {
if (__isValidHostName($name)) { if (__isValidHostName($name)) {
$handler = __NAMESPACE__ . "\\" . (empty($options["recurse"]) ? "__doRecurse" : "__doResolve"); $handler = __NAMESPACE__ . "\\" . (empty($options["recurse"]) ? "__doResolve" : "__doRecurse");
$types = (array) $type; $types = (array) $type;
return __pipeResult(\Amp\resolve($handler($name, $types, $options)), $types); return __pipeResult(\Amp\resolve($handler($name, $types, $options)), $types);
} else { } else {
@ -204,9 +203,7 @@ function __doResolve($name, array $types, $options) {
return; return;
} }
assert(array_reduce($types, function ($result, $val) { assert(array_reduce($types, function ($result, $val) { return $result && \is_int($val); }, true), 'The $types passed to DNS functions must all be integers (from \Amp\Dns\Record class)');
return $result && \is_int($val);
}, true), 'The $types passed to DNS functions must all be integers (from \Amp\Dns\Record class)');
$name = \strtolower($name); $name = \strtolower($name);
$result = []; $result = [];
@ -263,7 +260,7 @@ function __doResolve($name, array $types, $options) {
if (empty($result)) { // if we have no cached results if (empty($result)) { // if we have no cached results
throw $e; throw $e;
} }
} catch (\RuntimeException $e) { // if all promises in Amp\some fail } catch (\Amp\CombinatorException $e) { // if all promises in Amp\some fail
if (empty($result)) { // if we have no cached results if (empty($result)) { // if we have no cached results
throw new ResolutionException("All name resolution requests failed", 0, $e); throw new ResolutionException("All name resolution requests failed", 0, $e);
} }
@ -357,9 +354,7 @@ function __loadResolvConf($path = null) {
} }
} }
} }
} catch (FilesystemException $e) { } catch (\Amp\File\FilesystemException $e) {}
// use default
}
} }
yield new CoroutineResult($result); yield new CoroutineResult($result);
@ -408,7 +403,7 @@ function __parseCustomServerUri($uri) {
'Invalid server address ($uri must be a string IP address, ' . gettype($uri) . " given)" 'Invalid server address ($uri must be a string IP address, ' . gettype($uri) . " given)"
); );
} }
if (strpos("://", $uri) !== false) { if (strpos($uri, "://") !== false) {
return $uri; return $uri;
} }
if (($colonPos = strrpos(":", $uri)) !== false) { if (($colonPos = strrpos(":", $uri)) !== false) {