@@ -28,7 +28,7 @@ public function __construct(LoopInterface $loop, Resolver $resolver = null)
28
28
if ($ resolver === null ) {
29
29
// try to load nameservers from system config or default to Google's public DNS
30
30
$ config = Config::loadSystemConfigBlocking ();
31
- $ server = $ config ->nameservers ? reset ($ config ->nameservers ) : '8.8.8.8 ' ;
31
+ $ server = $ config ->nameservers ? \ reset ($ config ->nameservers ) : '8.8.8.8 ' ;
32
32
33
33
$ factory = new DnsFactory ();
34
34
$ resolver = $ factory ->create ($ server , $ loop );
@@ -43,7 +43,7 @@ public function createClient($address)
43
43
$ loop = $ this ->loop ;
44
44
45
45
return $ this ->resolveAddress ($ address )->then (function ($ address ) use ($ loop ) {
46
- $ socket = @stream_socket_client ($ address , $ errno , $ errstr );
46
+ $ socket = @\ stream_socket_client ($ address , $ errno , $ errstr );
47
47
if (!$ socket ) {
48
48
throw new Exception ('Unable to create client socket: ' . $ errstr , $ errno );
49
49
}
@@ -57,7 +57,7 @@ public function createServer($address)
57
57
$ loop = $ this ->loop ;
58
58
59
59
return $ this ->resolveAddress ($ address )->then (function ($ address ) use ($ loop ) {
60
- $ socket = @stream_socket_server ($ address , $ errno , $ errstr , STREAM_SERVER_BIND );
60
+ $ socket = @\ stream_socket_server ($ address , $ errno , $ errstr , \ STREAM_SERVER_BIND );
61
61
if (!$ socket ) {
62
62
throw new Exception ('Unable to create server socket: ' . $ errstr , $ errno );
63
63
}
@@ -68,18 +68,18 @@ public function createServer($address)
68
68
69
69
protected function resolveAddress ($ address )
70
70
{
71
- if (strpos ($ address , ':// ' ) === false ) {
71
+ if (\ strpos ($ address , ':// ' ) === false ) {
72
72
$ address = 'udp:// ' . $ address ;
73
73
}
74
74
75
75
// parse_url() does not accept null ports (random port assignment) => manually remove
76
76
$ nullport = false ;
77
- if (substr ($ address , -2 ) === ':0 ' ) {
78
- $ address = substr ($ address , 0 , -2 );
77
+ if (\ substr ($ address , -2 ) === ':0 ' ) {
78
+ $ address = \ substr ($ address , 0 , -2 );
79
79
$ nullport = true ;
80
80
}
81
81
82
- $ parts = parse_url ($ address );
82
+ $ parts = \ parse_url ($ address );
83
83
84
84
if (!$ parts || !isset ($ parts ['host ' ])) {
85
85
return Promise \resolve ($ address );
@@ -90,12 +90,12 @@ protected function resolveAddress($address)
90
90
}
91
91
92
92
// remove square brackets for IPv6 addresses
93
- $ host = trim ($ parts ['host ' ], '[] ' );
93
+ $ host = \ trim ($ parts ['host ' ], '[] ' );
94
94
95
95
return $ this ->resolveHost ($ host )->then (function ($ host ) use ($ parts ) {
96
96
$ address = $ parts ['scheme ' ] . ':// ' ;
97
97
98
- if (isset ($ parts ['port ' ]) && strpos ($ host , ': ' ) !== false ) {
98
+ if (isset ($ parts ['port ' ]) && \ strpos ($ host , ': ' ) !== false ) {
99
99
// enclose IPv6 address in square brackets if a port will be appended
100
100
$ host = '[ ' . $ host . '] ' ;
101
101
}
@@ -113,7 +113,7 @@ protected function resolveAddress($address)
113
113
protected function resolveHost ($ host )
114
114
{
115
115
// there's no need to resolve if the host is already given as an IP address
116
- if (false !== filter_var ($ host , FILTER_VALIDATE_IP )) {
116
+ if (false !== \ filter_var ($ host , \ FILTER_VALIDATE_IP )) {
117
117
return Promise \resolve ($ host );
118
118
}
119
119
0 commit comments