@@ -40,7 +40,7 @@ |
||
40 | 40 | */ |
41 | 41 | public function writeLine($line, $eol = PHP_EOL) |
42 | 42 | { |
43 | - return $this->write($line . $eol); |
|
43 | + return $this->write($line.$eol); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -254,7 +254,9 @@ discard block |
||
254 | 254 | $this->getContext() |
255 | 255 | ); |
256 | 256 | restore_error_handler(); |
257 | - if ($e) throw $e; |
|
257 | + if ($e) { |
|
258 | + throw $e; |
|
259 | + } |
|
258 | 260 | } |
259 | 261 | return $this->isConnected(); |
260 | 262 | } |
@@ -328,7 +330,9 @@ discard block |
||
328 | 330 | public function setMode($mode = null) |
329 | 331 | { |
330 | 332 | $this->assertNotConnected(__METHOD__); |
331 | - if (is_null($mode)) $mode = "r+b"; |
|
333 | + if (is_null($mode)) { |
|
334 | + $mode = "r+b"; |
|
335 | + } |
|
332 | 336 | |
333 | 337 | $mode = substr($mode, 0, 3); |
334 | 338 | $rest = substr($mode, 1); |
@@ -436,7 +440,9 @@ discard block |
||
436 | 440 | */ |
437 | 441 | protected function setLazy($lazy) |
438 | 442 | { |
439 | - if (is_null($lazy)) $lazy = true; |
|
443 | + if (is_null($lazy)) { |
|
444 | + $lazy = true; |
|
445 | + } |
|
440 | 446 | $this->lazy = (boolean) $lazy; |
441 | 447 | return $this; |
442 | 448 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | { |
240 | 240 | if (!$this->isConnected()) { |
241 | 241 | $e = null; |
242 | - $errhandler = function () use (&$e) { |
|
242 | + $errhandler = function() use (&$e) { |
|
243 | 243 | $e = new IOException(sprintf( |
244 | 244 | "Could not open connection for %s using mode %s", |
245 | 245 | $this->getUri(), |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | $this->updateContext(); |
556 | 556 | return $this; |
557 | 557 | } |
558 | - throw new InvalidArgumentException("Context options must be an array, got: " . gettype($options)); |
|
558 | + throw new InvalidArgumentException("Context options must be an array, got: ".gettype($options)); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | $this->updateContext(); |
576 | 576 | return $this; |
577 | 577 | } |
578 | - throw new InvalidArgumentException("Context parameters must be an array, got: " . gettype($params)); |
|
578 | + throw new InvalidArgumentException("Context parameters must be an array, got: ".gettype($params)); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * |
234 | 234 | * Creates and returns a Stream object for this resource |
235 | 235 | * |
236 | - * @return resource The underlying stream resource |
|
236 | + * @return Stream The underlying stream resource |
|
237 | 237 | */ |
238 | 238 | public function __invoke() |
239 | 239 | { |
@@ -853,6 +853,7 @@ discard block |
||
853 | 853 | * only be called on unopened stream resources. |
854 | 854 | * |
855 | 855 | * @param string The method that is asserting |
856 | + * @param string $method |
|
856 | 857 | * @return void |
857 | 858 | * @throws \CSVelte\Exception\IOException if stream is open |
858 | 859 | */ |
@@ -869,6 +870,7 @@ discard block |
||
869 | 870 | * Used internally to ensure that a given stream wrapper is valid and available |
870 | 871 | * |
871 | 872 | * @param string The name of the stream wrapper |
873 | + * @param string $name |
|
872 | 874 | * @return void |
873 | 875 | * @throws \InvalidArgumentException if wrapper doesn't exist |
874 | 876 | */ |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | |
186 | 186 | // ok we're opening a new stream resource handle |
187 | 187 | $this->setUri($uri) |
188 | - ->setMode($mode) |
|
189 | - ->setLazy($lazy) |
|
190 | - ->setUseIncludePath($use_include_path) |
|
191 | - ->setContext($context_options, $context_params); |
|
188 | + ->setMode($mode) |
|
189 | + ->setLazy($lazy) |
|
190 | + ->setUseIncludePath($use_include_path) |
|
191 | + ->setContext($context_options, $context_params); |
|
192 | 192 | if (!$this->isLazy()) { |
193 | 193 | $this->connect(); |
194 | 194 | } |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | |
352 | 352 | $this->flag = ''; |
353 | 353 | $this->setBaseMode($base) |
354 | - ->setIsPlus($plus == '+') |
|
355 | - ->setIsText($flag == 't') |
|
356 | - ->setIsBinary($flag == 'b'); |
|
354 | + ->setIsPlus($plus == '+') |
|
355 | + ->setIsText($flag == 't') |
|
356 | + ->setIsBinary($flag == 'b'); |
|
357 | 357 | |
358 | 358 | return $this; |
359 | 359 | } |
@@ -267,16 +267,16 @@ |
||
267 | 267 | return strlen($data); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Seekability accessor. |
|
272 | - * |
|
273 | - * Despite the fact that any class that implements this interface must also |
|
274 | - * define methods such as seek, that is no guarantee that an |
|
275 | - * object will necessarily be seekable. This method should tell the user |
|
276 | - * whether a stream is, in fact, seekable. |
|
277 | - * |
|
278 | - * @return boolean True if seekable, false otherwise |
|
279 | - */ |
|
270 | + /** |
|
271 | + * Seekability accessor. |
|
272 | + * |
|
273 | + * Despite the fact that any class that implements this interface must also |
|
274 | + * define methods such as seek, that is no guarantee that an |
|
275 | + * object will necessarily be seekable. This method should tell the user |
|
276 | + * whether a stream is, in fact, seekable. |
|
277 | + * |
|
278 | + * @return boolean True if seekable, false otherwise |
|
279 | + */ |
|
280 | 280 | public function isSeekable() |
281 | 281 | { |
282 | 282 | return $this->seekable; |
@@ -138,7 +138,9 @@ |
||
138 | 138 | public function readChunk($start = null, $length = null) |
139 | 139 | { |
140 | 140 | //dd($this->buffer, false); |
141 | - if ($this->buffer === false) return false; |
|
141 | + if ($this->buffer === false) { |
|
142 | + return false; |
|
143 | + } |
|
142 | 144 | $top = substr($this->buffer, 0, $start); |
143 | 145 | $data = substr($this->buffer, $start, $length); |
144 | 146 | $bottom = substr($this->buffer, $start + $length); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * Read in the specified amount of characters from the input source |
120 | 120 | * |
121 | 121 | * @param integer Amount of characters to read from input source |
122 | - * @return string|boolean The specified amount of characters read from input source |
|
122 | + * @return false|string The specified amount of characters read from input source |
|
123 | 123 | */ |
124 | 124 | public function read($chars) |
125 | 125 | { |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * |
246 | 246 | * After the stream has been detached, the stream is in an unusable state. |
247 | 247 | * |
248 | - * @return BufferStream|null Underlying PHP stream, if any |
|
248 | + * @return string|false Underlying PHP stream, if any |
|
249 | 249 | */ |
250 | 250 | public function detach() |
251 | 251 | { |
@@ -136,7 +136,9 @@ discard block |
||
136 | 136 | { |
137 | 137 | $resource = (new Resource($uri, $mode)) |
138 | 138 | ->setContextResource($context); |
139 | - if (!$lazy) $resource->connect(); |
|
139 | + if (!$lazy) { |
|
140 | + $resource->connect(); |
|
141 | + } |
|
140 | 142 | return new self($resource); |
141 | 143 | } |
142 | 144 | |
@@ -169,7 +171,9 @@ discard block |
||
169 | 171 | } |
170 | 172 | // if a certain value was requested, return it |
171 | 173 | // otherwise, return entire array |
172 | - if (is_null($key)) return $this->meta; |
|
174 | + if (is_null($key)) { |
|
175 | + return $this->meta; |
|
176 | + } |
|
173 | 177 | return (array_key_exists($key, $this->meta)) ? $this->meta[$key] : null; |
174 | 178 | } |
175 | 179 | } |
@@ -315,7 +319,9 @@ discard block |
||
315 | 319 | public function read($length) |
316 | 320 | { |
317 | 321 | $this->assertIsReadable(); |
318 | - if ($this->eof()) return false; |
|
322 | + if ($this->eof()) { |
|
323 | + return false; |
|
324 | + } |
|
319 | 325 | return fread($this->resource->getHandle(), $length); |
320 | 326 | } |
321 | 327 |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | public function toArray() |
195 | 195 | { |
196 | 196 | $data = []; |
197 | - foreach($this->data as $key => $val) { |
|
197 | + foreach ($this->data as $key => $val) { |
|
198 | 198 | $data[$key] = (is_object($val) && method_exists($val, 'toArray')) ? $val->toArray() : $val; |
199 | 199 | } |
200 | 200 | return $data; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | if ($i === $pos) return $key; |
370 | 370 | $i++; |
371 | 371 | } |
372 | - throw new OutOfBoundsException("Collection data does not contain a key at given position: " . $pos); |
|
372 | + throw new OutOfBoundsException("Collection data does not contain a key at given position: ".$pos); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | return $this->data[$key]; |
555 | 555 | } else { |
556 | 556 | if ($throwExc) { |
557 | - throw new OutOfBoundsException("Collection data does not contain value for given key: " . $key); |
|
557 | + throw new OutOfBoundsException("Collection data does not contain value for given key: ".$key); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | return $default; |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | public function pairs($alt = false) |
900 | 900 | { |
901 | 901 | return new self(array_map( |
902 | - function ($key, $val) use ($alt) { |
|
902 | + function($key, $val) use ($alt) { |
|
903 | 903 | if ($alt) { |
904 | 904 | return [$key => $val]; |
905 | 905 | } else { |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | if (false !== ($condRet = $this->if2DMapInternalMethod(__METHOD__))) { |
982 | 982 | return $condRet; |
983 | 983 | } |
984 | - $strvals = $this->map(function($val){ |
|
984 | + $strvals = $this->map(function($val) { |
|
985 | 985 | return (string) $val; |
986 | 986 | }); |
987 | 987 | $this->assertNumericValues(); |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | $this->assertIsTabular(); |
1096 | 1096 | return $this->sort(function($a, $b) use ($key, $cmp) { |
1097 | 1097 | if (!isset($a[$key]) || !isset($b[$key])) { |
1098 | - throw new RuntimeException('Cannot order collection by non-existant key: ' . $key); |
|
1098 | + throw new RuntimeException('Cannot order collection by non-existant key: '.$key); |
|
1099 | 1099 | } |
1100 | 1100 | if (is_null($cmp)) { |
1101 | 1101 | return strcasecmp($a[$key], $b[$key]); |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | */ |
1143 | 1143 | public function is2D() |
1144 | 1144 | { |
1145 | - return !$this->contains(function($val){ |
|
1145 | + return !$this->contains(function($val) { |
|
1146 | 1146 | return !is_array($val); |
1147 | 1147 | }); |
1148 | 1148 | return false; |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | |
1213 | 1213 | protected function assertNumericValues() |
1214 | 1214 | { |
1215 | - if ($this->contains(function($val){ |
|
1215 | + if ($this->contains(function($val) { |
|
1216 | 1216 | return !is_numeric($val); |
1217 | 1217 | })) { |
1218 | 1218 | // can't average non-numeric data |
@@ -1228,6 +1228,6 @@ discard block |
||
1228 | 1228 | if (is_null($data) || is_array($data) || $data instanceof Iterator) { |
1229 | 1229 | return; |
1230 | 1230 | } |
1231 | - throw new InvalidArgumentException("Invalid type for collection data: " . gettype($data)); |
|
1231 | + throw new InvalidArgumentException("Invalid type for collection data: ".gettype($data)); |
|
1232 | 1232 | } |
1233 | 1233 | } |
@@ -153,8 +153,9 @@ discard block |
||
153 | 153 | } |
154 | 154 | } else { |
155 | 155 | if (is_null($key)) { |
156 | - if (is_array($val)) return $this->merge($val); |
|
157 | - else { |
|
156 | + if (is_array($val)) { |
|
157 | + return $this->merge($val); |
|
158 | + } else { |
|
158 | 159 | if (is_callable($val)) { |
159 | 160 | return $this->map($val); |
160 | 161 | } /*else { |
@@ -248,7 +249,9 @@ discard block |
||
248 | 249 | { |
249 | 250 | if (is_callable($callback = $val)) { |
250 | 251 | foreach ($this->data as $key => $val) { |
251 | - if ($callback($val, $key)) return true; |
|
252 | + if ($callback($val, $key)) { |
|
253 | + return true; |
|
254 | + } |
|
252 | 255 | } |
253 | 256 | } elseif (in_array($val, $this->data)) { |
254 | 257 | return (is_null($key) || (isset($this->data[$key]) && $this->data[$key] == $val)); |
@@ -366,7 +369,9 @@ discard block |
||
366 | 369 | { |
367 | 370 | $i = 0; |
368 | 371 | foreach ($this->data as $key => $val) { |
369 | - if ($i === $pos) return $key; |
|
372 | + if ($i === $pos) { |
|
373 | + return $key; |
|
374 | + } |
|
370 | 375 | $i++; |
371 | 376 | } |
372 | 377 | throw new OutOfBoundsException("Collection data does not contain a key at given position: " . $pos); |
@@ -744,7 +749,9 @@ discard block |
||
744 | 749 | { |
745 | 750 | foreach ($this->data as $key => $val) { |
746 | 751 | if (!$ret = $callback($val, $key)) { |
747 | - if ($ret === false) break; |
|
752 | + if ($ret === false) { |
|
753 | + break; |
|
754 | + } |
|
748 | 755 | } |
749 | 756 | } |
750 | 757 | return $this; |
@@ -776,7 +783,9 @@ discard block |
||
776 | 783 | { |
777 | 784 | $keys = []; |
778 | 785 | foreach ($this->data as $key => $val) { |
779 | - if (false === $callback($val, $key)) $keys[$key] = true; |
|
786 | + if (false === $callback($val, $key)) { |
|
787 | + $keys[$key] = true; |
|
788 | + } |
|
780 | 789 | } |
781 | 790 | return new self(array_diff_key($this->data, $keys)); |
782 | 791 | } |
@@ -793,7 +802,9 @@ discard block |
||
793 | 802 | public function first(Callable $callback) |
794 | 803 | { |
795 | 804 | foreach ($this->data as $key => $val) { |
796 | - if ($callback($val, $key)) return $val; |
|
805 | + if ($callback($val, $key)) { |
|
806 | + return $val; |
|
807 | + } |
|
797 | 808 | } |
798 | 809 | return null; |
799 | 810 | } |
@@ -811,7 +822,9 @@ discard block |
||
811 | 822 | { |
812 | 823 | $elem = null; |
813 | 824 | foreach ($this->data as $key => $val) { |
814 | - if ($callback($val, $key)) $elem = $val; |
|
825 | + if ($callback($val, $key)) { |
|
826 | + $elem = $val; |
|
827 | + } |
|
815 | 828 | } |
816 | 829 | return $elem; |
817 | 830 | } |
@@ -1062,7 +1075,9 @@ discard block |
||
1062 | 1075 | */ |
1063 | 1076 | public function sort(Callable $callback = null, $preserve_keys = true) |
1064 | 1077 | { |
1065 | - if (is_null($callback)) $callback = 'strcasecmp'; |
|
1078 | + if (is_null($callback)) { |
|
1079 | + $callback = 'strcasecmp'; |
|
1080 | + } |
|
1066 | 1081 | if (!is_callable($callback)) { |
1067 | 1082 | throw new InvalidArgumentException(sprintf( |
1068 | 1083 | 'Invalid argument supplied for %s. Expected %s, got: "%s".', |
@@ -1172,7 +1187,9 @@ discard block |
||
1172 | 1187 | |
1173 | 1188 | // if the list of array keys is shorter than the total amount of items in |
1174 | 1189 | // the collection, than this is not tabular data |
1175 | - if (count($test) != count($this)) return false; |
|
1190 | + if (count($test) != count($this)) { |
|
1191 | + return false; |
|
1192 | + } |
|
1176 | 1193 | |
1177 | 1194 | // loop through the array of each item's array keys that we just created |
1178 | 1195 | // and compare it to the FIRST item. If any array contains different keys |
@@ -1180,7 +1197,9 @@ discard block |
||
1180 | 1197 | $first = array_shift($test); |
1181 | 1198 | foreach ($test as $key => $keys) { |
1182 | 1199 | $diff = array_diff($first, $keys); |
1183 | - if (!empty($diff)) return false; |
|
1200 | + if (!empty($diff)) { |
|
1201 | + return false; |
|
1202 | + } |
|
1184 | 1203 | } |
1185 | 1204 | return true; |
1186 | 1205 | } |
@@ -91,7 +91,9 @@ |
||
91 | 91 | { |
92 | 92 | $res = (new Resource($uri, $mode)) |
93 | 93 | ->setContextResource($context); |
94 | - if (!$lazy) $res->connect(); |
|
94 | + if (!$lazy) { |
|
95 | + $res->connect(); |
|
96 | + } |
|
95 | 97 | return $res; |
96 | 98 | } |
97 | 99 |
@@ -267,16 +267,16 @@ |
||
267 | 267 | return strlen($data); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Seekability accessor. |
|
272 | - * |
|
273 | - * Despite the fact that any class that implements this interface must also |
|
274 | - * define methods such as seek, that is no guarantee that an |
|
275 | - * object will necessarily be seekable. This method should tell the user |
|
276 | - * whether a stream is, in fact, seekable. |
|
277 | - * |
|
278 | - * @return boolean True if seekable, false otherwise |
|
279 | - */ |
|
270 | + /** |
|
271 | + * Seekability accessor. |
|
272 | + * |
|
273 | + * Despite the fact that any class that implements this interface must also |
|
274 | + * define methods such as seek, that is no guarantee that an |
|
275 | + * object will necessarily be seekable. This method should tell the user |
|
276 | + * whether a stream is, in fact, seekable. |
|
277 | + * |
|
278 | + * @return boolean True if seekable, false otherwise |
|
279 | + */ |
|
280 | 280 | public function isSeekable() |
281 | 281 | { |
282 | 282 | return $this->seekable; |
@@ -267,16 +267,16 @@ |
||
267 | 267 | return strlen($data); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Seekability accessor. |
|
272 | - * |
|
273 | - * Despite the fact that any class that implements this interface must also |
|
274 | - * define methods such as seek, that is no guarantee that an |
|
275 | - * object will necessarily be seekable. This method should tell the user |
|
276 | - * whether a stream is, in fact, seekable. |
|
277 | - * |
|
278 | - * @return boolean True if seekable, false otherwise |
|
279 | - */ |
|
270 | + /** |
|
271 | + * Seekability accessor. |
|
272 | + * |
|
273 | + * Despite the fact that any class that implements this interface must also |
|
274 | + * define methods such as seek, that is no guarantee that an |
|
275 | + * object will necessarily be seekable. This method should tell the user |
|
276 | + * whether a stream is, in fact, seekable. |
|
277 | + * |
|
278 | + * @return boolean True if seekable, false otherwise |
|
279 | + */ |
|
280 | 280 | public function isSeekable() |
281 | 281 | { |
282 | 282 | return $this->seekable; |