Completed
Push — master ( 127ba1...126d50 )
by Peter
02:32
created
src/SphinxClient.php 1 patch
Spacing   +201 added lines, -201 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:
@@ -149,19 +149,19 @@  discard block
 block discarded – undo
149 149
     assert(is_numeric($value));
150 150
 
151 151
     // x64
152
-    if (PHP_INT_SIZE >= 8) {
152
+    if (PHP_INT_SIZE>=8) {
153 153
         $value = (int)$value;
154 154
         return pack('NN', $value >> 32, $value & 0xFFFFFFFF);
155 155
     }
156 156
 
157 157
     // x32, int
158 158
     if (is_int($value)) {
159
-        return pack('NN', $value < 0 ? -1 : 0, $value);
159
+        return pack('NN', $value<0 ? -1 : 0, $value);
160 160
     }
161 161
 
162 162
     // x32, bcmath
163 163
     if (function_exists('bcmul')) {
164
-        if (bccomp($value, 0) == -1) {
164
+        if (bccomp($value, 0)==-1) {
165 165
             $value = bcadd('18446744073709551616', $value);
166 166
         }
167 167
         $h = bcdiv($value, '4294967296', 0);
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
     $l = $m - ($q * 4294967296.0);
180 180
     $h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328
181 181
 
182
-    if ($value < 0) {
183
-        if ($l == 0) {
182
+    if ($value<0) {
183
+        if ($l==0) {
184 184
             $h = 4294967296.0 - $h;
185 185
         } else {
186 186
             $h = 4294967295.0 - $h;
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
     assert(is_numeric($value));
203 203
 
204 204
     // x64
205
-    if (PHP_INT_SIZE >= 8) {
206
-        assert($value >= 0);
205
+    if (PHP_INT_SIZE>=8) {
206
+        assert($value>=0);
207 207
 
208 208
         // x64, int
209 209
         if (is_int($value)) {
@@ -265,16 +265,16 @@  discard block
 block discarded – undo
265 265
 {
266 266
     list($hi, $lo) = array_values(unpack('N*N*', $value));
267 267
 
268
-    if (PHP_INT_SIZE >= 8) {
269
-        if ($hi < 0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
268
+    if (PHP_INT_SIZE>=8) {
269
+        if ($hi<0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
270 270
             $hi += 1 << 32;
271 271
         }
272
-        if ($lo < 0) {
272
+        if ($lo<0) {
273 273
             $lo += 1 << 32;
274 274
         }
275 275
 
276 276
         // x64, int
277
-        if ($hi <= 2147483647) {
277
+        if ($hi<=2147483647) {
278 278
             return ($hi << 32) + $lo;
279 279
         }
280 280
 
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
         $C = 100000;
288 288
         $h = ((int)($hi / $C) << 32) + (int)($lo / $C);
289 289
         $l = (($hi % $C) << 32) + ($lo % $C);
290
-        if ($l > $C) {
290
+        if ($l>$C) {
291 291
             $h += (int)($l / $C);
292 292
             $l  = $l % $C;
293 293
         }
294 294
 
295
-        if ($h == 0) {
295
+        if ($h==0) {
296 296
             return $l;
297 297
         }
298 298
         return sprintf('%d%05d', $h, $l);
299 299
     }
300 300
 
301 301
     // x32, int
302
-    if ($hi == 0) {
303
-        if ($lo > 0) {
302
+    if ($hi==0) {
303
+        if ($lo>0) {
304 304
             return $lo;
305 305
         }
306 306
         return sprintf('%u', $lo);
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 
328 328
     $h = sprintf('%.0f', $h);
329 329
     $l = sprintf('%07.0f', $l);
330
-    if ($h == '0') {
330
+    if ($h=='0') {
331 331
         return sprintf('%.0f', (float)$l);
332 332
     }
333
-    return $h . $l;
333
+    return $h.$l;
334 334
 }
335 335
 
336 336
 /**
@@ -345,24 +345,24 @@  discard block
 block discarded – undo
345 345
     list($hi, $lo) = array_values(unpack('N*N*', $value));
346 346
 
347 347
     // x64
348
-    if (PHP_INT_SIZE >= 8) {
349
-        if ($hi < 0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
348
+    if (PHP_INT_SIZE>=8) {
349
+        if ($hi<0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
350 350
             $hi += 1 << 32;
351 351
         }
352
-        if ($lo < 0) {
352
+        if ($lo<0) {
353 353
             $lo += 1 << 32;
354 354
         }
355 355
 
356 356
         return ($hi << 32) + $lo;
357 357
     }
358 358
 
359
-    if ($hi == 0) { // x32, int
360
-        if ($lo > 0) {
359
+    if ($hi==0) { // x32, int
360
+        if ($lo>0) {
361 361
             return $lo;
362 362
         }
363 363
         return sprintf('%u', $lo);
364
-    } elseif ($hi == -1) { // x32, int
365
-        if ($lo < 0) {
364
+    } elseif ($hi==-1) { // x32, int
365
+        if ($lo<0) {
366 366
             return $lo;
367 367
         }
368 368
         return sprintf('%.0f', $lo - 4294967296.0);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
     $neg = '';
372 372
     $c = 0;
373
-    if ($hi < 0) {
373
+    if ($hi<0) {
374 374
         $hi = ~$hi;
375 375
         $lo = ~$lo;
376 376
         $c = 1;
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 
383 383
     // x32, bcmath
384 384
     if (function_exists('bcmul')) {
385
-        return $neg . bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c);
385
+        return $neg.bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c);
386 386
     }
387 387
 
388 388
     // x32, no-bcmath
@@ -395,17 +395,17 @@  discard block
 block discarded – undo
395 395
     $mq = floor($m / 10000000.0);
396 396
     $l = $m - $mq * 10000000.0 + $c;
397 397
     $h = $q * 4294967296.0 + $r * 429.0 + $mq;
398
-    if ($l == 10000000) {
398
+    if ($l==10000000) {
399 399
         $l = 0;
400 400
         $h += 1;
401 401
     }
402 402
 
403 403
     $h = sprintf('%.0f', $h);
404 404
     $l = sprintf('%07.0f', $l);
405
-    if ($h == '0') {
406
-        return $neg . sprintf('%.0f', (float)$l);
405
+    if ($h=='0') {
406
+        return $neg.sprintf('%.0f', (float)$l);
407 407
     }
408
-    return $neg . $h . $l;
408
+    return $neg.$h.$l;
409 409
 }
410 410
 
411 411
 /**
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function sphFixUint($value)
417 417
 {
418
-    if (PHP_INT_SIZE >= 8) {
418
+    if (PHP_INT_SIZE>=8) {
419 419
         // x64 route, workaround broken unpack() in 5.2.2+
420
-        if ($value < 0) {
420
+        if ($value<0) {
421 421
             $value += 1 << 32;
422 422
         }
423 423
         return $value;
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 
752 752
     public function __destruct()
753 753
     {
754
-        if ($this->socket !== false) {
754
+        if ($this->socket!==false) {
755 755
             fclose($this->socket);
756 756
         }
757 757
     }
@@ -791,19 +791,19 @@  discard block
 block discarded – undo
791 791
     public function setServer($host, $port = 0)
792 792
     {
793 793
         assert(is_string($host));
794
-        if ($host[0] == '/') {
795
-            $this->path = 'unix://' . $host;
794
+        if ($host[0]=='/') {
795
+            $this->path = 'unix://'.$host;
796 796
             return;
797 797
         }
798
-        if (substr($host, 0, 7) == 'unix://') {
798
+        if (substr($host, 0, 7)=='unix://') {
799 799
             $this->path = $host;
800 800
             return;
801 801
         }
802 802
 
803 803
         $this->host = $host;
804 804
         $port = intval($port);
805
-        assert(0 <= $port && $port < 65536);
806
-        $this->port = $port == 0 ? 9312 : $port;
805
+        assert(0<=$port && $port<65536);
806
+        $this->port = $port==0 ? 9312 : $port;
807 807
         $this->path = '';
808 808
     }
809 809
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
      */
828 828
     protected function send($handle, $data, $length)
829 829
     {
830
-        if (feof($handle) || fwrite($handle, $data, $length) !== $length) {
830
+        if (feof($handle) || fwrite($handle, $data, $length)!==$length) {
831 831
             $this->error = 'connection unexpectedly closed (timed out?)';
832 832
             $this->conn_error = true;
833 833
             return false;
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
      */
867 867
     protected function connect()
868 868
     {
869
-        if ($this->socket !== false) {
869
+        if ($this->socket!==false) {
870 870
             // we are in persistent connection mode, so we have a socket
871 871
             // however, need to check whether it's still alive
872 872
             if (!@feof($this->socket)) {
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
             $port = $this->port;
890 890
         }
891 891
 
892
-        if ($this->timeout <= 0) {
892
+        if ($this->timeout<=0) {
893 893
             $fp = @fsockopen($host, $port, $errno, $errstr);
894 894
         } else {
895 895
             $fp = @fsockopen($host, $port, $errno, $errstr, $this->timeout);
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
         // check version
922 922
         list(, $v) = unpack('N*', fread($fp, 4));
923 923
         $v = (int)$v;
924
-        if ($v < 1) {
924
+        if ($v<1) {
925 925
             fclose($fp);
926 926
             $this->error = "expected searchd protocol version 1+, got version '$v'";
927 927
             return false;
@@ -944,10 +944,10 @@  discard block
 block discarded – undo
944 944
         $len = 0;
945 945
 
946 946
         $header = fread($fp, 8);
947
-        if (strlen($header) == 8) {
947
+        if (strlen($header)==8) {
948 948
             list($status, $ver, $len) = array_values(unpack('n2a/Nb', $header));
949 949
             $left = $len;
950
-            while ($left > 0 && !feof($fp)) {
950
+            while ($left>0 && !feof($fp)) {
951 951
                 $chunk = fread($fp, min(8192, $left));
952 952
                 if ($chunk) {
953 953
                     $response .= $chunk;
@@ -956,13 +956,13 @@  discard block
 block discarded – undo
956 956
             }
957 957
         }
958 958
 
959
-        if ($this->socket === false) {
959
+        if ($this->socket===false) {
960 960
             fclose($fp);
961 961
         }
962 962
 
963 963
         // check response
964 964
         $read = strlen($response);
965
-        if (!$response || $read != $len) {
965
+        if (!$response || $read!=$len) {
966 966
             $this->error = $len
967 967
                 ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)"
968 968
                 : 'received zero-sized searchd response';
@@ -970,26 +970,26 @@  discard block
 block discarded – undo
970 970
         }
971 971
 
972 972
         // check status
973
-        if ($status == SEARCHD_WARNING) {
973
+        if ($status==SEARCHD_WARNING) {
974 974
             list(, $wlen) = unpack('N*', substr($response, 0, 4));
975 975
             $this->warning = substr($response, 4, $wlen);
976 976
             return substr($response, 4 + $wlen);
977 977
         }
978
-        if ($status == SEARCHD_ERROR) {
979
-            $this->error = 'searchd error: ' . substr($response, 4);
978
+        if ($status==SEARCHD_ERROR) {
979
+            $this->error = 'searchd error: '.substr($response, 4);
980 980
             return false;
981 981
         }
982
-        if ($status == SEARCHD_RETRY) {
983
-            $this->error = 'temporary searchd error: ' . substr($response, 4);
982
+        if ($status==SEARCHD_RETRY) {
983
+            $this->error = 'temporary searchd error: '.substr($response, 4);
984 984
             return false;
985 985
         }
986
-        if ($status != SEARCHD_OK) {
986
+        if ($status!=SEARCHD_OK) {
987 987
             $this->error = "unknown status code '$status'";
988 988
             return false;
989 989
         }
990 990
 
991 991
         // check version
992
-        if ($ver < $client_ver) {
992
+        if ($ver<$client_ver) {
993 993
             $this->warning = sprintf(
994 994
                 'searchd command v.%d.%d older than client\'s v.%d.%d, some options might not work',
995 995
                 $ver >> 8,
@@ -1018,15 +1018,15 @@  discard block
 block discarded – undo
1018 1018
     {
1019 1019
         assert(is_int($offset));
1020 1020
         assert(is_int($limit));
1021
-        assert($offset >= 0);
1022
-        assert($limit > 0);
1023
-        assert($max >= 0);
1021
+        assert($offset>=0);
1022
+        assert($limit>0);
1023
+        assert($max>=0);
1024 1024
         $this->offset = $offset;
1025 1025
         $this->limit = $limit;
1026
-        if ($max > 0) {
1026
+        if ($max>0) {
1027 1027
             $this->max_matches = $max;
1028 1028
         }
1029
-        if ($cutoff > 0) {
1029
+        if ($cutoff>0) {
1030 1030
             $this->cutoff = $cutoff;
1031 1031
         }
1032 1032
     }
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
     public function setMaxQueryTime($max)
1040 1040
     {
1041 1041
         assert(is_int($max));
1042
-        assert($max >= 0);
1042
+        assert($max>=0);
1043 1043
         $this->max_query_time = $max;
1044 1044
     }
1045 1045
 
@@ -1072,9 +1072,9 @@  discard block
 block discarded – undo
1072 1072
      * @param int $ranker
1073 1073
      * @param string $rank_expr
1074 1074
      */
1075
-    public function setRankingMode($ranker, $rank_expr='')
1075
+    public function setRankingMode($ranker, $rank_expr = '')
1076 1076
     {
1077
-        assert($ranker === 0 || $ranker >= 1 && $ranker < SPH_RANK_TOTAL);
1077
+        assert($ranker===0 || $ranker>=1 && $ranker<SPH_RANK_TOTAL);
1078 1078
         assert(is_string($rank_expr));
1079 1079
         $this->ranker = $ranker;
1080 1080
         $this->rank_expr = $rank_expr;
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
             SPH_SORT_EXPR
1098 1098
         )));
1099 1099
         assert(is_string($sort_by));
1100
-        assert($mode == SPH_SORT_RELEVANCE || strlen($sort_by) > 0);
1100
+        assert($mode==SPH_SORT_RELEVANCE || strlen($sort_by)>0);
1101 1101
 
1102 1102
         $this->sort = $mode;
1103 1103
         $this->sort_by = $sort_by;
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
     {
1152 1152
         assert(is_numeric($min));
1153 1153
         assert(is_numeric($max));
1154
-        assert($min <= $max);
1154
+        assert($min<=$max);
1155 1155
 
1156 1156
         $this->min_id = $min;
1157 1157
         $this->max_id = $max;
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
         assert(is_string($attribute));
1216 1216
         assert(is_numeric($min));
1217 1217
         assert(is_numeric($max));
1218
-        assert($min <= $max);
1218
+        assert($min<=$max);
1219 1219
 
1220 1220
         $this->filters[] = array(
1221 1221
             'type' => SPH_FILTER_RANGE,
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
         assert(is_string($attribute));
1241 1241
         assert(is_float($min));
1242 1242
         assert(is_float($max));
1243
-        assert($min <= $max);
1243
+        assert($min<=$max);
1244 1244
 
1245 1245
         $this->filters[] = array(
1246 1246
             'type' => SPH_FILTER_FLOATRANGE,
@@ -1320,8 +1320,8 @@  discard block
 block discarded – undo
1320 1320
      */
1321 1321
     public function setRetries($count, $delay = 0)
1322 1322
     {
1323
-        assert(is_int($count) && $count >= 0);
1324
-        assert(is_int($delay) && $delay >= 0);
1323
+        assert(is_int($count) && $count>=0);
1324
+        assert(is_int($delay) && $delay>=0);
1325 1325
         $this->retry_count = $count;
1326 1326
         $this->retry_delay = $delay;
1327 1327
     }
@@ -1397,12 +1397,12 @@  discard block
 block discarded – undo
1397 1397
             'global_idf',
1398 1398
             'low_priority'
1399 1399
         );
1400
-        $flags = array (
1400
+        $flags = array(
1401 1401
             'reverse_scan' => array(0, 1),
1402 1402
             'sort_method' => array('pq', 'kbuffer'),
1403 1403
             'max_predicted_time' => array(0),
1404 1404
             'boolean_simplify' => array(true, false),
1405
-            'idf' => array ('normalized', 'plain', 'tfidf_normalized', 'tfidf_unnormalized'),
1405
+            'idf' => array('normalized', 'plain', 'tfidf_normalized', 'tfidf_unnormalized'),
1406 1406
             'global_idf' => array(true, false),
1407 1407
             'low_priority' => array(true, false)
1408 1408
         );
@@ -1410,29 +1410,29 @@  discard block
 block discarded – undo
1410 1410
         assert(isset($flag_name, $known_names));
1411 1411
         assert(
1412 1412
             in_array($flag_value, $flags[$flag_name], true) ||
1413
-            ($flag_name == 'max_predicted_time' && is_int($flag_value) && $flag_value >= 0)
1413
+            ($flag_name=='max_predicted_time' && is_int($flag_value) && $flag_value>=0)
1414 1414
         );
1415 1415
 
1416 1416
         switch ($flag_name) {
1417 1417
             case 'reverse_scan':
1418
-                $this->query_flags = sphSetBit($this->query_flags, 0, $flag_value == 1);
1418
+                $this->query_flags = sphSetBit($this->query_flags, 0, $flag_value==1);
1419 1419
                 break;
1420 1420
             case 'sort_method':
1421
-                $this->query_flags = sphSetBit($this->query_flags, 1, $flag_value == 'kbuffer');
1421
+                $this->query_flags = sphSetBit($this->query_flags, 1, $flag_value=='kbuffer');
1422 1422
                 break;
1423 1423
             case 'max_predicted_time':
1424
-                $this->query_flags = sphSetBit($this->query_flags, 2, $flag_value > 0);
1424
+                $this->query_flags = sphSetBit($this->query_flags, 2, $flag_value>0);
1425 1425
                 $this->predicted_time = (int)$flag_value;
1426 1426
                 break;
1427 1427
             case 'boolean_simplify':
1428 1428
                 $this->query_flags = sphSetBit($this->query_flags, 3, $flag_value);
1429 1429
                 break;
1430 1430
             case 'idf':
1431
-                if ($flag_value == 'normalized' || $flag_value == 'plain') {
1432
-                    $this->query_flags = sphSetBit($this->query_flags, 4, $flag_value == 'plain');
1431
+                if ($flag_value=='normalized' || $flag_value=='plain') {
1432
+                    $this->query_flags = sphSetBit($this->query_flags, 4, $flag_value=='plain');
1433 1433
                 }
1434
-                if ($flag_value == 'tfidf_normalized' || $flag_value == 'tfidf_unnormalized') {
1435
-                    $this->query_flags = sphSetBit($this->query_flags, 6, $flag_value == 'tfidf_normalized');
1434
+                if ($flag_value=='tfidf_normalized' || $flag_value=='tfidf_unnormalized') {
1435
+                    $this->query_flags = sphSetBit($this->query_flags, 6, $flag_value=='tfidf_normalized');
1436 1436
                 }
1437 1437
                 break;
1438 1438
             case 'global_idf':
@@ -1456,8 +1456,8 @@  discard block
 block discarded – undo
1456 1456
         assert(is_string($order_by));
1457 1457
         assert(is_int($offset));
1458 1458
         assert(is_int($limit));
1459
-        assert($offset >= 0);
1460
-        assert($limit > 0);
1459
+        assert($offset>=0);
1460
+        assert($limit>0);
1461 1461
 
1462 1462
         $this->outer_order_by = $order_by;
1463 1463
         $this->outer_offset = $offset;
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
         $this->error = $results[0]['error'];
1537 1537
         $this->warning = $results[0]['warning'];
1538 1538
 
1539
-        if ($results[0]['status'] == SEARCHD_ERROR) {
1539
+        if ($results[0]['status']==SEARCHD_ERROR) {
1540 1540
             return false;
1541 1541
         } else {
1542 1542
             return $results[0];
@@ -1574,24 +1574,24 @@  discard block
 block discarded – undo
1574 1574
 
1575 1575
         // build request
1576 1576
         $req = pack('NNNNN', $this->query_flags, $this->offset, $this->limit, $this->mode, $this->ranker);
1577
-        if ($this->ranker == SPH_RANK_EXPR) {
1578
-            $req .= pack('N', strlen($this->rank_expr)) . $this->rank_expr;
1577
+        if ($this->ranker==SPH_RANK_EXPR) {
1578
+            $req .= pack('N', strlen($this->rank_expr)).$this->rank_expr;
1579 1579
         }
1580 1580
         $req .= pack('N', $this->sort); // (deprecated) sort mode
1581
-        $req .= pack('N', strlen($this->sort_by)) . $this->sort_by;
1582
-        $req .= pack('N', strlen($query)) . $query; // query itself
1581
+        $req .= pack('N', strlen($this->sort_by)).$this->sort_by;
1582
+        $req .= pack('N', strlen($query)).$query; // query itself
1583 1583
         $req .= pack('N', count($this->weights)); // weights
1584 1584
         foreach ($this->weights as $weight) {
1585 1585
             $req .= pack('N', (int)$weight);
1586 1586
         }
1587
-        $req .= pack('N', strlen($index)) . $index; // indexes
1587
+        $req .= pack('N', strlen($index)).$index; // indexes
1588 1588
         $req .= pack('N', 1); // id64 range marker
1589
-        $req .= sphPackU64($this->min_id) . sphPackU64($this->max_id); // id64 range
1589
+        $req .= sphPackU64($this->min_id).sphPackU64($this->max_id); // id64 range
1590 1590
 
1591 1591
         // filters
1592 1592
         $req .= pack('N', count($this->filters));
1593 1593
         foreach ($this->filters as $filter) {
1594
-            $req .= pack('N', strlen($filter['attr'])) . $filter['attr'];
1594
+            $req .= pack('N', strlen($filter['attr'])).$filter['attr'];
1595 1595
             $req .= pack('N', $filter['type']);
1596 1596
             switch ($filter['type']) {
1597 1597
                 case SPH_FILTER_VALUES:
@@ -1601,13 +1601,13 @@  discard block
 block discarded – undo
1601 1601
                     }
1602 1602
                     break;
1603 1603
                 case SPH_FILTER_RANGE:
1604
-                    $req .= sphPackI64($filter['min']) . sphPackI64($filter['max']);
1604
+                    $req .= sphPackI64($filter['min']).sphPackI64($filter['max']);
1605 1605
                     break;
1606 1606
                 case SPH_FILTER_FLOATRANGE:
1607
-                    $req .= $this->packFloat($filter['min']) . $this->packFloat($filter['max']);
1607
+                    $req .= $this->packFloat($filter['min']).$this->packFloat($filter['max']);
1608 1608
                     break;
1609 1609
                 case SPH_FILTER_STRING:
1610
-                    $req .= pack('N', strlen($filter['value'])) . $filter['value'];
1610
+                    $req .= pack('N', strlen($filter['value'])).$filter['value'];
1611 1611
                     break;
1612 1612
                 default:
1613 1613
                     assert(0 && 'internal error: unhandled filter type');
@@ -1616,27 +1616,27 @@  discard block
 block discarded – undo
1616 1616
         }
1617 1617
 
1618 1618
         // group-by clause, max-matches count, group-sort clause, cutoff count
1619
-        $req .= pack('NN', $this->group_func, strlen($this->group_by)) . $this->group_by;
1619
+        $req .= pack('NN', $this->group_func, strlen($this->group_by)).$this->group_by;
1620 1620
         $req .= pack('N', $this->max_matches);
1621
-        $req .= pack('N', strlen($this->group_sort)) . $this->group_sort;
1621
+        $req .= pack('N', strlen($this->group_sort)).$this->group_sort;
1622 1622
         $req .= pack('NNN', $this->cutoff, $this->retry_count, $this->retry_delay);
1623
-        $req .= pack('N', strlen($this->group_distinct)) . $this->group_distinct;
1623
+        $req .= pack('N', strlen($this->group_distinct)).$this->group_distinct;
1624 1624
 
1625 1625
         // anchor point
1626 1626
         if (empty($this->anchor)) {
1627 1627
             $req .= pack('N', 0);
1628 1628
         } else {
1629
-            $a =& $this->anchor;
1629
+            $a = & $this->anchor;
1630 1630
             $req .= pack('N', 1);
1631
-            $req .= pack('N', strlen($a['attrlat'])) . $a['attrlat'];
1632
-            $req .= pack('N', strlen($a['attrlong'])) . $a['attrlong'];
1633
-            $req .= $this->packFloat($a['lat']) . $this->packFloat($a['long']);
1631
+            $req .= pack('N', strlen($a['attrlat'])).$a['attrlat'];
1632
+            $req .= pack('N', strlen($a['attrlong'])).$a['attrlong'];
1633
+            $req .= $this->packFloat($a['lat']).$this->packFloat($a['long']);
1634 1634
         }
1635 1635
 
1636 1636
         // per-index weights
1637 1637
         $req .= pack('N', count($this->index_weights));
1638 1638
         foreach ($this->index_weights as $idx => $weight) {
1639
-            $req .= pack('N', strlen($idx)) . $idx . pack('N', $weight);
1639
+            $req .= pack('N', strlen($idx)).$idx.pack('N', $weight);
1640 1640
         }
1641 1641
 
1642 1642
         // max query time
@@ -1645,16 +1645,16 @@  discard block
 block discarded – undo
1645 1645
         // per-field weights
1646 1646
         $req .= pack('N', count($this->field_weights));
1647 1647
         foreach ($this->field_weights as $field => $weight) {
1648
-            $req .= pack('N', strlen($field)) . $field . pack('N', $weight);
1648
+            $req .= pack('N', strlen($field)).$field.pack('N', $weight);
1649 1649
         }
1650 1650
 
1651 1651
         // comment
1652
-        $req .= pack('N', strlen($comment)) . $comment;
1652
+        $req .= pack('N', strlen($comment)).$comment;
1653 1653
 
1654 1654
         // attribute overrides
1655 1655
         $req .= pack('N', count($this->overrides));
1656 1656
         foreach ($this->overrides as $key => $entry) {
1657
-            $req .= pack('N', strlen($entry['attr'])) . $entry['attr'];
1657
+            $req .= pack('N', strlen($entry['attr'])).$entry['attr'];
1658 1658
             $req .= pack('NN', $entry['type'], count($entry['values']));
1659 1659
             foreach ($entry['values'] as $id => $val) {
1660 1660
                 assert(is_numeric($id));
@@ -1676,14 +1676,14 @@  discard block
 block discarded – undo
1676 1676
         }
1677 1677
 
1678 1678
         // select-list
1679
-        $req .= pack('N', strlen($this->select)) . $this->select;
1679
+        $req .= pack('N', strlen($this->select)).$this->select;
1680 1680
 
1681 1681
         // max_predicted_time
1682
-        if ($this->predicted_time > 0) {
1682
+        if ($this->predicted_time>0) {
1683 1683
             $req .= pack('N', (int)$this->predicted_time);
1684 1684
         }
1685 1685
 
1686
-        $req .= pack('N', strlen($this->outer_order_by)) . $this->outer_order_by;
1686
+        $req .= pack('N', strlen($this->outer_order_by)).$this->outer_order_by;
1687 1687
         $req .= pack('NN', $this->outer_offset, $this->outer_limit);
1688 1688
         if ($this->has_outer) {
1689 1689
             $req .= pack('N', 1);
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
         $nreqs = count($this->reqs);
1724 1724
         $req = join('', $this->reqs);
1725 1725
         $len = 8 + strlen($req);
1726
-        $req = pack('nnNNN', SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs) . $req; // add header
1726
+        $req = pack('nnNNN', SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs).$req; // add header
1727 1727
 
1728 1728
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, VER_COMMAND_SEARCH))) {
1729 1729
             $this->mbPop();
@@ -1751,9 +1751,9 @@  discard block
 block discarded – undo
1751 1751
         $max = strlen($response); // max position for checks, to protect against broken responses
1752 1752
 
1753 1753
         $results = array();
1754
-        for ($ires = 0; $ires < $nreqs && $p < $max; $ires++) {
1754
+        for ($ires = 0; $ires<$nreqs && $p<$max; $ires++) {
1755 1755
             $results[] = array();
1756
-            $result =& $results[$ires];
1756
+            $result = & $results[$ires];
1757 1757
 
1758 1758
             $result['error'] = '';
1759 1759
             $result['warning'] = '';
@@ -1762,13 +1762,13 @@  discard block
 block discarded – undo
1762 1762
             list(, $status) = unpack('N*', substr($response, $p, 4));
1763 1763
             $p += 4;
1764 1764
             $result['status'] = $status;
1765
-            if ($status != SEARCHD_OK) {
1765
+            if ($status!=SEARCHD_OK) {
1766 1766
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1767 1767
                 $p += 4;
1768 1768
                 $message = substr($response, $p, $len);
1769 1769
                 $p += $len;
1770 1770
 
1771
-                if ($status == SEARCHD_WARNING) {
1771
+                if ($status==SEARCHD_WARNING) {
1772 1772
                     $result['warning'] = $message;
1773 1773
                 } else {
1774 1774
                     $result['error'] = $message;
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 
1783 1783
             list(, $nfields) = unpack('N*', substr($response, $p, 4));
1784 1784
             $p += 4;
1785
-            while ($nfields --> 0 && $p < $max) {
1785
+            while ($nfields-->0 && $p<$max) {
1786 1786
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1787 1787
                 $p += 4;
1788 1788
                 $fields[] = substr($response, $p, $len);
@@ -1792,7 +1792,7 @@  discard block
 block discarded – undo
1792 1792
 
1793 1793
             list(, $nattrs) = unpack('N*', substr($response, $p, 4));
1794 1794
             $p += 4;
1795
-            while ($nattrs --> 0 && $p < $max) {
1795
+            while ($nattrs-->0 && $p<$max) {
1796 1796
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1797 1797
                 $p += 4;
1798 1798
                 $attr = substr($response, $p, $len);
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
 
1812 1812
             // read matches
1813 1813
             $idx = -1;
1814
-            while ($count --> 0 && $p < $max) {
1814
+            while ($count-->0 && $p<$max) {
1815 1815
                 // index into result array
1816 1816
                 $idx++;
1817 1817
 
@@ -1839,14 +1839,14 @@  discard block
 block discarded – undo
1839 1839
                 $attrvals = array();
1840 1840
                 foreach ($attrs as $attr => $type) {
1841 1841
                     // handle 64bit ints
1842
-                    if ($type == SPH_ATTR_BIGINT) {
1842
+                    if ($type==SPH_ATTR_BIGINT) {
1843 1843
                         $attrvals[$attr] = sphUnpackI64(substr($response, $p, 8));
1844 1844
                         $p += 8;
1845 1845
                         continue;
1846 1846
                     }
1847 1847
 
1848 1848
                     // handle floats
1849
-                    if ($type == SPH_ATTR_FLOAT) {
1849
+                    if ($type==SPH_ATTR_FLOAT) {
1850 1850
                         list(, $uval) = unpack('N*', substr($response, $p, 4));
1851 1851
                         $p += 4;
1852 1852
                         list(, $fval) = unpack('f*', pack('L', $uval));
@@ -1857,28 +1857,28 @@  discard block
 block discarded – undo
1857 1857
                     // handle everything else as unsigned ints
1858 1858
                     list(, $val) = unpack('N*', substr($response, $p, 4));
1859 1859
                     $p += 4;
1860
-                    if ($type == SPH_ATTR_MULTI) {
1860
+                    if ($type==SPH_ATTR_MULTI) {
1861 1861
                         $attrvals[$attr] = array();
1862 1862
                         $nvalues = $val;
1863
-                        while ($nvalues --> 0 && $p < $max) {
1863
+                        while ($nvalues-->0 && $p<$max) {
1864 1864
                             list(, $val) = unpack('N*', substr($response, $p, 4));
1865 1865
                             $p += 4;
1866 1866
                             $attrvals[$attr][] = sphFixUint($val);
1867 1867
                         }
1868
-                    } elseif ($type == SPH_ATTR_MULTI64) {
1868
+                    } elseif ($type==SPH_ATTR_MULTI64) {
1869 1869
                         $attrvals[$attr] = array();
1870 1870
                         $nvalues = $val;
1871
-                        while ($nvalues > 0 && $p < $max) {
1871
+                        while ($nvalues>0 && $p<$max) {
1872 1872
                             $attrvals[$attr][] = sphUnpackI64(substr($response, $p, 8));
1873 1873
                             $p += 8;
1874 1874
                             $nvalues -= 2;
1875 1875
                         }
1876
-                    } elseif ($type == SPH_ATTR_STRING) {
1876
+                    } elseif ($type==SPH_ATTR_STRING) {
1877 1877
                         $attrvals[$attr] = substr($response, $p, $val);
1878 1878
                         $p += $val;
1879
-                    } elseif ($type == SPH_ATTR_FACTORS) {
1879
+                    } elseif ($type==SPH_ATTR_FACTORS) {
1880 1880
                         $attrvals[$attr] = substr($response, $p, $val - 4);
1881
-                        $p += $val-4;
1881
+                        $p += $val - 4;
1882 1882
                     } else {
1883 1883
                         $attrvals[$attr] = sphFixUint($val);
1884 1884
                     }
@@ -1897,14 +1897,14 @@  discard block
 block discarded – undo
1897 1897
             $result['time'] = sprintf('%.3f', $msecs / 1000);
1898 1898
             $p += 16;
1899 1899
 
1900
-            while ($words --> 0 && $p < $max) {
1900
+            while ($words-->0 && $p<$max) {
1901 1901
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1902 1902
                 $p += 4;
1903 1903
                 $word = substr($response, $p, $len);
1904 1904
                 $p += $len;
1905 1905
                 list($docs, $hits) = array_values(unpack('N*N*', substr($response, $p, 8)));
1906 1906
                 $p += 8;
1907
-                $result['words'][$word] = array (
1907
+                $result['words'][$word] = array(
1908 1908
                     'docs' => sprintf('%u', $docs),
1909 1909
                     'hits' => sprintf('%u', $hits)
1910 1910
                 );
@@ -2006,23 +2006,23 @@  discard block
 block discarded – undo
2006 2006
             $flags |= 1024;
2007 2007
         }
2008 2008
         $req = pack('NN', 0, $flags); // mode=0, flags=$flags
2009
-        $req .= pack('N', strlen($index)) . $index; // req index
2010
-        $req .= pack('N', strlen($words)) . $words; // req words
2009
+        $req .= pack('N', strlen($index)).$index; // req index
2010
+        $req .= pack('N', strlen($words)).$words; // req words
2011 2011
 
2012 2012
         // options
2013
-        $req .= pack('N', strlen($opts['before_match'])) . $opts['before_match'];
2014
-        $req .= pack('N', strlen($opts['after_match'])) . $opts['after_match'];
2015
-        $req .= pack('N', strlen($opts['chunk_separator'])) . $opts['chunk_separator'];
2013
+        $req .= pack('N', strlen($opts['before_match'])).$opts['before_match'];
2014
+        $req .= pack('N', strlen($opts['after_match'])).$opts['after_match'];
2015
+        $req .= pack('N', strlen($opts['chunk_separator'])).$opts['chunk_separator'];
2016 2016
         $req .= pack('NN', (int)$opts['limit'], (int)$opts['around']);
2017 2017
         $req .= pack('NNN', (int)$opts['limit_passages'], (int)$opts['limit_words'], (int)$opts['start_passage_id']); // v.1.2
2018
-        $req .= pack('N', strlen($opts['html_strip_mode'])) . $opts['html_strip_mode'];
2019
-        $req .= pack('N', strlen($opts['passage_boundary'])) . $opts['passage_boundary'];
2018
+        $req .= pack('N', strlen($opts['html_strip_mode'])).$opts['html_strip_mode'];
2019
+        $req .= pack('N', strlen($opts['passage_boundary'])).$opts['passage_boundary'];
2020 2020
 
2021 2021
         // documents
2022 2022
         $req .= pack('N', count($docs));
2023 2023
         foreach ($docs as $doc) {
2024 2024
             assert(is_string($doc));
2025
-            $req .= pack('N', strlen($doc)) . $doc;
2025
+            $req .= pack('N', strlen($doc)).$doc;
2026 2026
         }
2027 2027
 
2028 2028
         ////////////////////////////
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
         ////////////////////////////
2031 2031
 
2032 2032
         $len = strlen($req);
2033
-        $req = pack('nnN', SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len) . $req; // add header
2033
+        $req = pack('nnN', SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len).$req; // add header
2034 2034
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, VER_COMMAND_EXCERPT))) {
2035 2035
             $this->mbPop();
2036 2036
             return false;
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
             list(, $len) = unpack('N*', substr($response, $pos, 4));
2049 2049
             $pos += 4;
2050 2050
 
2051
-            if ($pos + $len > $rlen) {
2051
+            if ($pos + $len>$rlen) {
2052 2052
                 $this->error = 'incomplete reply';
2053 2053
                 $this->mbPop();
2054 2054
                 return false;
@@ -2094,8 +2094,8 @@  discard block
 block discarded – undo
2094 2094
         /////////////////
2095 2095
 
2096 2096
         // v.1.0 req
2097
-        $req  = pack('N', strlen($query)) . $query; // req query
2098
-        $req .= pack('N', strlen($index)) . $index; // req index
2097
+        $req  = pack('N', strlen($query)).$query; // req query
2098
+        $req .= pack('N', strlen($index)).$index; // req index
2099 2099
         $req .= pack('N', (int)$hits);
2100 2100
 
2101 2101
         ////////////////////////////
@@ -2103,7 +2103,7 @@  discard block
 block discarded – undo
2103 2103
         ////////////////////////////
2104 2104
 
2105 2105
         $len = strlen($req);
2106
-        $req = pack('nnN', SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len) . $req; // add header
2106
+        $req = pack('nnN', SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len).$req; // add header
2107 2107
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, VER_COMMAND_KEYWORDS))) {
2108 2108
             $this->mbPop();
2109 2109
             return false;
@@ -2118,7 +2118,7 @@  discard block
 block discarded – undo
2118 2118
         $rlen = strlen($response);
2119 2119
         list(, $nwords) = unpack('N*', substr($response, $pos, 4));
2120 2120
         $pos += 4;
2121
-        for ($i = 0; $i < $nwords; $i++) {
2121
+        for ($i = 0; $i<$nwords; $i++) {
2122 2122
             list(, $len) = unpack('N*', substr($response, $pos, 4));
2123 2123
             $pos += 4;
2124 2124
             $tokenized = $len ? substr($response, $pos, $len) : '';
@@ -2141,7 +2141,7 @@  discard block
 block discarded – undo
2141 2141
                 $res[$i]['hits'] = $nhits;
2142 2142
             }
2143 2143
 
2144
-            if ($pos > $rlen) {
2144
+            if ($pos>$rlen) {
2145 2145
                 $this->error = 'incomplete reply';
2146 2146
                 $this->mbPop();
2147 2147
                 return false;
@@ -2159,8 +2159,8 @@  discard block
 block discarded – undo
2159 2159
      */
2160 2160
     public function escapeString($string)
2161 2161
     {
2162
-        $from = array('\\', '(',')','|','-','!','@','~','"','&', '/', '^', '$', '=', '<');
2163
-        $to   = array('\\\\', '\(','\)','\|','\-','\!','\@','\~','\"', '\&', '\/', '\^', '\$', '\=', '\<');
2162
+        $from = array('\\', '(', ')', '|', '-', '!', '@', '~', '"', '&', '/', '^', '$', '=', '<');
2163
+        $to   = array('\\\\', '\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/', '\^', '\$', '\=', '\<');
2164 2164
 
2165 2165
         return str_replace($from, $to, $string);
2166 2166
     }
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
         foreach ($values as $id => $entry) {
2196 2196
             assert(is_numeric($id));
2197 2197
             assert(is_array($entry));
2198
-            assert(count($entry) == count($attrs));
2198
+            assert(count($entry)==count($attrs));
2199 2199
             foreach ($entry as $v) {
2200 2200
                 if ($mva) {
2201 2201
                     assert(is_array($v));
@@ -2210,12 +2210,12 @@  discard block
 block discarded – undo
2210 2210
 
2211 2211
         // build request
2212 2212
         $this->mbPush();
2213
-        $req = pack('N', strlen($index)) . $index;
2213
+        $req = pack('N', strlen($index)).$index;
2214 2214
 
2215 2215
         $req .= pack('N', count($attrs));
2216 2216
         $req .= pack('N', $ignore_non_existent ? 1 : 0);
2217 2217
         foreach ($attrs as $attr) {
2218
-            $req .= pack('N', strlen($attr)) . $attr;
2218
+            $req .= pack('N', strlen($attr)).$attr;
2219 2219
             $req .= pack('N', $mva ? 1 : 0);
2220 2220
         }
2221 2221
 
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
         }
2240 2240
 
2241 2241
         $len = strlen($req);
2242
-        $req = pack('nnN', SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len) . $req; // add header
2242
+        $req = pack('nnN', SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len).$req; // add header
2243 2243
         if (!$this->send($fp, $req, $len + 8)) {
2244 2244
             $this->mbPop();
2245 2245
             return -1;
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
      */
2266 2266
     public function open()
2267 2267
     {
2268
-        if ($this->socket !== false) {
2268
+        if ($this->socket!==false) {
2269 2269
             $this->error = 'already connected';
2270 2270
             return false;
2271 2271
         }
@@ -2287,7 +2287,7 @@  discard block
 block discarded – undo
2287 2287
      */
2288 2288
     public function close()
2289 2289
     {
2290
-        if ($this->socket === false) {
2290
+        if ($this->socket===false) {
2291 2291
             $this->error = 'not connected';
2292 2292
             return false;
2293 2293
         }
@@ -2329,8 +2329,8 @@  discard block
 block discarded – undo
2329 2329
         $p += 8;
2330 2330
 
2331 2331
         $res = array();
2332
-        for ($i = 0; $i < $rows; $i++) {
2333
-            for ($j = 0; $j < $cols; $j++) {
2332
+        for ($i = 0; $i<$rows; $i++) {
2333
+            for ($j = 0; $j<$cols; $j++) {
2334 2334
                 list(, $len) = unpack('N*', substr($response, $p, 4));
2335 2335
                 $p += 4;
2336 2336
                 $res[$i][] = substr($response, $p, $len);
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
         }
2365 2365
 
2366 2366
         $tag = -1;
2367
-        if (strlen($response) == 4) {
2367
+        if (strlen($response)==4) {
2368 2368
             list(, $tag) = unpack('N*', $response);
2369 2369
         } else {
2370 2370
             $this->error = 'unexpected response length';
Please login to merge, or discard this patch.