@@ -108,20 +108,20 @@ private function parseQuestion($data, $consumed)
108108 list ($ labels , $ consumed ) = $ this ->readLabels ($ data , $ consumed );
109109
110110 if ($ labels === null || !isset ($ data [$ consumed + 4 - 1 ])) {
111- return array ( null , null ) ;
111+ return [ null , null ] ;
112112 }
113113
114114 list ($ type , $ class ) = array_values (unpack ('n* ' , substr ($ data , $ consumed , 4 )));
115115 $ consumed += 4 ;
116116
117- return array (
117+ return [
118118 new Query (
119119 implode ('. ' , $ labels ),
120120 $ type ,
121121 $ class
122122 ),
123123 $ consumed
124- ) ;
124+ ] ;
125125 }
126126
127127 /**
@@ -134,7 +134,7 @@ private function parseRecord($data, $consumed)
134134 list ($ name , $ consumed ) = $ this ->readDomain ($ data , $ consumed );
135135
136136 if ($ name === null || !isset ($ data [$ consumed + 10 - 1 ])) {
137- return array ( null , null ) ;
137+ return [ null , null ] ;
138138 }
139139
140140 list ($ type , $ class ) = array_values (unpack ('n* ' , substr ($ data , $ consumed , 4 )));
@@ -152,7 +152,7 @@ private function parseRecord($data, $consumed)
152152 $ consumed += 2 ;
153153
154154 if (!isset ($ data [$ consumed + $ rdLength - 1 ])) {
155- return array ( null , null ) ;
155+ return [ null , null ] ;
156156 }
157157
158158 $ rdata = null ;
@@ -171,7 +171,7 @@ private function parseRecord($data, $consumed)
171171 } elseif (Message::TYPE_CNAME === $ type || Message::TYPE_PTR === $ type || Message::TYPE_NS === $ type ) {
172172 list ($ rdata , $ consumed ) = $ this ->readDomain ($ data , $ consumed );
173173 } elseif (Message::TYPE_TXT === $ type || Message::TYPE_SPF === $ type ) {
174- $ rdata = array () ;
174+ $ rdata = [] ;
175175 while ($ consumed < $ expected ) {
176176 $ len = ord ($ data [$ consumed ]);
177177 $ rdata [] = (string )substr ($ data , $ consumed + 1 , $ len );
@@ -182,34 +182,34 @@ private function parseRecord($data, $consumed)
182182 list ($ priority ) = array_values (unpack ('n ' , substr ($ data , $ consumed , 2 )));
183183 list ($ target , $ consumed ) = $ this ->readDomain ($ data , $ consumed + 2 );
184184
185- $ rdata = array (
185+ $ rdata = [
186186 'priority ' => $ priority ,
187187 'target ' => $ target
188- ) ;
188+ ] ;
189189 }
190190 } elseif (Message::TYPE_SRV === $ type ) {
191191 if ($ rdLength > 6 ) {
192192 list ($ priority , $ weight , $ port ) = array_values (unpack ('n* ' , substr ($ data , $ consumed , 6 )));
193193 list ($ target , $ consumed ) = $ this ->readDomain ($ data , $ consumed + 6 );
194194
195- $ rdata = array (
195+ $ rdata = [
196196 'priority ' => $ priority ,
197197 'weight ' => $ weight ,
198198 'port ' => $ port ,
199199 'target ' => $ target
200- ) ;
200+ ] ;
201201 }
202202 } elseif (Message::TYPE_SSHFP === $ type ) {
203203 if ($ rdLength > 2 ) {
204204 list ($ algorithm , $ hash ) = \array_values (\unpack ('C* ' , \substr ($ data , $ consumed , 2 )));
205205 $ fingerprint = \bin2hex (\substr ($ data , $ consumed + 2 , $ rdLength - 2 ));
206206 $ consumed += $ rdLength ;
207207
208- $ rdata = array (
208+ $ rdata = [
209209 'algorithm ' => $ algorithm ,
210210 'type ' => $ hash ,
211211 'fingerprint ' => $ fingerprint
212- ) ;
212+ ] ;
213213 }
214214 } elseif (Message::TYPE_SOA === $ type ) {
215215 list ($ mname , $ consumed ) = $ this ->readDomain ($ data , $ consumed );
@@ -219,18 +219,18 @@ private function parseRecord($data, $consumed)
219219 list ($ serial , $ refresh , $ retry , $ expire , $ minimum ) = array_values (unpack ('N* ' , substr ($ data , $ consumed , 20 )));
220220 $ consumed += 20 ;
221221
222- $ rdata = array (
222+ $ rdata = [
223223 'mname ' => $ mname ,
224224 'rname ' => $ rname ,
225225 'serial ' => $ serial ,
226226 'refresh ' => $ refresh ,
227227 'retry ' => $ retry ,
228228 'expire ' => $ expire ,
229229 'minimum ' => $ minimum
230- ) ;
230+ ] ;
231231 }
232232 } elseif (Message::TYPE_OPT === $ type ) {
233- $ rdata = array () ;
233+ $ rdata = [] ;
234234 while (isset ($ data [$ consumed + 4 - 1 ])) {
235235 list ($ code , $ length ) = array_values (unpack ('n* ' , substr ($ data , $ consumed , 4 )));
236236 $ value = (string ) substr ($ data , $ consumed + 4 , $ length );
@@ -254,11 +254,11 @@ private function parseRecord($data, $consumed)
254254 $ value = substr ($ data , $ consumed + 2 + $ tagLength , $ rdLength - 2 - $ tagLength );
255255 $ consumed += $ rdLength ;
256256
257- $ rdata = array (
257+ $ rdata = [
258258 'flag ' => $ flag ,
259259 'tag ' => $ tag ,
260260 'value ' => $ value
261- ) ;
261+ ] ;
262262 }
263263 }
264264 } else {
@@ -269,25 +269,25 @@ private function parseRecord($data, $consumed)
269269
270270 // ensure parsing record data consumes expact number of bytes indicated in record length
271271 if ($ consumed !== $ expected || $ rdata === null ) {
272- return array ( null , null ) ;
272+ return [ null , null ] ;
273273 }
274274
275- return array (
275+ return [
276276 new Record ($ name , $ type , $ class , $ ttl , $ rdata ),
277277 $ consumed
278- ) ;
278+ ] ;
279279 }
280280
281281 private function readDomain ($ data , $ consumed )
282282 {
283283 list ($ labels , $ consumed ) = $ this ->readLabels ($ data , $ consumed );
284284
285285 if ($ labels === null ) {
286- return array ( null , null ) ;
286+ return [ null , null ] ;
287287 }
288288
289289 // use escaped notation for each label part, then join using dots
290- return array (
290+ return [
291291 \implode (
292292 '. ' ,
293293 \array_map (
@@ -298,7 +298,7 @@ function ($label) {
298298 )
299299 ),
300300 $ consumed
301- ) ;
301+ ] ;
302302 }
303303
304304 /**
@@ -309,11 +309,11 @@ function ($label) {
309309 */
310310 private function readLabels ($ data , $ consumed , $ compressionDepth = 127 )
311311 {
312- $ labels = array () ;
312+ $ labels = [] ;
313313
314314 while (true ) {
315315 if (!isset ($ data [$ consumed ])) {
316- return array ( null , null ) ;
316+ return [ null , null ] ;
317317 }
318318
319319 $ length = \ord ($ data [$ consumed ]);
@@ -328,14 +328,14 @@ private function readLabels($data, $consumed, $compressionDepth = 127)
328328 if (($ length & 0xc0 ) === 0xc0 && isset ($ data [$ consumed + 1 ]) && $ compressionDepth ) {
329329 $ offset = ($ length & ~0xc0 ) << 8 | \ord ($ data [$ consumed + 1 ]);
330330 if ($ offset >= $ consumed ) {
331- return array ( null , null ) ;
331+ return [ null , null ] ;
332332 }
333333
334334 $ consumed += 2 ;
335335 list ($ newLabels ) = $ this ->readLabels ($ data , $ offset , $ compressionDepth - 1 );
336336
337337 if ($ newLabels === null ) {
338- return array ( null , null ) ;
338+ return [ null , null ] ;
339339 }
340340
341341 $ labels = array_merge ($ labels , $ newLabels );
@@ -344,13 +344,13 @@ private function readLabels($data, $consumed, $compressionDepth = 127)
344344
345345 // length MUST be 0-63 (6 bits only) and data has to be large enough
346346 if ($ length & 0xc0 || !isset ($ data [$ consumed + $ length - 1 ])) {
347- return array ( null , null ) ;
347+ return [ null , null ] ;
348348 }
349349
350350 $ labels [] = substr ($ data , $ consumed + 1 , $ length );
351351 $ consumed += $ length + 1 ;
352352 }
353353
354- return array ( $ labels , $ consumed) ;
354+ return [ $ labels , $ consumed] ;
355355 }
356356}
0 commit comments