Completed
Push — master ( 1765d7...0dda59 )
by Peter
02:32
created
src/test.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 $ranker = SPH_RANK_PROXIMITY_BM25;
75 75
 $select = '';
76 76
 
77
-for ($i = 0; $i < count($args); $i++) {
77
+for ($i = 0; $i<count($args); $i++) {
78 78
     switch ($args[$i]) {
79 79
         case '-h':
80 80
         case '--host':
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             }
169 169
             break;
170 170
         default:
171
-            $q .= $args[$i] . ' ';
171
+            $q .= $args[$i].' ';
172 172
     }
173 173
 }
174 174
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     $cl->setSelect($select);
200 200
 }
201 201
 if ($limit) {
202
-    $cl->setLimits(0, $limit,($limit>1000) ? $limit : 1000);
202
+    $cl->setLimits(0, $limit, ($limit>1000) ? $limit : 1000);
203 203
 }
204 204
 $cl->setRankingMode($ranker);
205 205
 $res = $cl->query($q, $index);
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
 // print me out
209 209
 ////////////////
210 210
 
211
-if ($res === false) {
212
-    printf('Query failed: %s.' . PHP_EOL, $cl->getLastError());
211
+if ($res===false) {
212
+    printf('Query failed: %s.'.PHP_EOL, $cl->getLastError());
213 213
 
214 214
 } else {
215 215
     if ($cl->getLastWarning()) {
216
-        printf('WARNING: %s' . PHP_EOL . PHP_EOL, $cl->getLastWarning());
216
+        printf('WARNING: %s'.PHP_EOL.PHP_EOL, $cl->getLastWarning());
217 217
     }
218 218
 
219 219
     print "Query '$q' retrieved {$res['total']} of {$res['total_found']} matches in {$res['time']} sec.\n";
220
-    print 'Query stats:' . PHP_EOL;
220
+    print 'Query stats:'.PHP_EOL;
221 221
     if (is_array($res['words'])) {
222 222
         foreach ($res['words'] as $word => $info) {
223 223
             print "    '$word' found {$info['hits']} times in {$info['docs']} documents\n";
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 
228 228
     if (is_array($res['matches'])) {
229 229
         $n = 1;
230
-        print 'Matches:' . PHP_EOL;
230
+        print 'Matches:'.PHP_EOL;
231 231
         foreach ($res['matches'] as $docinfo) {
232 232
             print "$n. doc_id={$docinfo['id']}, weight={$docinfo['weight']}";
233 233
             foreach ($res['attrs'] as $attrname => $attrtype) {
234 234
                 $value = $docinfo['attrs'][$attrname];
235
-                if ($attrtype == SPH_ATTR_MULTI || $attrtype == SPH_ATTR_MULTI64) {
236
-                    $value = '(' . join(',', $value) .')';
237
-                } elseif ($attrtype == SPH_ATTR_TIMESTAMP) {
235
+                if ($attrtype==SPH_ATTR_MULTI || $attrtype==SPH_ATTR_MULTI64) {
236
+                    $value = '('.join(',', $value).')';
237
+                } elseif ($attrtype==SPH_ATTR_TIMESTAMP) {
238 238
                     $value = date('Y-m-d H:i:s', $value);
239 239
                 }
240 240
                 print ", $attrname=$value";
Please login to merge, or discard this patch.
src/SphinxClient.php 1 patch
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -33,82 +33,82 @@  discard block
 block discarded – undo
33 33
 /////////////////////////////////////////////////////////////////////////////
34 34
 
35 35
 /// known searchd commands
36
-define('SEARCHD_COMMAND_SEARCH',     0);
37
-define('SEARCHD_COMMAND_EXCERPT',    1);
38
-define('SEARCHD_COMMAND_UPDATE',     2);
39
-define('SEARCHD_COMMAND_KEYWORDS',   3);
40
-define('SEARCHD_COMMAND_PERSIST',    4);
41
-define('SEARCHD_COMMAND_STATUS',     5);
36
+define('SEARCHD_COMMAND_SEARCH', 0);
37
+define('SEARCHD_COMMAND_EXCERPT', 1);
38
+define('SEARCHD_COMMAND_UPDATE', 2);
39
+define('SEARCHD_COMMAND_KEYWORDS', 3);
40
+define('SEARCHD_COMMAND_PERSIST', 4);
41
+define('SEARCHD_COMMAND_STATUS', 5);
42 42
 define('SEARCHD_COMMAND_FLUSHATTRS', 7);
43 43
 
44 44
 /// current client-side command implementation versions
45
-define('VER_COMMAND_SEARCH',     0x11E);
46
-define('VER_COMMAND_EXCERPT',    0x104);
47
-define('VER_COMMAND_UPDATE',     0x103);
48
-define('VER_COMMAND_KEYWORDS',   0x100);
49
-define('VER_COMMAND_STATUS',     0x101);
50
-define('VER_COMMAND_QUERY',      0x100);
45
+define('VER_COMMAND_SEARCH', 0x11E);
46
+define('VER_COMMAND_EXCERPT', 0x104);
47
+define('VER_COMMAND_UPDATE', 0x103);
48
+define('VER_COMMAND_KEYWORDS', 0x100);
49
+define('VER_COMMAND_STATUS', 0x101);
50
+define('VER_COMMAND_QUERY', 0x100);
51 51
 define('VER_COMMAND_FLUSHATTRS', 0x100);
52 52
 
53 53
 /// known searchd status codes
54
-define('SEARCHD_OK',      0);
55
-define('SEARCHD_ERROR',   1);
56
-define('SEARCHD_RETRY',   2);
54
+define('SEARCHD_OK', 0);
55
+define('SEARCHD_ERROR', 1);
56
+define('SEARCHD_RETRY', 2);
57 57
 define('SEARCHD_WARNING', 3);
58 58
 
59 59
 /// known match modes
60
-define('SPH_MATCH_ALL',       0);
61
-define('SPH_MATCH_ANY',       1);
62
-define('SPH_MATCH_PHRASE',    2);
63
-define('SPH_MATCH_BOOLEAN',   3);
64
-define('SPH_MATCH_EXTENDED',  4);
65
-define('SPH_MATCH_FULLSCAN',  5);
60
+define('SPH_MATCH_ALL', 0);
61
+define('SPH_MATCH_ANY', 1);
62
+define('SPH_MATCH_PHRASE', 2);
63
+define('SPH_MATCH_BOOLEAN', 3);
64
+define('SPH_MATCH_EXTENDED', 4);
65
+define('SPH_MATCH_FULLSCAN', 5);
66 66
 define('SPH_MATCH_EXTENDED2', 6); // extended engine V2 (TEMPORARY, WILL BE REMOVED)
67 67
 
68 68
 /// known ranking modes (ext2 only)
69 69
 define('SPH_RANK_PROXIMITY_BM25', 0); ///< default mode, phrase proximity major factor and BM25 minor one
70
-define('SPH_RANK_BM25',           1); ///< statistical mode, BM25 ranking only (faster but worse quality)
71
-define('SPH_RANK_NONE',           2); ///< no ranking, all matches get a weight of 1
72
-define('SPH_RANK_WORDCOUNT',      3); ///< simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts
73
-define('SPH_RANK_PROXIMITY',      4);
74
-define('SPH_RANK_MATCHANY',       5);
75
-define('SPH_RANK_FIELDMASK',      6);
76
-define('SPH_RANK_SPH04',          7);
77
-define('SPH_RANK_EXPR',           8);
78
-define('SPH_RANK_TOTAL',          9);
70
+define('SPH_RANK_BM25', 1); ///< statistical mode, BM25 ranking only (faster but worse quality)
71
+define('SPH_RANK_NONE', 2); ///< no ranking, all matches get a weight of 1
72
+define('SPH_RANK_WORDCOUNT', 3); ///< simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts
73
+define('SPH_RANK_PROXIMITY', 4);
74
+define('SPH_RANK_MATCHANY', 5);
75
+define('SPH_RANK_FIELDMASK', 6);
76
+define('SPH_RANK_SPH04', 7);
77
+define('SPH_RANK_EXPR', 8);
78
+define('SPH_RANK_TOTAL', 9);
79 79
 
80 80
 /// known sort modes
81
-define('SPH_SORT_RELEVANCE',     0);
82
-define('SPH_SORT_ATTR_DESC',     1);
83
-define('SPH_SORT_ATTR_ASC',      2);
81
+define('SPH_SORT_RELEVANCE', 0);
82
+define('SPH_SORT_ATTR_DESC', 1);
83
+define('SPH_SORT_ATTR_ASC', 2);
84 84
 define('SPH_SORT_TIME_SEGMENTS', 3);
85
-define('SPH_SORT_EXTENDED',      4);
86
-define('SPH_SORT_EXPR',          5);
85
+define('SPH_SORT_EXTENDED', 4);
86
+define('SPH_SORT_EXPR', 5);
87 87
 
88 88
 /// known filter types
89
-define('SPH_FILTER_VALUES',     0);
90
-define('SPH_FILTER_RANGE',      1);
89
+define('SPH_FILTER_VALUES', 0);
90
+define('SPH_FILTER_RANGE', 1);
91 91
 define('SPH_FILTER_FLOATRANGE', 2);
92
-define('SPH_FILTER_STRING',     3);
92
+define('SPH_FILTER_STRING', 3);
93 93
 
94 94
 /// known attribute types
95
-define('SPH_ATTR_INTEGER',   1);
95
+define('SPH_ATTR_INTEGER', 1);
96 96
 define('SPH_ATTR_TIMESTAMP', 2);
97
-define('SPH_ATTR_ORDINAL',   3);
98
-define('SPH_ATTR_BOOL',      4);
99
-define('SPH_ATTR_FLOAT',     5);
100
-define('SPH_ATTR_BIGINT',    6);
101
-define('SPH_ATTR_STRING',    7);
102
-define('SPH_ATTR_FACTORS',   1001);
103
-define('SPH_ATTR_MULTI',     0x40000001);
104
-define('SPH_ATTR_MULTI64',   0x40000002);
97
+define('SPH_ATTR_ORDINAL', 3);
98
+define('SPH_ATTR_BOOL', 4);
99
+define('SPH_ATTR_FLOAT', 5);
100
+define('SPH_ATTR_BIGINT', 6);
101
+define('SPH_ATTR_STRING', 7);
102
+define('SPH_ATTR_FACTORS', 1001);
103
+define('SPH_ATTR_MULTI', 0x40000001);
104
+define('SPH_ATTR_MULTI64', 0x40000002);
105 105
 
106 106
 /// known grouping functions
107
-define('SPH_GROUPBY_DAY',      0);
108
-define('SPH_GROUPBY_WEEK',     1);
109
-define('SPH_GROUPBY_MONTH',    2);
110
-define('SPH_GROUPBY_YEAR',     3);
111
-define('SPH_GROUPBY_ATTR',     4);
107
+define('SPH_GROUPBY_DAY', 0);
108
+define('SPH_GROUPBY_WEEK', 1);
109
+define('SPH_GROUPBY_MONTH', 2);
110
+define('SPH_GROUPBY_YEAR', 3);
111
+define('SPH_GROUPBY_ATTR', 4);
112 112
 define('SPH_GROUPBY_ATTRPAIR', 5);
113 113
 
114 114
 // important properties of PHP's integers:
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
     assert(is_numeric($v));
144 144
 
145 145
     // x64
146
-    if (PHP_INT_SIZE >= 8) {
146
+    if (PHP_INT_SIZE>=8) {
147 147
         $v = (int)$v;
148 148
         return pack('NN', $v >> 32, $v & 0xFFFFFFFF);
149 149
     }
150 150
 
151 151
     // x32, int
152 152
     if (is_int($v)) {
153
-        return pack('NN', $v < 0 ? -1 : 0, $v);
153
+        return pack('NN', $v<0 ? -1 : 0, $v);
154 154
     }
155 155
 
156 156
     // x32, bcmath
157 157
     if (function_exists('bcmul')) {
158
-        if (bccomp($v, 0) == -1) {
158
+        if (bccomp($v, 0)==-1) {
159 159
             $v = bcadd('18446744073709551616', $v);
160 160
         }
161 161
         $h = bcdiv($v, '4294967296', 0);
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
     $l = $m - ($q * 4294967296.0);
174 174
     $h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328
175 175
 
176
-    if ($v < 0) {
177
-        if ($l == 0) {
176
+    if ($v<0) {
177
+        if ($l==0) {
178 178
             $h = 4294967296.0 - $h;
179 179
         } else {
180 180
             $h = 4294967295.0 - $h;
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
     assert(is_numeric($v));
191 191
 
192 192
     // x64
193
-    if (PHP_INT_SIZE >= 8) {
194
-        assert($v >= 0);
193
+    if (PHP_INT_SIZE>=8) {
194
+        assert($v>=0);
195 195
 
196 196
         // x64, int
197 197
         if (is_int($v)) {
@@ -247,16 +247,16 @@  discard block
 block discarded – undo
247 247
 {
248 248
     list($hi, $lo) = array_values(unpack('N*N*', $v));
249 249
 
250
-    if (PHP_INT_SIZE >= 8) {
251
-        if ($hi < 0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
250
+    if (PHP_INT_SIZE>=8) {
251
+        if ($hi<0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
252 252
             $hi += 1 << 32;
253 253
         }
254
-        if ($lo < 0) {
254
+        if ($lo<0) {
255 255
             $lo += 1 << 32;
256 256
         }
257 257
 
258 258
         // x64, int
259
-        if ($hi <= 2147483647) {
259
+        if ($hi<=2147483647) {
260 260
             return ($hi << 32) + $lo;
261 261
         }
262 262
 
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
         $C = 100000;
270 270
         $h = ((int)($hi / $C) << 32) + (int)($lo / $C);
271 271
         $l = (($hi % $C) << 32) + ($lo % $C);
272
-        if ($l > $C) {
272
+        if ($l>$C) {
273 273
             $h += (int)($l / $C);
274 274
             $l  = $l % $C;
275 275
         }
276 276
 
277
-        if ($h == 0) {
277
+        if ($h==0) {
278 278
             return $l;
279 279
         }
280 280
         return sprintf('%d%05d', $h, $l);
281 281
     }
282 282
 
283 283
     // x32, int
284
-    if ($hi == 0) {
285
-        if ($lo > 0) {
284
+    if ($hi==0) {
285
+        if ($lo>0) {
286 286
             return $lo;
287 287
         }
288 288
         return sprintf('%u', $lo);
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 
310 310
     $h = sprintf('%.0f', $h);
311 311
     $l = sprintf('%07.0f', $l);
312
-    if ($h == '0') {
312
+    if ($h=='0') {
313 313
         return sprintf('%.0f', (float)$l);
314 314
     }
315
-    return $h . $l;
315
+    return $h.$l;
316 316
 }
317 317
 
318 318
 // unpack 64-bit signed
@@ -321,24 +321,24 @@  discard block
 block discarded – undo
321 321
     list($hi, $lo) = array_values(unpack('N*N*', $v));
322 322
 
323 323
     // x64
324
-    if (PHP_INT_SIZE >= 8) {
325
-        if ($hi < 0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
324
+    if (PHP_INT_SIZE>=8) {
325
+        if ($hi<0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
326 326
             $hi += 1 << 32;
327 327
         }
328
-        if ($lo < 0) {
328
+        if ($lo<0) {
329 329
             $lo += 1 << 32;
330 330
         }
331 331
 
332 332
         return ($hi << 32) + $lo;
333 333
     }
334 334
 
335
-    if ($hi == 0) { // x32, int
336
-        if ($lo > 0) {
335
+    if ($hi==0) { // x32, int
336
+        if ($lo>0) {
337 337
             return $lo;
338 338
         }
339 339
         return sprintf('%u', $lo);
340
-    } elseif ($hi == -1) { // x32, int
341
-        if ($lo < 0) {
340
+    } elseif ($hi==-1) { // x32, int
341
+        if ($lo<0) {
342 342
             return $lo;
343 343
         }
344 344
         return sprintf('%.0f', $lo - 4294967296.0);
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 
347 347
     $neg = '';
348 348
     $c = 0;
349
-    if ($hi < 0) {
349
+    if ($hi<0) {
350 350
         $hi = ~$hi;
351 351
         $lo = ~$lo;
352 352
         $c = 1;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 
359 359
     // x32, bcmath
360 360
     if (function_exists('bcmul')) {
361
-        return $neg . bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c);
361
+        return $neg.bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c);
362 362
     }
363 363
 
364 364
     // x32, no-bcmath
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
     $mq = floor($m / 10000000.0);
372 372
     $l = $m - $mq * 10000000.0 + $c;
373 373
     $h = $q * 4294967296.0 + $r * 429.0 + $mq;
374
-    if ($l == 10000000) {
374
+    if ($l==10000000) {
375 375
         $l = 0;
376 376
         $h += 1;
377 377
     }
378 378
 
379 379
     $h = sprintf('%.0f', $h);
380 380
     $l = sprintf('%07.0f', $l);
381
-    if ($h == '0') {
382
-        return $neg . sprintf('%.0f', (float)$l);
381
+    if ($h=='0') {
382
+        return $neg.sprintf('%.0f', (float)$l);
383 383
     }
384
-    return $neg . $h . $l;
384
+    return $neg.$h.$l;
385 385
 }
386 386
 
387 387
 
388 388
 function sphFixUint($value)
389 389
 {
390
-    if (PHP_INT_SIZE >= 8) {
390
+    if (PHP_INT_SIZE>=8) {
391 391
         // x64 route, workaround broken unpack() in 5.2.2+
392
-        if ($value < 0) {
392
+        if ($value<0) {
393 393
             $value += 1 << 32;
394 394
         }
395 395
         return $value;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
         $this->warning = '';
508 508
         $this->connerror = false;
509 509
 
510
-        $this->reqs = array();// requests storage (for multi-query case)
510
+        $this->reqs = array(); // requests storage (for multi-query case)
511 511
         $this->mbenc = '';
512 512
         $this->arrayresult = false;
513 513
         $this->timeout = 0;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 
516 516
     public function __destruct()
517 517
     {
518
-        if ($this->_socket !== false) {
518
+        if ($this->_socket!==false) {
519 519
             fclose($this->_socket);
520 520
         }
521 521
     }
@@ -542,19 +542,19 @@  discard block
 block discarded – undo
542 542
     public function setServer($host, $port = 0)
543 543
     {
544 544
         assert(is_string($host));
545
-        if ($host[0] == '/') {
546
-            $this->_path = 'unix://' . $host;
545
+        if ($host[0]=='/') {
546
+            $this->_path = 'unix://'.$host;
547 547
             return;
548 548
         }
549
-        if (substr($host, 0, 7) == 'unix://') {
549
+        if (substr($host, 0, 7)=='unix://') {
550 550
             $this->_path = $host;
551 551
             return;
552 552
         }
553 553
 
554 554
         $this->host = $host;
555 555
         $port = intval($port);
556
-        assert(0 <= $port && $port < 65536);
557
-        $this->port = $port == 0 ? 9312 : $port;
556
+        assert(0<=$port && $port<65536);
557
+        $this->port = $port==0 ? 9312 : $port;
558 558
         $this->_path = '';
559 559
     }
560 560
 
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 
569 569
     protected function send($handle, $data, $length)
570 570
     {
571
-        if (feof($handle) || fwrite($handle, $data, $length) !== $length) {
571
+        if (feof($handle) || fwrite($handle, $data, $length)!==$length) {
572 572
             $this->error = 'connection unexpectedly closed (timed out?)';
573 573
             $this->connerror = true;
574 574
             return false;
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
     /// connect to searchd server
600 600
     protected function connect()
601 601
     {
602
-        if ($this->_socket !== false) {
602
+        if ($this->_socket!==false) {
603 603
             // we are in persistent connection mode, so we have a socket
604 604
             // however, need to check whether it's still alive
605 605
             if (!@feof($this->_socket)) {
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             $port = $this->port;
623 623
         }
624 624
 
625
-        if ($this->timeout <= 0) {
625
+        if ($this->timeout<=0) {
626 626
             $fp = @fsockopen($host, $port, $errno, $errstr);
627 627
         } else {
628 628
             $fp = @fsockopen($host, $port, $errno, $errstr, $this->timeout);
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
         // check version
655 655
         list(, $v) = unpack('N*', fread($fp, 4));
656 656
         $v = (int)$v;
657
-        if ($v < 1) {
657
+        if ($v<1) {
658 658
             fclose($fp);
659 659
             $this->error = "expected searchd protocol version 1+, got version '$v'";
660 660
             return false;
@@ -670,10 +670,10 @@  discard block
 block discarded – undo
670 670
         $len = 0;
671 671
 
672 672
         $header = fread($fp, 8);
673
-        if (strlen($header) == 8) {
673
+        if (strlen($header)==8) {
674 674
             list($status, $ver, $len) = array_values(unpack('n2a/Nb', $header));
675 675
             $left = $len;
676
-            while ($left > 0 && !feof($fp)) {
676
+            while ($left>0 && !feof($fp)) {
677 677
                 $chunk = fread($fp, min(8192, $left));
678 678
                 if ($chunk) {
679 679
                     $response .= $chunk;
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
                 }
682 682
             }
683 683
         }
684
-        if ($this->_socket === false) {
684
+        if ($this->_socket===false) {
685 685
             fclose($fp);
686 686
         }
687 687
 
688 688
         // check response
689 689
         $read = strlen($response);
690
-        if (!$response || $read != $len) {
690
+        if (!$response || $read!=$len) {
691 691
             $this->error = $len
692 692
                 ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)"
693 693
                 : 'received zero-sized searchd response';
@@ -695,26 +695,26 @@  discard block
 block discarded – undo
695 695
         }
696 696
 
697 697
         // check status
698
-        if ($status == SEARCHD_WARNING) {
698
+        if ($status==SEARCHD_WARNING) {
699 699
             list(, $wlen) = unpack('N*', substr($response, 0, 4));
700 700
             $this->warning = substr($response, 4, $wlen);
701 701
             return substr($response, 4 + $wlen);
702 702
         }
703
-        if ($status == SEARCHD_ERROR) {
704
-            $this->error = 'searchd error: ' . substr($response, 4);
703
+        if ($status==SEARCHD_ERROR) {
704
+            $this->error = 'searchd error: '.substr($response, 4);
705 705
             return false;
706 706
         }
707
-        if ($status == SEARCHD_RETRY) {
708
-            $this->error = 'temporary searchd error: ' . substr($response, 4);
707
+        if ($status==SEARCHD_RETRY) {
708
+            $this->error = 'temporary searchd error: '.substr($response, 4);
709 709
             return false;
710 710
         }
711
-        if ($status != SEARCHD_OK) {
711
+        if ($status!=SEARCHD_OK) {
712 712
             $this->error = "unknown status code '$status'";
713 713
             return false;
714 714
         }
715 715
 
716 716
         // check version
717
-        if ($ver < $client_ver) {
717
+        if ($ver<$client_ver) {
718 718
             $this->warning = sprintf(
719 719
                 'searchd command v.%d.%d older than client\'s v.%d.%d, some options might not work',
720 720
                 $ver >> 8,
@@ -737,15 +737,15 @@  discard block
 block discarded – undo
737 737
     {
738 738
         assert(is_int($offset));
739 739
         assert(is_int($limit));
740
-        assert($offset >= 0);
741
-        assert($limit > 0);
742
-        assert($max >= 0);
740
+        assert($offset>=0);
741
+        assert($limit>0);
742
+        assert($max>=0);
743 743
         $this->offset = $offset;
744 744
         $this->limit = $limit;
745
-        if ($max > 0) {
745
+        if ($max>0) {
746 746
             $this->maxmatches = $max;
747 747
         }
748
-        if ($cutoff > 0) {
748
+        if ($cutoff>0) {
749 749
             $this->cutoff = $cutoff;
750 750
         }
751 751
     }
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
     public function setMaxQueryTime($max)
756 756
     {
757 757
         assert(is_int($max));
758
-        assert($max >= 0);
758
+        assert($max>=0);
759 759
         $this->maxquerytime = $max;
760 760
     }
761 761
 
@@ -767,21 +767,21 @@  discard block
 block discarded – undo
767 767
             E_USER_DEPRECATED
768 768
         );
769 769
         assert(
770
-            $mode == SPH_MATCH_ALL ||
771
-            $mode == SPH_MATCH_ANY ||
772
-            $mode == SPH_MATCH_PHRASE ||
773
-            $mode == SPH_MATCH_BOOLEAN ||
774
-            $mode == SPH_MATCH_EXTENDED ||
775
-            $mode == SPH_MATCH_FULLSCAN ||
776
-            $mode == SPH_MATCH_EXTENDED2
770
+            $mode==SPH_MATCH_ALL ||
771
+            $mode==SPH_MATCH_ANY ||
772
+            $mode==SPH_MATCH_PHRASE ||
773
+            $mode==SPH_MATCH_BOOLEAN ||
774
+            $mode==SPH_MATCH_EXTENDED ||
775
+            $mode==SPH_MATCH_FULLSCAN ||
776
+            $mode==SPH_MATCH_EXTENDED2
777 777
         );
778 778
         $this->mode = $mode;
779 779
     }
780 780
 
781 781
     /// set ranking mode
782
-    public function setRankingMode($ranker, $rankexpr='')
782
+    public function setRankingMode($ranker, $rankexpr = '')
783 783
     {
784
-        assert($ranker === 0 || $ranker >= 1 && $ranker < SPH_RANK_TOTAL);
784
+        assert($ranker===0 || $ranker>=1 && $ranker<SPH_RANK_TOTAL);
785 785
         assert(is_string($rankexpr));
786 786
         $this->ranker = $ranker;
787 787
         $this->rankexpr = $rankexpr;
@@ -790,16 +790,16 @@  discard block
 block discarded – undo
790 790
     /// set matches sorting mode
791 791
     public function setSortMode($mode, $sortby = '')
792 792
     {
793
-        assert (
794
-            $mode == SPH_SORT_RELEVANCE ||
795
-            $mode == SPH_SORT_ATTR_DESC ||
796
-            $mode == SPH_SORT_ATTR_ASC ||
797
-            $mode == SPH_SORT_TIME_SEGMENTS ||
798
-            $mode == SPH_SORT_EXTENDED ||
799
-            $mode == SPH_SORT_EXPR
793
+        assert(
794
+            $mode==SPH_SORT_RELEVANCE ||
795
+            $mode==SPH_SORT_ATTR_DESC ||
796
+            $mode==SPH_SORT_ATTR_ASC ||
797
+            $mode==SPH_SORT_TIME_SEGMENTS ||
798
+            $mode==SPH_SORT_EXTENDED ||
799
+            $mode==SPH_SORT_EXPR
800 800
         );
801 801
         assert(is_string($sortby));
802
-        assert($mode == SPH_SORT_RELEVANCE || strlen($sortby) > 0);
802
+        assert($mode==SPH_SORT_RELEVANCE || strlen($sortby)>0);
803 803
 
804 804
         $this->sort = $mode;
805 805
         $this->sortby = $sortby;
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
     {
841 841
         assert(is_numeric($min));
842 842
         assert(is_numeric($max));
843
-        assert($min <= $max);
843
+        assert($min<=$max);
844 844
         $this->min_id = $min;
845 845
         $this->max_id = $max;
846 846
     }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
         assert(is_string($attribute));
889 889
         assert(is_numeric($min));
890 890
         assert(is_numeric($max));
891
-        assert($min <= $max);
891
+        assert($min<=$max);
892 892
 
893 893
         $this->filters[] = array(
894 894
             'type' => SPH_FILTER_RANGE,
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
         assert(is_string($attribute));
907 907
         assert(is_float($min));
908 908
         assert(is_float($max));
909
-        assert($min <= $max);
909
+        assert($min<=$max);
910 910
 
911 911
         $this->filters[] = array(
912 912
             'type' => SPH_FILTER_FLOATRANGE,
@@ -941,12 +941,12 @@  discard block
 block discarded – undo
941 941
         assert(is_string($attribute));
942 942
         assert(is_string($groupsort));
943 943
         assert(
944
-            $func == SPH_GROUPBY_DAY ||
945
-            $func == SPH_GROUPBY_WEEK ||
946
-            $func == SPH_GROUPBY_MONTH ||
947
-            $func == SPH_GROUPBY_YEAR ||
948
-            $func == SPH_GROUPBY_ATTR ||
949
-            $func == SPH_GROUPBY_ATTRPAIR
944
+            $func==SPH_GROUPBY_DAY ||
945
+            $func==SPH_GROUPBY_WEEK ||
946
+            $func==SPH_GROUPBY_MONTH ||
947
+            $func==SPH_GROUPBY_YEAR ||
948
+            $func==SPH_GROUPBY_ATTR ||
949
+            $func==SPH_GROUPBY_ATTRPAIR
950 950
         );
951 951
 
952 952
         $this->groupby = $attribute;
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
     /// set distributed retries count and delay
965 965
     public function setRetries($count, $delay = 0)
966 966
     {
967
-        assert(is_int($count) && $count >= 0);
968
-        assert(is_int($delay) && $delay >= 0);
967
+        assert(is_int($count) && $count>=0);
968
+        assert(is_int($delay) && $delay>=0);
969 969
         $this->retrycount = $count;
970 970
         $this->retrydelay = $delay;
971 971
     }
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
             'global_idf',
1023 1023
             'low_priority'
1024 1024
         );
1025
-        $flags = array (
1025
+        $flags = array(
1026 1026
             'reverse_scan' => array(0, 1),
1027 1027
             'sort_method' => array('pq', 'kbuffer'),
1028 1028
             'max_predicted_time' => array(0),
1029 1029
             'boolean_simplify' => array(true, false),
1030
-            'idf' => array ('normalized', 'plain', 'tfidf_normalized', 'tfidf_unnormalized'),
1030
+            'idf' => array('normalized', 'plain', 'tfidf_normalized', 'tfidf_unnormalized'),
1031 1031
             'global_idf' => array(true, false),
1032 1032
             'low_priority' => array(true, false)
1033 1033
         );
@@ -1035,32 +1035,32 @@  discard block
 block discarded – undo
1035 1035
         assert(isset($flag_name, $known_names));
1036 1036
         assert(
1037 1037
             in_array($flag_value, $flags[$flag_name], true) ||
1038
-            ($flag_name == 'max_predicted_time' && is_int($flag_value) && $flag_value >= 0)
1038
+            ($flag_name=='max_predicted_time' && is_int($flag_value) && $flag_value>=0)
1039 1039
         );
1040 1040
 
1041
-        if ($flag_name == 'reverse_scan') {
1042
-            $this->query_flags = sphSetBit($this->query_flags, 0, $flag_value == 1);
1041
+        if ($flag_name=='reverse_scan') {
1042
+            $this->query_flags = sphSetBit($this->query_flags, 0, $flag_value==1);
1043 1043
         }
1044
-        if ($flag_name == 'sort_method') {
1045
-            $this->query_flags = sphSetBit($this->query_flags, 1, $flag_value == 'kbuffer');
1044
+        if ($flag_name=='sort_method') {
1045
+            $this->query_flags = sphSetBit($this->query_flags, 1, $flag_value=='kbuffer');
1046 1046
         }
1047
-        if ($flag_name == 'max_predicted_time') {
1048
-            $this->query_flags = sphSetBit($this->query_flags, 2, $flag_value > 0);
1047
+        if ($flag_name=='max_predicted_time') {
1048
+            $this->query_flags = sphSetBit($this->query_flags, 2, $flag_value>0);
1049 1049
             $this->predictedtime = (int)$flag_value;
1050 1050
         }
1051
-        if ($flag_name == 'boolean_simplify') {
1051
+        if ($flag_name=='boolean_simplify') {
1052 1052
             $this->query_flags = sphSetBit($this->query_flags, 3, $flag_value);
1053 1053
         }
1054
-        if ($flag_name == 'idf' && ($flag_value == 'normalized' || $flag_value == 'plain')) {
1055
-            $this->query_flags = sphSetBit($this->query_flags, 4, $flag_value == 'plain');
1054
+        if ($flag_name=='idf' && ($flag_value=='normalized' || $flag_value=='plain')) {
1055
+            $this->query_flags = sphSetBit($this->query_flags, 4, $flag_value=='plain');
1056 1056
         }
1057
-        if ($flag_name == 'global_idf') {
1057
+        if ($flag_name=='global_idf') {
1058 1058
             $this->query_flags = sphSetBit($this->query_flags, 5, $flag_value);
1059 1059
         }
1060
-        if ($flag_name == 'idf' && ($flag_value == 'tfidf_normalized' || $flag_value == 'tfidf_unnormalized')) {
1061
-            $this->query_flags = sphSetBit($this->query_flags, 6, $flag_value == 'tfidf_normalized');
1060
+        if ($flag_name=='idf' && ($flag_value=='tfidf_normalized' || $flag_value=='tfidf_unnormalized')) {
1061
+            $this->query_flags = sphSetBit($this->query_flags, 6, $flag_value=='tfidf_normalized');
1062 1062
         }
1063
-        if ($flag_name == 'low_priority') {
1063
+        if ($flag_name=='low_priority') {
1064 1064
             $this->query_flags = sphSetBit($this->query_flags, 8, $flag_value);
1065 1065
         }
1066 1066
     }
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
         assert(is_string($orderby));
1072 1072
         assert(is_int($offset));
1073 1073
         assert(is_int($limit));
1074
-        assert($offset >= 0);
1075
-        assert($limit > 0);
1074
+        assert($offset>=0);
1075
+        assert($limit>0);
1076 1076
 
1077 1077
         $this->outerorderby = $orderby;
1078 1078
         $this->outeroffset = $offset;
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 
1138 1138
         $this->error = $results[0]['error'];
1139 1139
         $this->warning = $results[0]['warning'];
1140
-        if ($results[0]['status'] == SEARCHD_ERROR) {
1140
+        if ($results[0]['status']==SEARCHD_ERROR) {
1141 1141
             return false;
1142 1142
         } else {
1143 1143
             return $results[0];
@@ -1161,24 +1161,24 @@  discard block
 block discarded – undo
1161 1161
 
1162 1162
         // build request
1163 1163
         $req = pack('NNNNN', $this->query_flags, $this->offset, $this->limit, $this->mode, $this->ranker);
1164
-        if ($this->ranker == SPH_RANK_EXPR) {
1165
-            $req .= pack('N', strlen($this->rankexpr)) . $this->rankexpr;
1164
+        if ($this->ranker==SPH_RANK_EXPR) {
1165
+            $req .= pack('N', strlen($this->rankexpr)).$this->rankexpr;
1166 1166
         }
1167 1167
         $req .= pack('N', $this->sort); // (deprecated) sort mode
1168
-        $req .= pack('N', strlen($this->sortby)) . $this->sortby;
1169
-        $req .= pack('N', strlen($query)) . $query; // query itself
1168
+        $req .= pack('N', strlen($this->sortby)).$this->sortby;
1169
+        $req .= pack('N', strlen($query)).$query; // query itself
1170 1170
         $req .= pack('N', count($this->weights)); // weights
1171 1171
         foreach ($this->weights as $weight) {
1172 1172
             $req .= pack('N', (int)$weight);
1173 1173
         }
1174
-        $req .= pack('N', strlen($index)) . $index; // indexes
1174
+        $req .= pack('N', strlen($index)).$index; // indexes
1175 1175
         $req .= pack('N', 1); // id64 range marker
1176
-        $req .= sphPackU64($this->min_id) . sphPackU64($this->max_id); // id64 range
1176
+        $req .= sphPackU64($this->min_id).sphPackU64($this->max_id); // id64 range
1177 1177
 
1178 1178
         // filters
1179 1179
         $req .= pack('N', count($this->filters));
1180 1180
         foreach ($this->filters as $filter) {
1181
-            $req .= pack('N', strlen($filter['attr'])) . $filter['attr'];
1181
+            $req .= pack('N', strlen($filter['attr'])).$filter['attr'];
1182 1182
             $req .= pack('N', $filter['type']);
1183 1183
             switch ($filter['type']) {
1184 1184
                 case SPH_FILTER_VALUES:
@@ -1188,13 +1188,13 @@  discard block
 block discarded – undo
1188 1188
                     }
1189 1189
                     break;
1190 1190
                 case SPH_FILTER_RANGE:
1191
-                    $req .= sphPackI64($filter['min']) . sphPackI64($filter['max']);
1191
+                    $req .= sphPackI64($filter['min']).sphPackI64($filter['max']);
1192 1192
                     break;
1193 1193
                 case SPH_FILTER_FLOATRANGE:
1194
-                    $req .= $this->packFloat($filter['min']) . $this->packFloat($filter['max']);
1194
+                    $req .= $this->packFloat($filter['min']).$this->packFloat($filter['max']);
1195 1195
                     break;
1196 1196
                 case SPH_FILTER_STRING:
1197
-                    $req .= pack('N', strlen($filter['value'])) . $filter['value'];
1197
+                    $req .= pack('N', strlen($filter['value'])).$filter['value'];
1198 1198
                     break;
1199 1199
                 default:
1200 1200
                     assert(0 && 'internal error: unhandled filter type');
@@ -1203,27 +1203,27 @@  discard block
 block discarded – undo
1203 1203
         }
1204 1204
 
1205 1205
         // group-by clause, max-matches count, group-sort clause, cutoff count
1206
-        $req .= pack('NN', $this->groupfunc, strlen($this->groupby)) . $this->groupby;
1206
+        $req .= pack('NN', $this->groupfunc, strlen($this->groupby)).$this->groupby;
1207 1207
         $req .= pack('N', $this->maxmatches);
1208
-        $req .= pack('N', strlen($this->groupsort)) . $this->groupsort;
1208
+        $req .= pack('N', strlen($this->groupsort)).$this->groupsort;
1209 1209
         $req .= pack('NNN', $this->cutoff, $this->retrycount, $this->retrydelay);
1210
-        $req .= pack('N', strlen($this->groupdistinct)) . $this->groupdistinct;
1210
+        $req .= pack('N', strlen($this->groupdistinct)).$this->groupdistinct;
1211 1211
 
1212 1212
         // anchor point
1213 1213
         if (empty($this->anchor)) {
1214 1214
             $req .= pack('N', 0);
1215 1215
         } else {
1216
-            $a =& $this->anchor;
1216
+            $a = & $this->anchor;
1217 1217
             $req .= pack('N', 1);
1218
-            $req .= pack('N', strlen($a['attrlat'])) . $a['attrlat'];
1219
-            $req .= pack('N', strlen($a['attrlong'])) . $a['attrlong'];
1220
-            $req .= $this->packFloat($a['lat']) . $this->packFloat($a['long']);
1218
+            $req .= pack('N', strlen($a['attrlat'])).$a['attrlat'];
1219
+            $req .= pack('N', strlen($a['attrlong'])).$a['attrlong'];
1220
+            $req .= $this->packFloat($a['lat']).$this->packFloat($a['long']);
1221 1221
         }
1222 1222
 
1223 1223
         // per-index weights
1224 1224
         $req .= pack('N', count($this->indexweights));
1225 1225
         foreach ($this->indexweights as $idx => $weight) {
1226
-            $req .= pack('N', strlen($idx)) . $idx . pack('N', $weight);
1226
+            $req .= pack('N', strlen($idx)).$idx.pack('N', $weight);
1227 1227
         }
1228 1228
 
1229 1229
         // max query time
@@ -1232,16 +1232,16 @@  discard block
 block discarded – undo
1232 1232
         // per-field weights
1233 1233
         $req .= pack('N', count($this->fieldweights));
1234 1234
         foreach ($this->fieldweights as $field => $weight) {
1235
-            $req .= pack('N', strlen($field)) . $field . pack('N', $weight);
1235
+            $req .= pack('N', strlen($field)).$field.pack('N', $weight);
1236 1236
         }
1237 1237
 
1238 1238
         // comment
1239
-        $req .= pack('N', strlen($comment)) . $comment;
1239
+        $req .= pack('N', strlen($comment)).$comment;
1240 1240
 
1241 1241
         // attribute overrides
1242 1242
         $req .= pack('N', count($this->overrides));
1243 1243
         foreach ($this->overrides as $key => $entry) {
1244
-            $req .= pack('N', strlen($entry['attr'])) . $entry['attr'];
1244
+            $req .= pack('N', strlen($entry['attr'])).$entry['attr'];
1245 1245
             $req .= pack('NN', $entry['type'], count($entry['values']));
1246 1246
             foreach ($entry['values'] as $id => $val) {
1247 1247
                 assert(is_numeric($id));
@@ -1263,14 +1263,14 @@  discard block
 block discarded – undo
1263 1263
         }
1264 1264
 
1265 1265
         // select-list
1266
-        $req .= pack('N', strlen($this->select)) . $this->select;
1266
+        $req .= pack('N', strlen($this->select)).$this->select;
1267 1267
 
1268 1268
         // max_predicted_time
1269
-        if ($this->predictedtime > 0) {
1269
+        if ($this->predictedtime>0) {
1270 1270
             $req .= pack('N', (int)$this->predictedtime);
1271 1271
         }
1272 1272
 
1273
-        $req .= pack('N', strlen($this->outerorderby)) . $this->outerorderby;
1273
+        $req .= pack('N', strlen($this->outerorderby)).$this->outerorderby;
1274 1274
         $req .= pack('NN', $this->outeroffset, $this->outerlimit);
1275 1275
         if ($this->hasouter) {
1276 1276
             $req .= pack('N', 1);
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
         $nreqs = count($this->reqs);
1307 1307
         $req = join('', $this->reqs);
1308 1308
         $len = 8 + strlen($req);
1309
-        $req = pack('nnNNN', SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs) . $req; // add header
1309
+        $req = pack('nnNNN', SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs).$req; // add header
1310 1310
 
1311 1311
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, VER_COMMAND_SEARCH))) {
1312 1312
             $this->mbPop();
@@ -1327,9 +1327,9 @@  discard block
 block discarded – undo
1327 1327
         $max = strlen($response); // max position for checks, to protect against broken responses
1328 1328
 
1329 1329
         $results = array();
1330
-        for ($ires = 0; $ires < $nreqs && $p < $max; $ires++) {
1330
+        for ($ires = 0; $ires<$nreqs && $p<$max; $ires++) {
1331 1331
             $results[] = array();
1332
-            $result =& $results[$ires];
1332
+            $result = & $results[$ires];
1333 1333
 
1334 1334
             $result['error'] = '';
1335 1335
             $result['warning'] = '';
@@ -1338,13 +1338,13 @@  discard block
 block discarded – undo
1338 1338
             list(, $status) = unpack('N*', substr($response, $p, 4));
1339 1339
             $p += 4;
1340 1340
             $result['status'] = $status;
1341
-            if ($status != SEARCHD_OK) {
1341
+            if ($status!=SEARCHD_OK) {
1342 1342
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1343 1343
                 $p += 4;
1344 1344
                 $message = substr($response, $p, $len);
1345 1345
                 $p += $len;
1346 1346
 
1347
-                if ($status == SEARCHD_WARNING) {
1347
+                if ($status==SEARCHD_WARNING) {
1348 1348
                     $result['warning'] = $message;
1349 1349
                 } else {
1350 1350
                     $result['error'] = $message;
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 
1359 1359
             list(, $nfields) = unpack('N*', substr($response, $p, 4));
1360 1360
             $p += 4;
1361
-            while ($nfields --> 0 && $p < $max) {
1361
+            while ($nfields-->0 && $p<$max) {
1362 1362
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1363 1363
                 $p += 4;
1364 1364
                 $fields[] = substr($response, $p, $len);
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
 
1369 1369
             list(, $nattrs) = unpack('N*', substr($response, $p, 4));
1370 1370
             $p += 4;
1371
-            while ($nattrs --> 0 && $p < $max) {
1371
+            while ($nattrs-->0 && $p<$max) {
1372 1372
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1373 1373
                 $p += 4;
1374 1374
                 $attr = substr($response, $p, $len);
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 
1388 1388
             // read matches
1389 1389
             $idx = -1;
1390
-            while ($count --> 0 && $p < $max) {
1390
+            while ($count-->0 && $p<$max) {
1391 1391
                 // index into result array
1392 1392
                 $idx++;
1393 1393
 
@@ -1415,14 +1415,14 @@  discard block
 block discarded – undo
1415 1415
                 $attrvals = array();
1416 1416
                 foreach ($attrs as $attr => $type) {
1417 1417
                     // handle 64bit ints
1418
-                    if ($type == SPH_ATTR_BIGINT) {
1418
+                    if ($type==SPH_ATTR_BIGINT) {
1419 1419
                         $attrvals[$attr] = sphUnpackI64(substr($response, $p, 8));
1420 1420
                         $p += 8;
1421 1421
                         continue;
1422 1422
                     }
1423 1423
 
1424 1424
                     // handle floats
1425
-                    if ($type == SPH_ATTR_FLOAT) {
1425
+                    if ($type==SPH_ATTR_FLOAT) {
1426 1426
                         list(, $uval) = unpack('N*', substr($response, $p, 4));
1427 1427
                         $p += 4;
1428 1428
                         list(, $fval) = unpack('f*', pack('L', $uval));
@@ -1433,28 +1433,28 @@  discard block
 block discarded – undo
1433 1433
                     // handle everything else as unsigned ints
1434 1434
                     list(, $val) = unpack('N*', substr($response, $p, 4));
1435 1435
                     $p += 4;
1436
-                    if ($type == SPH_ATTR_MULTI) {
1436
+                    if ($type==SPH_ATTR_MULTI) {
1437 1437
                         $attrvals[$attr] = array();
1438 1438
                         $nvalues = $val;
1439
-                        while ($nvalues --> 0 && $p < $max) {
1439
+                        while ($nvalues-->0 && $p<$max) {
1440 1440
                             list(, $val) = unpack('N*', substr($response, $p, 4));
1441 1441
                             $p += 4;
1442 1442
                             $attrvals[$attr][] = sphFixUint($val);
1443 1443
                         }
1444
-                    } elseif ($type == SPH_ATTR_MULTI64) {
1444
+                    } elseif ($type==SPH_ATTR_MULTI64) {
1445 1445
                         $attrvals[$attr] = array();
1446 1446
                         $nvalues = $val;
1447
-                        while ($nvalues > 0 && $p < $max) {
1447
+                        while ($nvalues>0 && $p<$max) {
1448 1448
                             $attrvals[$attr][] = sphUnpackI64(substr($response, $p, 8));
1449 1449
                             $p += 8;
1450 1450
                             $nvalues -= 2;
1451 1451
                         }
1452
-                    } elseif ($type == SPH_ATTR_STRING) {
1452
+                    } elseif ($type==SPH_ATTR_STRING) {
1453 1453
                         $attrvals[$attr] = substr($response, $p, $val);
1454 1454
                         $p += $val;
1455
-                    } elseif ($type == SPH_ATTR_FACTORS) {
1455
+                    } elseif ($type==SPH_ATTR_FACTORS) {
1456 1456
                         $attrvals[$attr] = substr($response, $p, $val - 4);
1457
-                        $p += $val-4;
1457
+                        $p += $val - 4;
1458 1458
                     } else {
1459 1459
                         $attrvals[$attr] = sphFixUint($val);
1460 1460
                     }
@@ -1473,14 +1473,14 @@  discard block
 block discarded – undo
1473 1473
             $result['time'] = sprintf('%.3f', $msecs / 1000);
1474 1474
             $p += 16;
1475 1475
 
1476
-            while ($words --> 0 && $p < $max) {
1476
+            while ($words-->0 && $p<$max) {
1477 1477
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1478 1478
                 $p += 4;
1479 1479
                 $word = substr($response, $p, $len);
1480 1480
                 $p += $len;
1481 1481
                 list($docs, $hits) = array_values(unpack('N*N*', substr($response, $p, 8)));
1482 1482
                 $p += 8;
1483
-                $result['words'][$word] = array (
1483
+                $result['words'][$word] = array(
1484 1484
                     'docs' => sprintf('%u', $docs),
1485 1485
                     'hits' => sprintf('%u', $hits)
1486 1486
                 );
@@ -1615,23 +1615,23 @@  discard block
 block discarded – undo
1615 1615
             $flags |= 1024;
1616 1616
         }
1617 1617
         $req = pack('NN', 0, $flags); // mode=0, flags=$flags
1618
-        $req .= pack('N', strlen($index)) . $index; // req index
1619
-        $req .= pack('N', strlen($words)) . $words; // req words
1618
+        $req .= pack('N', strlen($index)).$index; // req index
1619
+        $req .= pack('N', strlen($words)).$words; // req words
1620 1620
 
1621 1621
         // options
1622
-        $req .= pack('N', strlen($opts['before_match'])) . $opts['before_match'];
1623
-        $req .= pack('N', strlen($opts['after_match'])) . $opts['after_match'];
1624
-        $req .= pack('N', strlen($opts['chunk_separator'])) . $opts['chunk_separator'];
1622
+        $req .= pack('N', strlen($opts['before_match'])).$opts['before_match'];
1623
+        $req .= pack('N', strlen($opts['after_match'])).$opts['after_match'];
1624
+        $req .= pack('N', strlen($opts['chunk_separator'])).$opts['chunk_separator'];
1625 1625
         $req .= pack('NN', (int)$opts['limit'], (int)$opts['around']);
1626 1626
         $req .= pack('NNN', (int)$opts['limit_passages'], (int)$opts['limit_words'], (int)$opts['start_passage_id']); // v.1.2
1627
-        $req .= pack('N', strlen($opts['html_strip_mode'])) . $opts['html_strip_mode'];
1628
-        $req .= pack('N', strlen($opts['passage_boundary'])) . $opts['passage_boundary'];
1627
+        $req .= pack('N', strlen($opts['html_strip_mode'])).$opts['html_strip_mode'];
1628
+        $req .= pack('N', strlen($opts['passage_boundary'])).$opts['passage_boundary'];
1629 1629
 
1630 1630
         // documents
1631 1631
         $req .= pack('N', count($docs));
1632 1632
         foreach ($docs as $doc) {
1633 1633
             assert(is_string($doc));
1634
-            $req .= pack('N', strlen($doc)) . $doc;
1634
+            $req .= pack('N', strlen($doc)).$doc;
1635 1635
         }
1636 1636
 
1637 1637
         ////////////////////////////
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
         ////////////////////////////
1640 1640
 
1641 1641
         $len = strlen($req);
1642
-        $req = pack('nnN', SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len) . $req; // add header
1642
+        $req = pack('nnN', SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len).$req; // add header
1643 1643
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, VER_COMMAND_EXCERPT))) {
1644 1644
             $this->mbPop();
1645 1645
             return false;
@@ -1652,11 +1652,11 @@  discard block
 block discarded – undo
1652 1652
         $pos = 0;
1653 1653
         $res = array();
1654 1654
         $rlen = strlen($response);
1655
-        for ($i = 0; $i < count($docs); $i++) {
1655
+        for ($i = 0; $i<count($docs); $i++) {
1656 1656
             list(, $len) = unpack('N*', substr($response, $pos, 4));
1657 1657
             $pos += 4;
1658 1658
 
1659
-            if ($pos + $len > $rlen) {
1659
+            if ($pos + $len>$rlen) {
1660 1660
                 $this->error = 'incomplete reply';
1661 1661
                 $this->mbPop();
1662 1662
                 return false;
@@ -1695,8 +1695,8 @@  discard block
 block discarded – undo
1695 1695
         /////////////////
1696 1696
 
1697 1697
         // v.1.0 req
1698
-        $req  = pack('N', strlen($query)) . $query; // req query
1699
-        $req .= pack('N', strlen($index)) . $index; // req index
1698
+        $req  = pack('N', strlen($query)).$query; // req query
1699
+        $req .= pack('N', strlen($index)).$index; // req index
1700 1700
         $req .= pack('N', (int)$hits);
1701 1701
 
1702 1702
         ////////////////////////////
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
         ////////////////////////////
1705 1705
 
1706 1706
         $len = strlen($req);
1707
-        $req = pack('nnN', SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len) . $req; // add header
1707
+        $req = pack('nnN', SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len).$req; // add header
1708 1708
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, VER_COMMAND_KEYWORDS))) {
1709 1709
             $this->mbPop();
1710 1710
             return false;
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
         $rlen = strlen($response);
1720 1720
         list(, $nwords) = unpack('N*', substr($response, $pos, 4));
1721 1721
         $pos += 4;
1722
-        for ($i = 0; $i < $nwords; $i++) {
1722
+        for ($i = 0; $i<$nwords; $i++) {
1723 1723
             list(, $len) = unpack('N*', substr($response, $pos, 4));
1724 1724
             $pos += 4;
1725 1725
             $tokenized = $len ? substr($response, $pos, $len) : '';
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
                 $res[$i]['hits'] = $nhits;
1743 1743
             }
1744 1744
 
1745
-            if ($pos > $rlen) {
1745
+            if ($pos>$rlen) {
1746 1746
                 $this->error = 'incomplete reply';
1747 1747
                 $this->mbPop();
1748 1748
                 return false;
@@ -1755,8 +1755,8 @@  discard block
 block discarded – undo
1755 1755
 
1756 1756
     public function escapeString($string)
1757 1757
     {
1758
-        $from = array('\\', '(',')','|','-','!','@','~','"','&', '/', '^', '$', '=', '<');
1759
-        $to   = array('\\\\', '\(','\)','\|','\-','\!','\@','\~','\"', '\&', '\/', '\^', '\$', '\=', '\<');
1758
+        $from = array('\\', '(', ')', '|', '-', '!', '@', '~', '"', '&', '/', '^', '$', '=', '<');
1759
+        $to   = array('\\\\', '\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/', '\^', '\$', '\=', '\<');
1760 1760
 
1761 1761
         return str_replace($from, $to, $string);
1762 1762
     }
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
         foreach ($values as $id => $entry) {
1784 1784
             assert(is_numeric($id));
1785 1785
             assert(is_array($entry));
1786
-            assert(count($entry) == count($attrs));
1786
+            assert(count($entry)==count($attrs));
1787 1787
             foreach ($entry as $v) {
1788 1788
                 if ($mva) {
1789 1789
                     assert(is_array($v));
@@ -1798,12 +1798,12 @@  discard block
 block discarded – undo
1798 1798
 
1799 1799
         // build request
1800 1800
         $this->mbPush();
1801
-        $req = pack('N', strlen($index)) . $index;
1801
+        $req = pack('N', strlen($index)).$index;
1802 1802
 
1803 1803
         $req .= pack('N', count($attrs));
1804 1804
         $req .= pack('N', $ignorenonexistent ? 1 : 0);
1805 1805
         foreach ($attrs as $attr) {
1806
-            $req .= pack('N', strlen($attr)) . $attr;
1806
+            $req .= pack('N', strlen($attr)).$attr;
1807 1807
             $req .= pack('N', $mva ? 1 : 0);
1808 1808
         }
1809 1809
 
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
         }
1828 1828
 
1829 1829
         $len = strlen($req);
1830
-        $req = pack('nnN', SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len) . $req; // add header
1830
+        $req = pack('nnN', SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len).$req; // add header
1831 1831
         if (!$this->send($fp, $req, $len + 8)) {
1832 1832
             $this->mbPop();
1833 1833
             return -1;
@@ -1850,7 +1850,7 @@  discard block
 block discarded – undo
1850 1850
 
1851 1851
     public function open()
1852 1852
     {
1853
-        if ($this->_socket !== false) {
1853
+        if ($this->_socket!==false) {
1854 1854
             $this->error = 'already connected';
1855 1855
             return false;
1856 1856
         }
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
 
1870 1870
     public function close()
1871 1871
     {
1872
-        if ($this->_socket === false) {
1872
+        if ($this->_socket===false) {
1873 1873
             $this->error = 'not connected';
1874 1874
             return false;
1875 1875
         }
@@ -1906,8 +1906,8 @@  discard block
 block discarded – undo
1906 1906
         $p += 8;
1907 1907
 
1908 1908
         $res = array();
1909
-        for ($i = 0; $i < $rows; $i++) {
1910
-            for ($j = 0; $j < $cols; $j++) {
1909
+        for ($i = 0; $i<$rows; $i++) {
1910
+            for ($j = 0; $j<$cols; $j++) {
1911 1911
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1912 1912
                 $p += 4;
1913 1913
                 $res[$i][] = substr($response, $p, $len);
@@ -1938,7 +1938,7 @@  discard block
 block discarded – undo
1938 1938
         }
1939 1939
 
1940 1940
         $tag = -1;
1941
-        if (strlen($response) == 4) {
1941
+        if (strlen($response)==4) {
1942 1942
             list(, $tag) = unpack('N*', $response);
1943 1943
         } else {
1944 1944
             $this->error = 'unexpected response length';
Please login to merge, or discard this patch.