Completed
Push — master ( ad5c0d...b72b0b )
by Peter
02:35
created
src/functions.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
     assert(is_numeric($value));
39 39
 
40 40
     // x64
41
-    if (PHP_INT_SIZE >= 8) {
41
+    if (PHP_INT_SIZE>=8) {
42 42
         $value = (int)$value;
43 43
         return pack('NN', $value >> 32, $value & 0xFFFFFFFF);
44 44
     }
45 45
 
46 46
     // x32, int
47 47
     if (is_int($value)) {
48
-        return pack('NN', $value < 0 ? -1 : 0, $value);
48
+        return pack('NN', $value<0 ? -1 : 0, $value);
49 49
     }
50 50
 
51 51
     // x32, bcmath
52 52
     if (function_exists('bcmul')) {
53
-        if (bccomp($value, 0) == -1) {
53
+        if (bccomp($value, 0)==-1) {
54 54
             $value = bcadd('18446744073709551616', $value);
55 55
         }
56 56
         $h = bcdiv($value, '4294967296', 0);
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
     $l = $m - ($q * 4294967296.0);
69 69
     $h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328
70 70
 
71
-    if ($value < 0) {
72
-        if ($l == 0) {
71
+    if ($value<0) {
72
+        if ($l==0) {
73 73
             $h = 4294967296.0 - $h;
74 74
         } else {
75 75
             $h = 4294967295.0 - $h;
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
     assert(is_numeric($value));
92 92
 
93 93
     // x64
94
-    if (PHP_INT_SIZE >= 8) {
95
-        assert($value >= 0);
94
+    if (PHP_INT_SIZE>=8) {
95
+        assert($value>=0);
96 96
 
97 97
         // x64, int
98 98
         if (is_int($value)) {
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
 {
155 155
     list($hi, $lo) = array_values(unpack('N*N*', $value));
156 156
 
157
-    if (PHP_INT_SIZE >= 8) {
158
-        if ($hi < 0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
157
+    if (PHP_INT_SIZE>=8) {
158
+        if ($hi<0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
159 159
             $hi += 1 << 32;
160 160
         }
161
-        if ($lo < 0) {
161
+        if ($lo<0) {
162 162
             $lo += 1 << 32;
163 163
         }
164 164
 
165 165
         // x64, int
166
-        if ($hi <= 2147483647) {
166
+        if ($hi<=2147483647) {
167 167
             return ($hi << 32) + $lo;
168 168
         }
169 169
 
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
         $C = 100000;
177 177
         $h = ((int)($hi / $C) << 32) + (int)($lo / $C);
178 178
         $l = (($hi % $C) << 32) + ($lo % $C);
179
-        if ($l > $C) {
179
+        if ($l>$C) {
180 180
             $h += (int)($l / $C);
181 181
             $l  = $l % $C;
182 182
         }
183 183
 
184
-        if ($h == 0) {
184
+        if ($h==0) {
185 185
             return $l;
186 186
         }
187 187
         return sprintf('%d%05d', $h, $l);
188 188
     }
189 189
 
190 190
     // x32, int
191
-    if ($hi == 0) {
192
-        if ($lo > 0) {
191
+    if ($hi==0) {
192
+        if ($lo>0) {
193 193
             return $lo;
194 194
         }
195 195
         return sprintf('%u', $lo);
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 
217 217
     $h = sprintf('%.0f', $h);
218 218
     $l = sprintf('%07.0f', $l);
219
-    if ($h == '0') {
219
+    if ($h=='0') {
220 220
         return sprintf('%.0f', (float)$l);
221 221
     }
222
-    return $h . $l;
222
+    return $h.$l;
223 223
 }
224 224
 
225 225
 /**
@@ -234,24 +234,24 @@  discard block
 block discarded – undo
234 234
     list($hi, $lo) = array_values(unpack('N*N*', $value));
235 235
 
236 236
     // x64
237
-    if (PHP_INT_SIZE >= 8) {
238
-        if ($hi < 0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
237
+    if (PHP_INT_SIZE>=8) {
238
+        if ($hi<0) { // because php 5.2.2 to 5.2.5 is totally fucked up again
239 239
             $hi += 1 << 32;
240 240
         }
241
-        if ($lo < 0) {
241
+        if ($lo<0) {
242 242
             $lo += 1 << 32;
243 243
         }
244 244
 
245 245
         return ($hi << 32) + $lo;
246 246
     }
247 247
 
248
-    if ($hi == 0) { // x32, int
249
-        if ($lo > 0) {
248
+    if ($hi==0) { // x32, int
249
+        if ($lo>0) {
250 250
             return $lo;
251 251
         }
252 252
         return sprintf('%u', $lo);
253
-    } elseif ($hi == -1) { // x32, int
254
-        if ($lo < 0) {
253
+    } elseif ($hi==-1) { // x32, int
254
+        if ($lo<0) {
255 255
             return $lo;
256 256
         }
257 257
         return sprintf('%.0f', $lo - 4294967296.0);
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
     $neg = '';
261 261
     $c = 0;
262
-    if ($hi < 0) {
262
+    if ($hi<0) {
263 263
         $hi = ~$hi;
264 264
         $lo = ~$lo;
265 265
         $c = 1;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
     // x32, bcmath
273 273
     if (function_exists('bcmul')) {
274
-        return $neg . bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c);
274
+        return $neg.bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c);
275 275
     }
276 276
 
277 277
     // x32, no-bcmath
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
     $mq = floor($m / 10000000.0);
285 285
     $l = $m - $mq * 10000000.0 + $c;
286 286
     $h = $q * 4294967296.0 + $r * 429.0 + $mq;
287
-    if ($l == 10000000) {
287
+    if ($l==10000000) {
288 288
         $l = 0;
289 289
         $h += 1;
290 290
     }
291 291
 
292 292
     $h = sprintf('%.0f', $h);
293 293
     $l = sprintf('%07.0f', $l);
294
-    if ($h == '0') {
295
-        return $neg . sprintf('%.0f', (float)$l);
294
+    if ($h=='0') {
295
+        return $neg.sprintf('%.0f', (float)$l);
296 296
     }
297
-    return $neg . $h . $l;
297
+    return $neg.$h.$l;
298 298
 }
299 299
 
300 300
 /**
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
  */
305 305
 function sphFixUint($value)
306 306
 {
307
-    if (PHP_INT_SIZE >= 8) {
307
+    if (PHP_INT_SIZE>=8) {
308 308
         // x64 route, workaround broken unpack() in 5.2.2+
309
-        if ($value < 0) {
309
+        if ($value<0) {
310 310
             $value += 1 << 32;
311 311
         }
312 312
         return $value;
Please login to merge, or discard this patch.
src/const.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -2,59 +2,59 @@  discard block
 block discarded – undo
2 2
 
3 3
 // known searchd commands
4 4
 /* @deprecated use SphinxClient::SEARCHD_COMMAND_SEARCH */
5
-define('SEARCHD_COMMAND_SEARCH',     0);
5
+define('SEARCHD_COMMAND_SEARCH', 0);
6 6
 /* @deprecated use SphinxClient::SEARCHD_COMMAND_EXCERPT */
7
-define('SEARCHD_COMMAND_EXCERPT',    1);
7
+define('SEARCHD_COMMAND_EXCERPT', 1);
8 8
 /* @deprecated use SphinxClient::SEARCHD_COMMAND_UPDATE */
9
-define('SEARCHD_COMMAND_UPDATE',     2);
9
+define('SEARCHD_COMMAND_UPDATE', 2);
10 10
 /* @deprecated use SphinxClient::SEARCHD_COMMAND_KEYWORDS */
11
-define('SEARCHD_COMMAND_KEYWORDS',   3);
11
+define('SEARCHD_COMMAND_KEYWORDS', 3);
12 12
 /* @deprecated use SphinxClient::SEARCHD_COMMAND_PERSIST */
13
-define('SEARCHD_COMMAND_PERSIST',    4);
13
+define('SEARCHD_COMMAND_PERSIST', 4);
14 14
 /* @deprecated use SphinxClient::SEARCHD_COMMAND_STATUS */
15
-define('SEARCHD_COMMAND_STATUS',     5);
15
+define('SEARCHD_COMMAND_STATUS', 5);
16 16
 /* @deprecated use SphinxClient::SEARCHD_COMMAND_FLUSHATTRS */
17 17
 define('SEARCHD_COMMAND_FLUSHATTRS', 7);
18 18
 
19 19
 // current client-side command implementation versions
20 20
 /* @deprecated use SphinxClient::VER_COMMAND_SEARCH */
21
-define('VER_COMMAND_SEARCH',     0x11E);
21
+define('VER_COMMAND_SEARCH', 0x11E);
22 22
 /* @deprecated use SphinxClient::VER_COMMAND_EXCERPT */
23
-define('VER_COMMAND_EXCERPT',    0x104);
23
+define('VER_COMMAND_EXCERPT', 0x104);
24 24
 /* @deprecated use SphinxClient::VER_COMMAND_UPDATE */
25
-define('VER_COMMAND_UPDATE',     0x103);
25
+define('VER_COMMAND_UPDATE', 0x103);
26 26
 /* @deprecated use SphinxClient::VER_COMMAND_KEYWORDS */
27
-define('VER_COMMAND_KEYWORDS',   0x100);
27
+define('VER_COMMAND_KEYWORDS', 0x100);
28 28
 /* @deprecated use SphinxClient::VER_COMMAND_STATUS */
29
-define('VER_COMMAND_STATUS',     0x101);
29
+define('VER_COMMAND_STATUS', 0x101);
30 30
 /* @deprecated use SphinxClient::VER_COMMAND_QUERY */
31
-define('VER_COMMAND_QUERY',      0x100);
31
+define('VER_COMMAND_QUERY', 0x100);
32 32
 /* @deprecated use SphinxClient::VER_COMMAND_FLUSH_ATTRS */
33 33
 define('VER_COMMAND_FLUSHATTRS', 0x100);
34 34
 
35 35
 // known searchd status codes
36 36
 /* @deprecated use SphinxClient::SEARCHD_OK */
37
-define('SEARCHD_OK',      0);
37
+define('SEARCHD_OK', 0);
38 38
 /* @deprecated use SphinxClient::SEARCHD_ERROR */
39
-define('SEARCHD_ERROR',   1);
39
+define('SEARCHD_ERROR', 1);
40 40
 /* @deprecated use SphinxClient::SEARCHD_RETRY */
41
-define('SEARCHD_RETRY',   2);
41
+define('SEARCHD_RETRY', 2);
42 42
 /* @deprecated use SphinxClient::SEARCHD_WARNING */
43 43
 define('SEARCHD_WARNING', 3);
44 44
 
45 45
 // known match modes
46 46
 /* @deprecated use SphinxClient::MATCH_ALL */
47
-define('SPH_MATCH_ALL',       0);
47
+define('SPH_MATCH_ALL', 0);
48 48
 /* @deprecated use SphinxClient::MATCH_ANY */
49
-define('SPH_MATCH_ANY',       1);
49
+define('SPH_MATCH_ANY', 1);
50 50
 /* @deprecated use SphinxClient::MATCH_PHRASE */
51
-define('SPH_MATCH_PHRASE',    2);
51
+define('SPH_MATCH_PHRASE', 2);
52 52
 /* @deprecated use SphinxClient::MATCH_BOOLEAN */
53
-define('SPH_MATCH_BOOLEAN',   3);
53
+define('SPH_MATCH_BOOLEAN', 3);
54 54
 /* @deprecated use SphinxClient::MATCH_EXTENDED */
55
-define('SPH_MATCH_EXTENDED',  4);
55
+define('SPH_MATCH_EXTENDED', 4);
56 56
 /* @deprecated use SphinxClient::MATCH_FULL_SCAN */
57
-define('SPH_MATCH_FULLSCAN',  5);
57
+define('SPH_MATCH_FULLSCAN', 5);
58 58
 /* @deprecated use SphinxClient::MATCH_EXTENDED2 */
59 59
 define('SPH_MATCH_EXTENDED2', 6); // extended engine V2 (TEMPORARY, WILL BE REMOVED)
60 60
 
@@ -62,80 +62,80 @@  discard block
 block discarded – undo
62 62
 /* @deprecated use SphinxClient::RANK_PROXIMITY_BM25 */
63 63
 define('SPH_RANK_PROXIMITY_BM25', 0); // default mode, phrase proximity major factor and BM25 minor one
64 64
 /* @deprecated use SphinxClient::RANK_BM25 */
65
-define('SPH_RANK_BM25',           1); // statistical mode, BM25 ranking only (faster but worse quality)
65
+define('SPH_RANK_BM25', 1); // statistical mode, BM25 ranking only (faster but worse quality)
66 66
 /* @deprecated use SphinxClient::RANK_NONE */
67
-define('SPH_RANK_NONE',           2); // no ranking, all matches get a weight of 1
67
+define('SPH_RANK_NONE', 2); // no ranking, all matches get a weight of 1
68 68
 /* @deprecated use SphinxClient::RANK_WORD_COUNT */
69
-define('SPH_RANK_WORDCOUNT',      3); // simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts
69
+define('SPH_RANK_WORDCOUNT', 3); // simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts
70 70
 /* @deprecated use SphinxClient::RANK_PROXIMITY */
71
-define('SPH_RANK_PROXIMITY',      4);
71
+define('SPH_RANK_PROXIMITY', 4);
72 72
 /* @deprecated use SphinxClient::RANK_MATCH_ANY */
73
-define('SPH_RANK_MATCHANY',       5);
73
+define('SPH_RANK_MATCHANY', 5);
74 74
 /* @deprecated use SphinxClient::RANK_FIELD_MASK */
75
-define('SPH_RANK_FIELDMASK',      6);
75
+define('SPH_RANK_FIELDMASK', 6);
76 76
 /* @deprecated use SphinxClient::RANK_SPH04 */
77
-define('SPH_RANK_SPH04',          7);
77
+define('SPH_RANK_SPH04', 7);
78 78
 /* @deprecated use SphinxClient::RANK_EXPR */
79
-define('SPH_RANK_EXPR',           8);
79
+define('SPH_RANK_EXPR', 8);
80 80
 /* @deprecated use SphinxClient::RANK_TOTAL */
81
-define('SPH_RANK_TOTAL',          9);
81
+define('SPH_RANK_TOTAL', 9);
82 82
 
83 83
 // known sort modes
84 84
 /* @deprecated use SphinxClient::SORT_RELEVANCE */
85
-define('SPH_SORT_RELEVANCE',     0);
85
+define('SPH_SORT_RELEVANCE', 0);
86 86
 /* @deprecated use SphinxClient::SORT_ATTR_DESC */
87
-define('SPH_SORT_ATTR_DESC',     1);
87
+define('SPH_SORT_ATTR_DESC', 1);
88 88
 /* @deprecated use SphinxClient::SORT_ATTR_ASC */
89
-define('SPH_SORT_ATTR_ASC',      2);
89
+define('SPH_SORT_ATTR_ASC', 2);
90 90
 /* @deprecated use SphinxClient::SORT_TIME_SEGMENTS */
91 91
 define('SPH_SORT_TIME_SEGMENTS', 3);
92 92
 /* @deprecated use SphinxClient::SORT_EXTENDED */
93
-define('SPH_SORT_EXTENDED',      4);
93
+define('SPH_SORT_EXTENDED', 4);
94 94
 /* @deprecated use SphinxClient::SORT_EXPR */
95
-define('SPH_SORT_EXPR',          5);
95
+define('SPH_SORT_EXPR', 5);
96 96
 
97 97
 // known filter types
98 98
 /* @deprecated use SphinxClient::FILTER_VALUES */
99
-define('SPH_FILTER_VALUES',     0);
99
+define('SPH_FILTER_VALUES', 0);
100 100
 /* @deprecated use SphinxClient::FILTER_RANGE */
101
-define('SPH_FILTER_RANGE',      1);
101
+define('SPH_FILTER_RANGE', 1);
102 102
 /* @deprecated use SphinxClient::FILTER_FLOAT_RANGE */
103 103
 define('SPH_FILTER_FLOATRANGE', 2);
104 104
 /* @deprecated use SphinxClient::FILTER_STRING */
105
-define('SPH_FILTER_STRING',     3);
105
+define('SPH_FILTER_STRING', 3);
106 106
 
107 107
 // known attribute types
108 108
 /* @deprecated use SphinxClient::ATTR_INTEGER */
109
-define('SPH_ATTR_INTEGER',   1);
109
+define('SPH_ATTR_INTEGER', 1);
110 110
 /* @deprecated use SphinxClient::ATTR_TIMESTAMP */
111 111
 define('SPH_ATTR_TIMESTAMP', 2);
112 112
 /* @deprecated use SphinxClient::ATTR_ORDINAL */
113
-define('SPH_ATTR_ORDINAL',   3);
113
+define('SPH_ATTR_ORDINAL', 3);
114 114
 /* @deprecated use SphinxClient::ATTR_BOOL */
115
-define('SPH_ATTR_BOOL',      4);
115
+define('SPH_ATTR_BOOL', 4);
116 116
 /* @deprecated use SphinxClient::ATTR_FLOAT */
117
-define('SPH_ATTR_FLOAT',     5);
117
+define('SPH_ATTR_FLOAT', 5);
118 118
 /* @deprecated use SphinxClient::ATTR_BIGINT */
119
-define('SPH_ATTR_BIGINT',    6);
119
+define('SPH_ATTR_BIGINT', 6);
120 120
 /* @deprecated use SphinxClient::ATTR_STRING */
121
-define('SPH_ATTR_STRING',    7);
121
+define('SPH_ATTR_STRING', 7);
122 122
 /* @deprecated use SphinxClient::ATTR_FACTORS */
123
-define('SPH_ATTR_FACTORS',   1001);
123
+define('SPH_ATTR_FACTORS', 1001);
124 124
 /* @deprecated use SphinxClient::ATTR_MULTI */
125
-define('SPH_ATTR_MULTI',     0x40000001);
125
+define('SPH_ATTR_MULTI', 0x40000001);
126 126
 /* @deprecated use SphinxClient::ATTR_MULTI64 */
127
-define('SPH_ATTR_MULTI64',   0x40000002);
127
+define('SPH_ATTR_MULTI64', 0x40000002);
128 128
 
129 129
 // known grouping functions
130 130
 /* @deprecated use SphinxClient::GROUP_BY_DAY */
131
-define('SPH_GROUPBY_DAY',      0);
131
+define('SPH_GROUPBY_DAY', 0);
132 132
 /* @deprecated use SphinxClient::GROUP_BY_WEEK */
133
-define('SPH_GROUPBY_WEEK',     1);
133
+define('SPH_GROUPBY_WEEK', 1);
134 134
 /* @deprecated use SphinxClient::GROUP_BY_MONTH */
135
-define('SPH_GROUPBY_MONTH',    2);
135
+define('SPH_GROUPBY_MONTH', 2);
136 136
 /* @deprecated use SphinxClient::GROUP_BY_YEAR */
137
-define('SPH_GROUPBY_YEAR',     3);
137
+define('SPH_GROUPBY_YEAR', 3);
138 138
 /* @deprecated use SphinxClient::GROUP_BY_ATTR */
139
-define('SPH_GROUPBY_ATTR',     4);
139
+define('SPH_GROUPBY_ATTR', 4);
140 140
 /* @deprecated use SphinxClient::GROUP_BY_ATTR_PAIR */
141 141
 define('SPH_GROUPBY_ATTRPAIR', 5);
Please login to merge, or discard this patch.
src/test.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     $select = '';
86 86
     $count = count($args);
87 87
 
88
-    for ($i = 0; $i < $count; $i++) {
88
+    for ($i = 0; $i<$count; $i++) {
89 89
         switch ($args[$i]) {
90 90
             case '-h':
91 91
             case '--host':
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 }
180 180
                 break;
181 181
             default:
182
-                $q .= $args[$i] . ' ';
182
+                $q .= $args[$i].' ';
183 183
         }
184 184
     }
185 185
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         $cl->setSelect($select);
211 211
     }
212 212
     if ($limit) {
213
-        $cl->setLimits(0, $limit, ($limit > 1000) ? $limit : 1000);
213
+        $cl->setLimits(0, $limit, ($limit>1000) ? $limit : 1000);
214 214
     }
215 215
     $cl->setRankingMode($ranker);
216 216
     $res = $cl->query($q, $index);
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
     // print me out
220 220
     ////////////////
221 221
 
222
-    if ($res === false) {
223
-        printf('Query failed: %s.' . PHP_EOL, $cl->getLastError());
222
+    if ($res===false) {
223
+        printf('Query failed: %s.'.PHP_EOL, $cl->getLastError());
224 224
 
225 225
     } else {
226 226
         if ($cl->getLastWarning()) {
227
-            printf('WARNING: %s' . PHP_EOL . PHP_EOL, $cl->getLastWarning());
227
+            printf('WARNING: %s'.PHP_EOL.PHP_EOL, $cl->getLastWarning());
228 228
         }
229 229
 
230 230
         print "Query '$q' retrieved {$res['total']} of {$res['total_found']} matches in {$res['time']} sec.\n";
231
-        print 'Query stats:' . PHP_EOL;
231
+        print 'Query stats:'.PHP_EOL;
232 232
         if (is_array($res['words'])) {
233 233
             foreach ($res['words'] as $word => $info) {
234 234
                 print "    '$word' found {$info['hits']} times in {$info['docs']} documents\n";
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 
239 239
         if (is_array($res['matches'])) {
240 240
             $n = 1;
241
-            print 'Matches:' . PHP_EOL;
241
+            print 'Matches:'.PHP_EOL;
242 242
             foreach ($res['matches'] as $doc_info) {
243 243
                 print "$n. doc_id={$doc_info['id']}, weight={$doc_info['weight']}";
244 244
                 foreach ($res['attrs'] as $attr_name => $attr_type) {
245 245
                     $value = $doc_info['attrs'][$attr_name];
246
-                    if ($attr_type == Client::ATTR_MULTI || $attr_type == Client::ATTR_MULTI64) {
247
-                        $value = '(' . join(',', $value) . ')';
248
-                    } elseif ($attr_type == Client::ATTR_TIMESTAMP) {
246
+                    if ($attr_type==Client::ATTR_MULTI || $attr_type==Client::ATTR_MULTI64) {
247
+                        $value = '('.join(',', $value).')';
248
+                    } elseif ($attr_type==Client::ATTR_TIMESTAMP) {
249 249
                         $value = date('Y-m-d H:i:s', $value);
250 250
                     }
251 251
                     print ", $attr_name=$value";
Please login to merge, or discard this patch.
src/Sphinx/Client.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 
418 418
     public function __destruct()
419 419
     {
420
-        if ($this->socket !== false) {
420
+        if ($this->socket!==false) {
421 421
             fclose($this->socket);
422 422
         }
423 423
     }
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
     public function setServer($host, $port = 0)
458 458
     {
459 459
         assert(is_string($host));
460
-        if ($host[0] == '/') {
461
-            $this->path = 'unix://' . $host;
460
+        if ($host[0]=='/') {
461
+            $this->path = 'unix://'.$host;
462 462
             return;
463 463
         }
464
-        if (substr($host, 0, 7) == 'unix://') {
464
+        if (substr($host, 0, 7)=='unix://') {
465 465
             $this->path = $host;
466 466
             return;
467 467
         }
468 468
 
469 469
         $this->host = $host;
470 470
         $port = intval($port);
471
-        assert(0 <= $port && $port < 65536);
472
-        $this->port = $port == 0 ? 9312 : $port;
471
+        assert(0<=$port && $port<65536);
472
+        $this->port = $port==0 ? 9312 : $port;
473 473
         $this->path = '';
474 474
     }
475 475
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
      */
494 494
     protected function send($handle, $data, $length)
495 495
     {
496
-        if (feof($handle) || fwrite($handle, $data, $length) !== $length) {
496
+        if (feof($handle) || fwrite($handle, $data, $length)!==$length) {
497 497
             $this->error = 'connection unexpectedly closed (timed out?)';
498 498
             $this->conn_error = true;
499 499
             return false;
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
             $port = $this->port;
556 556
         }
557 557
 
558
-        if ($this->timeout <= 0) {
558
+        if ($this->timeout<=0) {
559 559
             $fp = @fsockopen($host, $port, $errno, $errstr);
560 560
         } else {
561 561
             $fp = @fsockopen($host, $port, $errno, $errstr, $this->timeout);
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
         // check version
588 588
         list(, $v) = unpack('N*', fread($fp, 4));
589 589
         $v = (int)$v;
590
-        if ($v < 1) {
590
+        if ($v<1) {
591 591
             fclose($fp);
592 592
             $this->error = "expected searchd protocol version 1+, got version '$v'";
593 593
             return false;
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
         $len = 0;
611 611
 
612 612
         $header = fread($fp, 8);
613
-        if (strlen($header) == 8) {
613
+        if (strlen($header)==8) {
614 614
             list($status, $ver, $len) = array_values(unpack('n2a/Nb', $header));
615 615
             $left = $len;
616
-            while ($left > 0 && !feof($fp)) {
616
+            while ($left>0 && !feof($fp)) {
617 617
                 $chunk = fread($fp, min(8192, $left));
618 618
                 if ($chunk) {
619 619
                     $response .= $chunk;
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
             }
623 623
         }
624 624
 
625
-        if ($this->socket === false) {
625
+        if ($this->socket===false) {
626 626
             fclose($fp);
627 627
         }
628 628
 
629 629
         // check response
630 630
         $read = strlen($response);
631
-        if (!$response || $read != $len) {
631
+        if (!$response || $read!=$len) {
632 632
             $this->error = $len
633 633
                 ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)"
634 634
                 : 'received zero-sized searchd response';
@@ -641,13 +641,13 @@  discard block
 block discarded – undo
641 641
                 $this->warning = substr($response, 4, $wlen);
642 642
                 return substr($response, 4 + $wlen);
643 643
             case self::SEARCHD_ERROR:
644
-                $this->error = 'searchd error: ' . substr($response, 4);
644
+                $this->error = 'searchd error: '.substr($response, 4);
645 645
                 return false;
646 646
             case self::SEARCHD_RETRY:
647
-                $this->error = 'temporary searchd error: ' . substr($response, 4);
647
+                $this->error = 'temporary searchd error: '.substr($response, 4);
648 648
                 return false;
649 649
             case self::SEARCHD_OK:
650
-                if ($ver < $client_ver) { // check version
650
+                if ($ver<$client_ver) { // check version
651 651
                     $this->warning = sprintf(
652 652
                         'searchd command v.%d.%d older than client\'s v.%d.%d, some options might not work',
653 653
                         $ver >> 8,
@@ -680,15 +680,15 @@  discard block
 block discarded – undo
680 680
     {
681 681
         assert(is_int($offset));
682 682
         assert(is_int($limit));
683
-        assert($offset >= 0);
684
-        assert($limit > 0);
685
-        assert($max >= 0);
683
+        assert($offset>=0);
684
+        assert($limit>0);
685
+        assert($max>=0);
686 686
         $this->offset = $offset;
687 687
         $this->limit = $limit;
688
-        if ($max > 0) {
688
+        if ($max>0) {
689 689
             $this->max_matches = $max;
690 690
         }
691
-        if ($cutoff > 0) {
691
+        if ($cutoff>0) {
692 692
             $this->cutoff = $cutoff;
693 693
         }
694 694
     }
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
     public function setMaxQueryTime($max)
702 702
     {
703 703
         assert(is_int($max));
704
-        assert($max >= 0);
704
+        assert($max>=0);
705 705
         $this->max_query_time = $max;
706 706
     }
707 707
 
@@ -734,9 +734,9 @@  discard block
 block discarded – undo
734 734
      * @param int $ranker
735 735
      * @param string $rank_expr
736 736
      */
737
-    public function setRankingMode($ranker, $rank_expr='')
737
+    public function setRankingMode($ranker, $rank_expr = '')
738 738
     {
739
-        assert($ranker === 0 || $ranker >= 1 && $ranker < self::RANK_TOTAL);
739
+        assert($ranker===0 || $ranker>=1 && $ranker<self::RANK_TOTAL);
740 740
         assert(is_string($rank_expr));
741 741
         $this->ranker = $ranker;
742 742
         $this->rank_expr = $rank_expr;
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
             self::SORT_EXPR
760 760
         )));
761 761
         assert(is_string($sort_by));
762
-        assert($mode == self::SORT_RELEVANCE || strlen($sort_by) > 0);
762
+        assert($mode==self::SORT_RELEVANCE || strlen($sort_by)>0);
763 763
 
764 764
         $this->sort = $mode;
765 765
         $this->sort_by = $sort_by;
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
     {
814 814
         assert(is_numeric($min));
815 815
         assert(is_numeric($max));
816
-        assert($min <= $max);
816
+        assert($min<=$max);
817 817
 
818 818
         $this->min_id = $min;
819 819
         $this->max_id = $max;
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
         assert(is_string($attribute));
878 878
         assert(is_numeric($min));
879 879
         assert(is_numeric($max));
880
-        assert($min <= $max);
880
+        assert($min<=$max);
881 881
 
882 882
         $this->filters[] = array(
883 883
             'type' => self::FILTER_RANGE,
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
         assert(is_string($attribute));
903 903
         assert(is_float($min));
904 904
         assert(is_float($max));
905
-        assert($min <= $max);
905
+        assert($min<=$max);
906 906
 
907 907
         $this->filters[] = array(
908 908
             'type' => self::FILTER_FLOAT_RANGE,
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
      */
983 983
     public function setRetries($count, $delay = 0)
984 984
     {
985
-        assert(is_int($count) && $count >= 0);
986
-        assert(is_int($delay) && $delay >= 0);
985
+        assert(is_int($count) && $count>=0);
986
+        assert(is_int($delay) && $delay>=0);
987 987
         $this->retry_count = $count;
988 988
         $this->retry_delay = $delay;
989 989
     }
@@ -1059,12 +1059,12 @@  discard block
 block discarded – undo
1059 1059
             'global_idf',
1060 1060
             'low_priority'
1061 1061
         );
1062
-        $flags = array (
1062
+        $flags = array(
1063 1063
             'reverse_scan' => array(0, 1),
1064 1064
             'sort_method' => array('pq', 'kbuffer'),
1065 1065
             'max_predicted_time' => array(0),
1066 1066
             'boolean_simplify' => array(true, false),
1067
-            'idf' => array ('normalized', 'plain', 'tfidf_normalized', 'tfidf_unnormalized'),
1067
+            'idf' => array('normalized', 'plain', 'tfidf_normalized', 'tfidf_unnormalized'),
1068 1068
             'global_idf' => array(true, false),
1069 1069
             'low_priority' => array(true, false)
1070 1070
         );
@@ -1072,29 +1072,29 @@  discard block
 block discarded – undo
1072 1072
         assert(isset($flag_name, $known_names));
1073 1073
         assert(
1074 1074
             in_array($flag_value, $flags[$flag_name], true) ||
1075
-            ($flag_name == 'max_predicted_time' && is_int($flag_value) && $flag_value >= 0)
1075
+            ($flag_name=='max_predicted_time' && is_int($flag_value) && $flag_value>=0)
1076 1076
         );
1077 1077
 
1078 1078
         switch ($flag_name) {
1079 1079
             case 'reverse_scan':
1080
-                $this->query_flags = setBit($this->query_flags, 0, $flag_value == 1);
1080
+                $this->query_flags = setBit($this->query_flags, 0, $flag_value==1);
1081 1081
                 break;
1082 1082
             case 'sort_method':
1083
-                $this->query_flags = setBit($this->query_flags, 1, $flag_value == 'kbuffer');
1083
+                $this->query_flags = setBit($this->query_flags, 1, $flag_value=='kbuffer');
1084 1084
                 break;
1085 1085
             case 'max_predicted_time':
1086
-                $this->query_flags = setBit($this->query_flags, 2, $flag_value > 0);
1086
+                $this->query_flags = setBit($this->query_flags, 2, $flag_value>0);
1087 1087
                 $this->predicted_time = (int)$flag_value;
1088 1088
                 break;
1089 1089
             case 'boolean_simplify':
1090 1090
                 $this->query_flags = setBit($this->query_flags, 3, $flag_value);
1091 1091
                 break;
1092 1092
             case 'idf':
1093
-                if ($flag_value == 'normalized' || $flag_value == 'plain') {
1094
-                    $this->query_flags = setBit($this->query_flags, 4, $flag_value == 'plain');
1093
+                if ($flag_value=='normalized' || $flag_value=='plain') {
1094
+                    $this->query_flags = setBit($this->query_flags, 4, $flag_value=='plain');
1095 1095
                 }
1096
-                if ($flag_value == 'tfidf_normalized' || $flag_value == 'tfidf_unnormalized') {
1097
-                    $this->query_flags = setBit($this->query_flags, 6, $flag_value == 'tfidf_normalized');
1096
+                if ($flag_value=='tfidf_normalized' || $flag_value=='tfidf_unnormalized') {
1097
+                    $this->query_flags = setBit($this->query_flags, 6, $flag_value=='tfidf_normalized');
1098 1098
                 }
1099 1099
                 break;
1100 1100
             case 'global_idf':
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
         assert(is_string($order_by));
1119 1119
         assert(is_int($offset));
1120 1120
         assert(is_int($limit));
1121
-        assert($offset >= 0);
1122
-        assert($limit > 0);
1121
+        assert($offset>=0);
1122
+        assert($limit>0);
1123 1123
 
1124 1124
         $this->outer_order_by = $order_by;
1125 1125
         $this->outer_offset = $offset;
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
         $this->error = $results[0]['error'];
1199 1199
         $this->warning = $results[0]['warning'];
1200 1200
 
1201
-        if ($results[0]['status'] == self::SEARCHD_ERROR) {
1201
+        if ($results[0]['status']==self::SEARCHD_ERROR) {
1202 1202
             return false;
1203 1203
         } else {
1204 1204
             return $results[0];
@@ -1236,24 +1236,24 @@  discard block
 block discarded – undo
1236 1236
 
1237 1237
         // build request
1238 1238
         $req = pack('NNNNN', $this->query_flags, $this->offset, $this->limit, $this->mode, $this->ranker);
1239
-        if ($this->ranker == self::RANK_EXPR) {
1240
-            $req .= pack('N', strlen($this->rank_expr)) . $this->rank_expr;
1239
+        if ($this->ranker==self::RANK_EXPR) {
1240
+            $req .= pack('N', strlen($this->rank_expr)).$this->rank_expr;
1241 1241
         }
1242 1242
         $req .= pack('N', $this->sort); // (deprecated) sort mode
1243
-        $req .= pack('N', strlen($this->sort_by)) . $this->sort_by;
1244
-        $req .= pack('N', strlen($query)) . $query; // query itself
1243
+        $req .= pack('N', strlen($this->sort_by)).$this->sort_by;
1244
+        $req .= pack('N', strlen($query)).$query; // query itself
1245 1245
         $req .= pack('N', count($this->weights)); // weights
1246 1246
         foreach ($this->weights as $weight) {
1247 1247
             $req .= pack('N', (int)$weight);
1248 1248
         }
1249
-        $req .= pack('N', strlen($index)) . $index; // indexes
1249
+        $req .= pack('N', strlen($index)).$index; // indexes
1250 1250
         $req .= pack('N', 1); // id64 range marker
1251
-        $req .= pack64IntUnsigned($this->min_id) . pack64IntUnsigned($this->max_id); // id64 range
1251
+        $req .= pack64IntUnsigned($this->min_id).pack64IntUnsigned($this->max_id); // id64 range
1252 1252
 
1253 1253
         // filters
1254 1254
         $req .= pack('N', count($this->filters));
1255 1255
         foreach ($this->filters as $filter) {
1256
-            $req .= pack('N', strlen($filter['attr'])) . $filter['attr'];
1256
+            $req .= pack('N', strlen($filter['attr'])).$filter['attr'];
1257 1257
             $req .= pack('N', $filter['type']);
1258 1258
             switch ($filter['type']) {
1259 1259
                 case self::FILTER_VALUES:
@@ -1263,13 +1263,13 @@  discard block
 block discarded – undo
1263 1263
                     }
1264 1264
                     break;
1265 1265
                 case self::FILTER_RANGE:
1266
-                    $req .= pack64IntSigned($filter['min']) . pack64IntSigned($filter['max']);
1266
+                    $req .= pack64IntSigned($filter['min']).pack64IntSigned($filter['max']);
1267 1267
                     break;
1268 1268
                 case self::FILTER_FLOAT_RANGE:
1269
-                    $req .= $this->packFloat($filter['min']) . $this->packFloat($filter['max']);
1269
+                    $req .= $this->packFloat($filter['min']).$this->packFloat($filter['max']);
1270 1270
                     break;
1271 1271
                 case self::FILTER_STRING:
1272
-                    $req .= pack('N', strlen($filter['value'])) . $filter['value'];
1272
+                    $req .= pack('N', strlen($filter['value'])).$filter['value'];
1273 1273
                     break;
1274 1274
                 default:
1275 1275
                     assert(0 && 'internal error: unhandled filter type');
@@ -1278,27 +1278,27 @@  discard block
 block discarded – undo
1278 1278
         }
1279 1279
 
1280 1280
         // group-by clause, max-matches count, group-sort clause, cutoff count
1281
-        $req .= pack('NN', $this->group_func, strlen($this->group_by)) . $this->group_by;
1281
+        $req .= pack('NN', $this->group_func, strlen($this->group_by)).$this->group_by;
1282 1282
         $req .= pack('N', $this->max_matches);
1283
-        $req .= pack('N', strlen($this->group_sort)) . $this->group_sort;
1283
+        $req .= pack('N', strlen($this->group_sort)).$this->group_sort;
1284 1284
         $req .= pack('NNN', $this->cutoff, $this->retry_count, $this->retry_delay);
1285
-        $req .= pack('N', strlen($this->group_distinct)) . $this->group_distinct;
1285
+        $req .= pack('N', strlen($this->group_distinct)).$this->group_distinct;
1286 1286
 
1287 1287
         // anchor point
1288 1288
         if (empty($this->anchor)) {
1289 1289
             $req .= pack('N', 0);
1290 1290
         } else {
1291
-            $a =& $this->anchor;
1291
+            $a = & $this->anchor;
1292 1292
             $req .= pack('N', 1);
1293
-            $req .= pack('N', strlen($a['attrlat'])) . $a['attrlat'];
1294
-            $req .= pack('N', strlen($a['attrlong'])) . $a['attrlong'];
1295
-            $req .= $this->packFloat($a['lat']) . $this->packFloat($a['long']);
1293
+            $req .= pack('N', strlen($a['attrlat'])).$a['attrlat'];
1294
+            $req .= pack('N', strlen($a['attrlong'])).$a['attrlong'];
1295
+            $req .= $this->packFloat($a['lat']).$this->packFloat($a['long']);
1296 1296
         }
1297 1297
 
1298 1298
         // per-index weights
1299 1299
         $req .= pack('N', count($this->index_weights));
1300 1300
         foreach ($this->index_weights as $idx => $weight) {
1301
-            $req .= pack('N', strlen($idx)) . $idx . pack('N', $weight);
1301
+            $req .= pack('N', strlen($idx)).$idx.pack('N', $weight);
1302 1302
         }
1303 1303
 
1304 1304
         // max query time
@@ -1307,16 +1307,16 @@  discard block
 block discarded – undo
1307 1307
         // per-field weights
1308 1308
         $req .= pack('N', count($this->field_weights));
1309 1309
         foreach ($this->field_weights as $field => $weight) {
1310
-            $req .= pack('N', strlen($field)) . $field . pack('N', $weight);
1310
+            $req .= pack('N', strlen($field)).$field.pack('N', $weight);
1311 1311
         }
1312 1312
 
1313 1313
         // comment
1314
-        $req .= pack('N', strlen($comment)) . $comment;
1314
+        $req .= pack('N', strlen($comment)).$comment;
1315 1315
 
1316 1316
         // attribute overrides
1317 1317
         $req .= pack('N', count($this->overrides));
1318 1318
         foreach ($this->overrides as $key => $entry) {
1319
-            $req .= pack('N', strlen($entry['attr'])) . $entry['attr'];
1319
+            $req .= pack('N', strlen($entry['attr'])).$entry['attr'];
1320 1320
             $req .= pack('NN', $entry['type'], count($entry['values']));
1321 1321
             foreach ($entry['values'] as $id => $val) {
1322 1322
                 assert(is_numeric($id));
@@ -1338,14 +1338,14 @@  discard block
 block discarded – undo
1338 1338
         }
1339 1339
 
1340 1340
         // select-list
1341
-        $req .= pack('N', strlen($this->select)) . $this->select;
1341
+        $req .= pack('N', strlen($this->select)).$this->select;
1342 1342
 
1343 1343
         // max_predicted_time
1344
-        if ($this->predicted_time > 0) {
1344
+        if ($this->predicted_time>0) {
1345 1345
             $req .= pack('N', (int)$this->predicted_time);
1346 1346
         }
1347 1347
 
1348
-        $req .= pack('N', strlen($this->outer_order_by)) . $this->outer_order_by;
1348
+        $req .= pack('N', strlen($this->outer_order_by)).$this->outer_order_by;
1349 1349
         $req .= pack('NN', $this->outer_offset, $this->outer_limit);
1350 1350
         if ($this->has_outer) {
1351 1351
             $req .= pack('N', 1);
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
         // mbstring workaround
1377 1377
         $this->mbPush();
1378 1378
 
1379
-        if (($fp = $this->connect()) === false) {
1379
+        if (($fp = $this->connect())===false) {
1380 1380
             $this->mbPop();
1381 1381
             return false;
1382 1382
         }
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
         $req = join('', $this->reqs);
1387 1387
         $len = 8 + strlen($req);
1388 1388
         // add header
1389
-        $req = pack('nnNNN', self::SEARCHD_COMMAND_SEARCH, self::VER_COMMAND_SEARCH, $len, 0, $nreqs) . $req;
1389
+        $req = pack('nnNNN', self::SEARCHD_COMMAND_SEARCH, self::VER_COMMAND_SEARCH, $len, 0, $nreqs).$req;
1390 1390
 
1391 1391
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, self::VER_COMMAND_SEARCH))) {
1392 1392
             $this->mbPop();
@@ -1414,9 +1414,9 @@  discard block
 block discarded – undo
1414 1414
         $max = strlen($response); // max position for checks, to protect against broken responses
1415 1415
 
1416 1416
         $results = array();
1417
-        for ($ires = 0; $ires < $nreqs && $p < $max; $ires++) {
1417
+        for ($ires = 0; $ires<$nreqs && $p<$max; $ires++) {
1418 1418
             $results[] = array();
1419
-            $result =& $results[$ires];
1419
+            $result = & $results[$ires];
1420 1420
 
1421 1421
             $result['error'] = '';
1422 1422
             $result['warning'] = '';
@@ -1425,13 +1425,13 @@  discard block
 block discarded – undo
1425 1425
             list(, $status) = unpack('N*', substr($response, $p, 4));
1426 1426
             $p += 4;
1427 1427
             $result['status'] = $status;
1428
-            if ($status != self::SEARCHD_OK) {
1428
+            if ($status!=self::SEARCHD_OK) {
1429 1429
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1430 1430
                 $p += 4;
1431 1431
                 $message = substr($response, $p, $len);
1432 1432
                 $p += $len;
1433 1433
 
1434
-                if ($status == self::SEARCHD_WARNING) {
1434
+                if ($status==self::SEARCHD_WARNING) {
1435 1435
                     $result['warning'] = $message;
1436 1436
                 } else {
1437 1437
                     $result['error'] = $message;
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 
1446 1446
             list(, $nfields) = unpack('N*', substr($response, $p, 4));
1447 1447
             $p += 4;
1448
-            while ($nfields --> 0 && $p < $max) {
1448
+            while ($nfields-->0 && $p<$max) {
1449 1449
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1450 1450
                 $p += 4;
1451 1451
                 $fields[] = substr($response, $p, $len);
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 
1456 1456
             list(, $n_attrs) = unpack('N*', substr($response, $p, 4));
1457 1457
             $p += 4;
1458
-            while ($n_attrs --> 0 && $p < $max) {
1458
+            while ($n_attrs-->0 && $p<$max) {
1459 1459
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1460 1460
                 $p += 4;
1461 1461
                 $attr = substr($response, $p, $len);
@@ -1474,7 +1474,7 @@  discard block
 block discarded – undo
1474 1474
 
1475 1475
             // read matches
1476 1476
             $idx = -1;
1477
-            while ($count --> 0 && $p < $max) {
1477
+            while ($count-->0 && $p<$max) {
1478 1478
                 // index into result array
1479 1479
                 $idx++;
1480 1480
 
@@ -1502,14 +1502,14 @@  discard block
 block discarded – undo
1502 1502
                 $attr_values = array();
1503 1503
                 foreach ($attrs as $attr => $type) {
1504 1504
                     // handle 64bit int
1505
-                    if ($type == self::ATTR_BIGINT) {
1505
+                    if ($type==self::ATTR_BIGINT) {
1506 1506
                         $attr_values[$attr] = unpack64IntSigned(substr($response, $p, 8));
1507 1507
                         $p += 8;
1508 1508
                         continue;
1509 1509
                     }
1510 1510
 
1511 1511
                     // handle floats
1512
-                    if ($type == self::ATTR_FLOAT) {
1512
+                    if ($type==self::ATTR_FLOAT) {
1513 1513
                         list(, $u_value) = unpack('N*', substr($response, $p, 4));
1514 1514
                         $p += 4;
1515 1515
                         list(, $f_value) = unpack('f*', pack('L', $u_value));
@@ -1520,28 +1520,28 @@  discard block
 block discarded – undo
1520 1520
                     // handle everything else as unsigned int
1521 1521
                     list(, $val) = unpack('N*', substr($response, $p, 4));
1522 1522
                     $p += 4;
1523
-                    if ($type == self::ATTR_MULTI) {
1523
+                    if ($type==self::ATTR_MULTI) {
1524 1524
                         $attr_values[$attr] = array();
1525 1525
                         $n_values = $val;
1526
-                        while ($n_values --> 0 && $p < $max) {
1526
+                        while ($n_values-->0 && $p<$max) {
1527 1527
                             list(, $val) = unpack('N*', substr($response, $p, 4));
1528 1528
                             $p += 4;
1529 1529
                             $attr_values[$attr][] = fixUInt($val);
1530 1530
                         }
1531
-                    } elseif ($type == self::ATTR_MULTI64) {
1531
+                    } elseif ($type==self::ATTR_MULTI64) {
1532 1532
                         $attr_values[$attr] = array();
1533 1533
                         $n_values = $val;
1534
-                        while ($n_values > 0 && $p < $max) {
1534
+                        while ($n_values>0 && $p<$max) {
1535 1535
                             $attr_values[$attr][] = unpack64IntSigned(substr($response, $p, 8));
1536 1536
                             $p += 8;
1537 1537
                             $n_values -= 2;
1538 1538
                         }
1539
-                    } elseif ($type == self::ATTR_STRING) {
1539
+                    } elseif ($type==self::ATTR_STRING) {
1540 1540
                         $attr_values[$attr] = substr($response, $p, $val);
1541 1541
                         $p += $val;
1542
-                    } elseif ($type == self::ATTR_FACTORS) {
1542
+                    } elseif ($type==self::ATTR_FACTORS) {
1543 1543
                         $attr_values[$attr] = substr($response, $p, $val - 4);
1544
-                        $p += $val-4;
1544
+                        $p += $val - 4;
1545 1545
                     } else {
1546 1546
                         $attr_values[$attr] = fixUInt($val);
1547 1547
                     }
@@ -1560,14 +1560,14 @@  discard block
 block discarded – undo
1560 1560
             $result['time'] = sprintf('%.3f', $msecs / 1000);
1561 1561
             $p += 16;
1562 1562
 
1563
-            while ($words --> 0 && $p < $max) {
1563
+            while ($words-->0 && $p<$max) {
1564 1564
                 list(, $len) = unpack('N*', substr($response, $p, 4));
1565 1565
                 $p += 4;
1566 1566
                 $word = substr($response, $p, $len);
1567 1567
                 $p += $len;
1568 1568
                 list($docs, $hits) = array_values(unpack('N*N*', substr($response, $p, 8)));
1569 1569
                 $p += 8;
1570
-                $result['words'][$word] = array (
1570
+                $result['words'][$word] = array(
1571 1571
                     'docs' => sprintf('%u', $docs),
1572 1572
                     'hits' => sprintf('%u', $hits)
1573 1573
                 );
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
 
1601 1601
         $this->mbPush();
1602 1602
 
1603
-        if (($fp = $this->connect()) === false) {
1603
+        if (($fp = $this->connect())===false) {
1604 1604
             $this->mbPop();
1605 1605
             return false;
1606 1606
         }
@@ -1669,24 +1669,24 @@  discard block
 block discarded – undo
1669 1669
             $flags |= 1024;
1670 1670
         }
1671 1671
         $req = pack('NN', 0, $flags); // mode=0, flags=$flags
1672
-        $req .= pack('N', strlen($index)) . $index; // req index
1673
-        $req .= pack('N', strlen($words)) . $words; // req words
1672
+        $req .= pack('N', strlen($index)).$index; // req index
1673
+        $req .= pack('N', strlen($words)).$words; // req words
1674 1674
 
1675 1675
         // options
1676
-        $req .= pack('N', strlen($opts['before_match'])) . $opts['before_match'];
1677
-        $req .= pack('N', strlen($opts['after_match'])) . $opts['after_match'];
1678
-        $req .= pack('N', strlen($opts['chunk_separator'])) . $opts['chunk_separator'];
1676
+        $req .= pack('N', strlen($opts['before_match'])).$opts['before_match'];
1677
+        $req .= pack('N', strlen($opts['after_match'])).$opts['after_match'];
1678
+        $req .= pack('N', strlen($opts['chunk_separator'])).$opts['chunk_separator'];
1679 1679
         $req .= pack('NN', (int)$opts['limit'], (int)$opts['around']);
1680 1680
         // v.1.2
1681 1681
         $req .= pack('NNN', (int)$opts['limit_passages'], (int)$opts['limit_words'], (int)$opts['start_passage_id']);
1682
-        $req .= pack('N', strlen($opts['html_strip_mode'])) . $opts['html_strip_mode'];
1683
-        $req .= pack('N', strlen($opts['passage_boundary'])) . $opts['passage_boundary'];
1682
+        $req .= pack('N', strlen($opts['html_strip_mode'])).$opts['html_strip_mode'];
1683
+        $req .= pack('N', strlen($opts['passage_boundary'])).$opts['passage_boundary'];
1684 1684
 
1685 1685
         // documents
1686 1686
         $req .= pack('N', count($docs));
1687 1687
         foreach ($docs as $doc) {
1688 1688
             assert(is_string($doc));
1689
-            $req .= pack('N', strlen($doc)) . $doc;
1689
+            $req .= pack('N', strlen($doc)).$doc;
1690 1690
         }
1691 1691
 
1692 1692
         ////////////////////////////
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
         ////////////////////////////
1695 1695
 
1696 1696
         $len = strlen($req);
1697
-        $req = pack('nnN', self::SEARCHD_COMMAND_EXCERPT, self::VER_COMMAND_EXCERPT, $len) . $req; // add header
1697
+        $req = pack('nnN', self::SEARCHD_COMMAND_EXCERPT, self::VER_COMMAND_EXCERPT, $len).$req; // add header
1698 1698
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, self::VER_COMMAND_EXCERPT))) {
1699 1699
             $this->mbPop();
1700 1700
             return false;
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
             list(, $len) = unpack('N*', substr($response, $pos, 4));
1713 1713
             $pos += 4;
1714 1714
 
1715
-            if ($pos + $len > $rlen) {
1715
+            if ($pos + $len>$rlen) {
1716 1716
                 $this->error = 'incomplete reply';
1717 1717
                 $this->mbPop();
1718 1718
                 return false;
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 
1749 1749
         $this->mbPush();
1750 1750
 
1751
-        if (($fp = $this->connect()) === false) {
1751
+        if (($fp = $this->connect())===false) {
1752 1752
             $this->mbPop();
1753 1753
             return false;
1754 1754
         }
@@ -1758,8 +1758,8 @@  discard block
 block discarded – undo
1758 1758
         /////////////////
1759 1759
 
1760 1760
         // v.1.0 req
1761
-        $req  = pack('N', strlen($query)) . $query; // req query
1762
-        $req .= pack('N', strlen($index)) . $index; // req index
1761
+        $req  = pack('N', strlen($query)).$query; // req query
1762
+        $req .= pack('N', strlen($index)).$index; // req index
1763 1763
         $req .= pack('N', (int)$hits);
1764 1764
 
1765 1765
         ////////////////////////////
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
         ////////////////////////////
1768 1768
 
1769 1769
         $len = strlen($req);
1770
-        $req = pack('nnN', self::SEARCHD_COMMAND_KEYWORDS, self::VER_COMMAND_KEYWORDS, $len) . $req; // add header
1770
+        $req = pack('nnN', self::SEARCHD_COMMAND_KEYWORDS, self::VER_COMMAND_KEYWORDS, $len).$req; // add header
1771 1771
         if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, self::VER_COMMAND_KEYWORDS))) {
1772 1772
             $this->mbPop();
1773 1773
             return false;
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
         $rlen = strlen($response);
1783 1783
         list(, $nwords) = unpack('N*', substr($response, $pos, 4));
1784 1784
         $pos += 4;
1785
-        for ($i = 0; $i < $nwords; $i++) {
1785
+        for ($i = 0; $i<$nwords; $i++) {
1786 1786
             list(, $len) = unpack('N*', substr($response, $pos, 4));
1787 1787
             $pos += 4;
1788 1788
             $tokenized = $len ? substr($response, $pos, $len) : '';
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
                 $res[$i]['hits'] = $nhits;
1806 1806
             }
1807 1807
 
1808
-            if ($pos > $rlen) {
1808
+            if ($pos>$rlen) {
1809 1809
                 $this->error = 'incomplete reply';
1810 1810
                 $this->mbPop();
1811 1811
                 return false;
@@ -1823,8 +1823,8 @@  discard block
 block discarded – undo
1823 1823
      */
1824 1824
     public function escapeString($string)
1825 1825
     {
1826
-        $from = array('\\', '(',')','|','-','!','@','~','"','&', '/', '^', '$', '=', '<');
1827
-        $to   = array('\\\\', '\(','\)','\|','\-','\!','\@','\~','\"', '\&', '\/', '\^', '\$', '\=', '\<');
1826
+        $from = array('\\', '(', ')', '|', '-', '!', '@', '~', '"', '&', '/', '^', '$', '=', '<');
1827
+        $to   = array('\\\\', '\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/', '\^', '\$', '\=', '\<');
1828 1828
 
1829 1829
         return str_replace($from, $to, $string);
1830 1830
     }
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
         foreach ($values as $id => $entry) {
1860 1860
             assert(is_numeric($id));
1861 1861
             assert(is_array($entry));
1862
-            assert(count($entry) == count($attrs));
1862
+            assert(count($entry)==count($attrs));
1863 1863
             foreach ($entry as $v) {
1864 1864
                 if ($mva) {
1865 1865
                     assert(is_array($v));
@@ -1874,12 +1874,12 @@  discard block
 block discarded – undo
1874 1874
 
1875 1875
         // build request
1876 1876
         $this->mbPush();
1877
-        $req = pack('N', strlen($index)) . $index;
1877
+        $req = pack('N', strlen($index)).$index;
1878 1878
 
1879 1879
         $req .= pack('N', count($attrs));
1880 1880
         $req .= pack('N', $ignore_non_existent ? 1 : 0);
1881 1881
         foreach ($attrs as $attr) {
1882
-            $req .= pack('N', strlen($attr)) . $attr;
1882
+            $req .= pack('N', strlen($attr)).$attr;
1883 1883
             $req .= pack('N', $mva ? 1 : 0);
1884 1884
         }
1885 1885
 
@@ -1897,13 +1897,13 @@  discard block
 block discarded – undo
1897 1897
         }
1898 1898
 
1899 1899
         // connect, send query, get response
1900
-        if (($fp = $this->connect()) === false) {
1900
+        if (($fp = $this->connect())===false) {
1901 1901
             $this->mbPop();
1902 1902
             return -1;
1903 1903
         }
1904 1904
 
1905 1905
         $len = strlen($req);
1906
-        $req = pack('nnN', self::SEARCHD_COMMAND_UPDATE, self::VER_COMMAND_UPDATE, $len) . $req; // add header
1906
+        $req = pack('nnN', self::SEARCHD_COMMAND_UPDATE, self::VER_COMMAND_UPDATE, $len).$req; // add header
1907 1907
         if (!$this->send($fp, $req, $len + 8)) {
1908 1908
             $this->mbPop();
1909 1909
             return -1;
@@ -1929,11 +1929,11 @@  discard block
 block discarded – undo
1929 1929
      */
1930 1930
     public function open()
1931 1931
     {
1932
-        if ($this->socket !== false) {
1932
+        if ($this->socket!==false) {
1933 1933
             $this->error = 'already connected';
1934 1934
             return false;
1935 1935
         }
1936
-        if (($fp = $this->connect()) === false)
1936
+        if (($fp = $this->connect())===false)
1937 1937
             return false;
1938 1938
 
1939 1939
         // command, command version = 0, body length = 4, body = 1
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
      */
1952 1952
     public function close()
1953 1953
     {
1954
-        if ($this->socket === false) {
1954
+        if ($this->socket===false) {
1955 1955
             $this->error = 'not connected';
1956 1956
             return false;
1957 1957
         }
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
         assert(is_bool($session));
1977 1977
 
1978 1978
         $this->mbPush();
1979
-        if (($fp = $this->connect()) === false) {
1979
+        if (($fp = $this->connect())===false) {
1980 1980
             $this->mbPop();
1981 1981
             return false;
1982 1982
         }
@@ -1994,8 +1994,8 @@  discard block
 block discarded – undo
1994 1994
         $p += 8;
1995 1995
 
1996 1996
         $res = array();
1997
-        for ($i = 0; $i < $rows; $i++) {
1998
-            for ($j = 0; $j < $cols; $j++) {
1997
+        for ($i = 0; $i<$rows; $i++) {
1998
+            for ($j = 0; $j<$cols; $j++) {
1999 1999
                 list(, $len) = unpack('N*', substr($response, $p, 4));
2000 2000
                 $p += 4;
2001 2001
                 $res[$i][] = substr($response, $p, $len);
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
     public function flushAttributes()
2018 2018
     {
2019 2019
         $this->mbPush();
2020
-        if (($fp = $this->connect()) === false) {
2020
+        if (($fp = $this->connect())===false) {
2021 2021
             $this->mbPop();
2022 2022
             return -1;
2023 2023
         }
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
         }
2030 2030
 
2031 2031
         $tag = -1;
2032
-        if (strlen($response) == 4) {
2032
+        if (strlen($response)==4) {
2033 2033
             list(, $tag) = unpack('N*', $response);
2034 2034
         } else {
2035 2035
             $this->error = 'unexpected response length';
Please login to merge, or discard this patch.