Completed
Push — releases/v0.2.1 ( f649db...d87112 )
by Luke
03:42
created
src/CSVelte/Collection.php 1 patch
Doc Comments   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
      *
615 615
      * @param int|mixed The offset to set
616 616
      * @param any The value to set it to
617
-     * @return boolean
617
+     * @return Collection
618 618
      */
619 619
     public function offsetSet($offset, $value)
620 620
     {
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
      * Filter out unwanted items using a callback function.
771 771
      *
772 772
      * @param Callable $callback
773
-     * @return CSVelte\Collection A new collection with filtered items removed
773
+     * @return Collection A new collection with filtered items removed
774 774
      */
775 775
     public function filter(Callable $callback)
776 776
     {
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
      * Returns an array where the key is a value in the collection and the value
823 823
      * is the number of times that value appears in the collection.
824 824
      *
825
-     * @return CSVelte\Collection A collection of value frequencies (see description)
825
+     * @return Collection A collection of value frequencies (see description)
826 826
      */
827 827
     public function frequency()
828 828
     {
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
      * Returns a collection with duplicate values removed. If two-dimensional,
847 847
      * then each array within the collection will have its duplicates removed.
848 848
      *
849
-     * @return CSVelte\Collection A new collection with duplicate values removed.
849
+     * @return Collection A new collection with duplicate values removed.
850 850
      */
851 851
     public function unique()
852 852
     {
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
      * Returns a collection of arrays where the key is the duplicate value
863 863
      * and the value is an array of keys from the original collection.
864 864
      *
865
-     * @return CSVelte\Collection A new collection with duplicate values.
865
+     * @return Collection A new collection with duplicate values.
866 866
      */
867 867
     public function duplicates()
868 868
     {
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
      *
881 881
      * Get a new collection where the keys and values have been swapped.
882 882
      *
883
-     * @return CSVelte\Collection A new collection where keys/values have been swapped
883
+     * @return Collection A new collection where keys/values have been swapped
884 884
      */
885 885
     public function flip()
886 886
     {
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
      * first is the default.
895 895
      *
896 896
      * @param boolean Whether you want pairs in [k => v] rather than [k, v] format
897
-     * @return CSVelte\Collection A collection of key/value pairs
897
+     * @return Collection A collection of key/value pairs
898 898
      */
899 899
     public function pairs($alt = false)
900 900
     {
@@ -1056,9 +1056,8 @@  discard block
 block discarded – undo
1056 1056
      * default it uses a case-insensitive natural order algorithm, but you can
1057 1057
      * pass it any sorting algorithm you like.
1058 1058
      *
1059
-     * @param Callable $sort_func The sorting function you want to use
1060 1059
      * @param boolean $preserve_keys Whether you want to preserve keys
1061
-     * @return CSVelte\Collection A new collection sorted by $callback
1060
+     * @return Collection A new collection sorted by $callback
1062 1061
      */
1063 1062
     public function sort(Callable $callback = null, $preserve_keys = true)
1064 1063
     {
@@ -1088,7 +1087,7 @@  discard block
 block discarded – undo
1088 1087
      * @param string $key The key you want to order by
1089 1088
      * @param Callable $cmp The sorting comparison algorithm to use
1090 1089
      * @param boolean $preserve_keys Whether keys should be preserved
1091
-     * @return CSVelte\Collection A new collection sorted by $cmp and $key
1090
+     * @return Collection A new collection sorted by $cmp and $key
1092 1091
      */
1093 1092
     public function orderBy($key, Callable $cmp = null, $preserve_keys = true)
1094 1093
     {
@@ -1112,13 +1111,16 @@  discard block
 block discarded – undo
1112 1111
      * trying to write a particular sorting algurithm that sorts forwards and back.
1113 1112
      *
1114 1113
      * @param boolean $preserve_keys Whether keys should be preserved
1115
-     * @return CSVelte\Collection A new collection in reverse order
1114
+     * @return Collection A new collection in reverse order
1116 1115
      */
1117 1116
     public function reverse($preserve_keys = true)
1118 1117
     {
1119 1118
         return new self(array_reverse($this->data, $preserve_keys));
1120 1119
     }
1121 1120
 
1121
+    /**
1122
+     * @param string $method
1123
+     */
1122 1124
     protected function if2DMapInternalMethod($method)
1123 1125
     {
1124 1126
         if ($this->is2D()) {
Please login to merge, or discard this patch.
src/CSVelte/IO/BufferStream.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
     /**
169 169
      * Return the current position within the stream/readable
170 170
      *
171
-     * @return int The current position within readable
171
+     * @return boolean The current position within readable
172 172
      */
173 173
     public function tell()
174 174
     {
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -267,16 +267,16 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/CSVelte/IO/IteratorStream.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     /**
177 177
      * Return the current position within the stream/readable
178 178
      *
179
-     * @return int The current position within readable
179
+     * @return boolean The current position within readable
180 180
      */
181 181
     public function tell()
182 182
     {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     /**
229 229
      * Closes the stream and any underlying resources.
230 230
      *
231
-     * @return void
231
+     * @return boolean
232 232
      */
233 233
     public function close()
234 234
     {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      * Write data to the output.
279 279
      *
280 280
      * @param string The data to write
281
-     * @return int The number of bytes written
281
+     * @return boolean The number of bytes written
282 282
      */
283 283
     public function write($data)
284 284
     {
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -285,16 +285,16 @@
 block discarded – undo
285 285
         return $this->writable;
286 286
     }
287 287
 
288
-     /**
289
-      * Seekability accessor.
290
-      *
291
-      * Despite the fact that any class that implements this interface must also
292
-      * define methods such as seek, that is no guarantee that an
293
-      * object will necessarily be seekable. This method should tell the user
294
-      * whether a stream is, in fact, seekable.
295
-      *
296
-      * @return boolean True if seekable, false otherwise
297
-      */
288
+        /**
289
+         * Seekability accessor.
290
+         *
291
+         * Despite the fact that any class that implements this interface must also
292
+         * define methods such as seek, that is no guarantee that an
293
+         * object will necessarily be seekable. This method should tell the user
294
+         * whether a stream is, in fact, seekable.
295
+         *
296
+         * @return boolean True if seekable, false otherwise
297
+         */
298 298
     public function isSeekable()
299 299
     {
300 300
         return $this->seekable;
Please login to merge, or discard this patch.
src/CSVelte/IO/Resource.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
      *
220 220
      * Creates and returns a Stream object for this resource
221 221
      *
222
-     * @return resource The underlying stream resource
222
+     * @return Stream The underlying stream resource
223 223
      */
224 224
     public function __invoke()
225 225
     {
@@ -432,6 +432,7 @@  discard block
 block discarded – undo
432 432
      * until the user specifically requests it.
433 433
      *
434 434
      * @param boolean|null Whether or not to "lazily" open the stream
435
+     * @param boolean|null $lazy
435 436
      * @return $this
436 437
      */
437 438
     protected function setLazy($lazy)
@@ -841,6 +842,7 @@  discard block
 block discarded – undo
841 842
      * only be called on unopened stream resources.
842 843
      *
843 844
      * @param  string The method that is asserting
845
+     * @param string $method
844 846
      * @return void
845 847
      * @throws \CSVelte\Exception\IOException if stream is open
846 848
      */
@@ -857,6 +859,7 @@  discard block
 block discarded – undo
857 859
      * Used internally to ensure that a given stream wrapper is valid and available
858 860
      *
859 861
      * @param  string The name of the stream wrapper
862
+     * @param string $name
860 863
      * @return void
861 864
      * @throws \InvalidArgumentException if wrapper doesn't exist
862 865
      */
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
             // set all this manually
191 191
             $meta = stream_get_meta_data($handle);
192 192
             $this->setUri($meta['uri'])
193
-                 ->setMode($meta['mode']);
193
+                    ->setMode($meta['mode']);
194 194
             $this->conn = $handle;
195 195
             return;
196 196
         }
197 197
 
198 198
         // ok we're opening a new stream resource handle
199 199
         $this->setUri($uri)
200
-             ->setMode($mode)
201
-             ->setLazy($lazy)
202
-             ->setUseIncludePath($use_include_path)
203
-             ->setContext($context_options, $context_params);
200
+                ->setMode($mode)
201
+                ->setLazy($lazy)
202
+                ->setUseIncludePath($use_include_path)
203
+                ->setContext($context_options, $context_params);
204 204
         if (!$this->isLazy()) {
205 205
             $this->connect();
206 206
         }
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 
340 340
         $this->flag = '';
341 341
         $this->setBaseMode($base)
342
-             ->setIsPlus($plus == '+')
343
-             ->setIsText($flag == 't')
344
-             ->setIsBinary($flag == 'b');
342
+                ->setIsPlus($plus == '+')
343
+                ->setIsText($flag == 't')
344
+                ->setIsBinary($flag == 'b');
345 345
 
346 346
         return $this;
347 347
     }
Please login to merge, or discard this patch.
src/CSVelte/IO/Stream.php 1 patch
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -131,6 +131,7 @@  discard block
 block discarded – undo
131 131
      *
132 132
      * @see http://php.net/manual/en/function.fopen.php
133 133
      * @see http://php.net/manual/en/function.stream-context-create.php
134
+     * @param string $mode
134 135
      */
135 136
     public static function open($uri, $mode = null, $context = null, $lazy = false)
136 137
     {
@@ -143,7 +144,7 @@  discard block
 block discarded – undo
143 144
     /**
144 145
      * Close stream resource.
145 146
      *
146
-     * @return boolean True on success or false on failure
147
+     * @return boolean|null True on success or false on failure
147 148
      */
148 149
     public function close()
149 150
     {
@@ -224,7 +225,7 @@  discard block
 block discarded – undo
224 225
      *
225 226
      * Returns the internal stream resource pointer
226 227
      *
227
-     * @return resource The open stream resource pointer
228
+     * @return Resource The open stream resource pointer
228 229
      */
229 230
     public function getResource()
230 231
     {
@@ -262,7 +263,7 @@  discard block
 block discarded – undo
262 263
      *
263 264
      * After the stream has been detached, the stream is in an unusable state.
264 265
      *
265
-     * @return resource|null Underlying PHP stream, if any
266
+     * @return Resource Underlying PHP stream, if any
266 267
      */
267 268
     public function detach()
268 269
     {
Please login to merge, or discard this patch.
src/CSVelte/Table/AbstractRow.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     /**
133 133
      * Get the current key (column number or header, if available)
134 134
      *
135
-     * @return string The "current" key
135
+     * @return integer The "current" key
136 136
      * @access public
137 137
      * @todo Figure out if this can return a CSVelte\Table\HeaderData object so long as it
138 138
      *     has a __toString() method that generated the right key...
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * Advance the internal pointer to the next column's data object
147 147
      * Also returns the next column's data object if there is one
148 148
      *
149
-     * @return CSVelte\Table\Data The "next" column's data
149
+     * @return string|null The "next" column's data
150 150
      * @access public
151 151
      */
152 152
     public function next()
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     /**
159 159
      * Return the internal pointer to the first column and return that object
160 160
      *
161
-     * @return void
161
+     * @return string|null
162 162
      * @access public
163 163
      */
164 164
     public function rewind()
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
     public function __construct($fields)
57 57
     {
58 58
         $this->setFields($fields)
59
-             ->rewind();
59
+                ->rewind();
60 60
     }
61 61
 
62 62
     protected function setFields($fields)
Please login to merge, or discard this patch.
src/CSVelte/Taster.php 2 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -189,6 +189,7 @@  discard block
 block discarded – undo
189 189
      * replaceQuotedSpecialChars method which (at least to me) makes more sense.
190 190
      *
191 191
      * @param string The string to replace quoted strings within
192
+     * @param string $data
192 193
      * @return string The input string with quoted strings removed
193 194
      * @todo Replace code that uses this method with the replaceQuotedSpecialChars
194 195
      *     method instead. I think it's cleaner.
@@ -559,7 +560,7 @@  discard block
 block discarded – undo
559 560
      * Determine whether a particular string of data has quotes around it.
560 561
      *
561 562
      * @param string The data to check
562
-     * @return boolean Whether the data is quoted or not
563
+     * @return integer Whether the data is quoted or not
563 564
      */
564 565
     protected function isQuoted($data)
565 566
     {
@@ -607,6 +608,8 @@  discard block
 block discarded – undo
607 608
      *
608 609
      * @param string The string to do the replacements on
609 610
      * @param string The delimiter character to replace
611
+     * @param string $data
612
+     * @param string $delim
610 613
      * @return string The data with replacements performed
611 614
      * @todo I could probably pass in (maybe optionally) the newline character I
612 615
      *     want to replace as well. I'll do that if I need to.
@@ -632,6 +635,7 @@  discard block
 block discarded – undo
632 635
      * to be practical.
633 636
      *
634 637
      * @param string The string of data to check the type of
638
+     * @param string $data
635 639
      * @return string One of the TYPE_ string constants above
636 640
      */
637 641
     protected function lickType($data)
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -290,20 +290,20 @@  discard block
 block discarded – undo
290 290
         throw new TasterException("quoteChar and delimiter cannot be determined", TasterException::ERR_QUOTE_AND_DELIM);
291 291
     }
292 292
 
293
-     /**
294
-      * Take a list of likely delimiter characters and find the one that occurs
295
-      * the most consistent amount of times within the provided data.
296
-      *
297
-      * @param string The character(s) used for newlines
298
-      * @return string One of four Flavor::QUOTING_* constants
299
-      * @see \CSVelte\Flavor for possible quote style constants
300
-      * @todo Refactor this method--It needs more thorough testing against a wider
301
-      *     variety of CSV data to be sure it works reliably. And I'm sure there
302
-      *     are many performance and logic improvements that could be made. This
303
-      *     is essentially a first draft.
304
-      * @todo Can't use replaceQuotedSpecialChars rather than removeQuotedStrings
305
-      *     because the former requires u to know the delimiter
306
-      */
293
+        /**
294
+         * Take a list of likely delimiter characters and find the one that occurs
295
+         * the most consistent amount of times within the provided data.
296
+         *
297
+         * @param string The character(s) used for newlines
298
+         * @return string One of four Flavor::QUOTING_* constants
299
+         * @see \CSVelte\Flavor for possible quote style constants
300
+         * @todo Refactor this method--It needs more thorough testing against a wider
301
+         *     variety of CSV data to be sure it works reliably. And I'm sure there
302
+         *     are many performance and logic improvements that could be made. This
303
+         *     is essentially a first draft.
304
+         * @todo Can't use replaceQuotedSpecialChars rather than removeQuotedStrings
305
+         *     because the former requires u to know the delimiter
306
+         */
307 307
     protected function lickDelimiter($eol = "\n")
308 308
     {
309 309
         $frequencies = [];
@@ -381,16 +381,16 @@  discard block
 block discarded – undo
381 381
              *     which one has the best distribution, return that one.
382 382
              */
383 383
 
384
-             $decision = $dups->get($max);
385
-             try {
386
-                 $delim = $this->guessDelimByDistribution($decision, $eol);
387
-             } catch (TasterException $e) {
388
-                 // if somehow we STILL can't come to a consensus, then fall back to a
389
-                 // "preferred delimiters" list...
390
-                 foreach ($this->delims as $key => $val) {
384
+                $decision = $dups->get($max);
385
+                try {
386
+                    $delim = $this->guessDelimByDistribution($decision, $eol);
387
+                } catch (TasterException $e) {
388
+                    // if somehow we STILL can't come to a consensus, then fall back to a
389
+                    // "preferred delimiters" list...
390
+                    foreach ($this->delims as $key => $val) {
391 391
                     if ($delim = array_search($val, $decision)) return $delim;
392
-                 }
393
-             }
392
+                    }
393
+                }
394 394
         }
395 395
         return $delims
396 396
             ->sort()
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
             })->map(function($dists) {
448 448
                 return $dists->average();
449 449
             })->sort()
450
-              ->reverse()
451
-              ->getKeyAtPosition(0)];
450
+                ->reverse()
451
+                ->getKeyAtPosition(0)];
452 452
         } catch (Exception $e) {
453 453
             throw new TasterException("delimiter cannot be determined by distribution", TasterException::ERR_DELIMITER);
454 454
         }
Please login to merge, or discard this patch.
src/CSVelte/Writer.php 1 patch
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     /**
61 61
      * Class Constructor
62 62
      *
63
-     * @param \CSVelte\Contract\Writable $output An output source to write to
63
+     * @param Streamable $output An output source to write to
64 64
      * @param \CSVelte\Flavor|array $flavor A flavor or set of formatting params
65 65
      */
66 66
     public function __construct(Streamable $output, $flavor = null)
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * likely buffer the output so that this may be called after writeRows()
90 90
      *
91 91
      * @param \Iterator|array A list of header values
92
-     * @return boolean
92
+     * @return boolean|null
93 93
      * @throws \CSVelte\Exception\WriterException
94 94
      */
95 95
     public function setHeaderRow($headers)
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * This means taking an array of data, and converting it to a Row object
160 160
      *
161 161
      * @param \Iterator|array of data items
162
-     * @return CSVelte\Table\AbstractRow
162
+     * @return Row
163 163
      * @access protected
164 164
      */
165 165
     protected function prepareRow(Iterator $row)
@@ -187,6 +187,9 @@  discard block
 block discarded – undo
187 187
         return $this->quoteString($data);
188 188
     }
189 189
 
190
+    /**
191
+     * @param string $str
192
+     */
190 193
     protected function quoteString($str)
191 194
     {
192 195
         $flvr = $this->getFlavor();
Please login to merge, or discard this patch.
src/CSVelte/Reader.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,8 +91,8 @@
 block discarded – undo
91 91
     public function __construct($input, $flavor = null)
92 92
     {
93 93
         $this->setSource($input)
94
-             ->setFlavor($flavor)
95
-             ->rewind();
94
+                ->setFlavor($flavor)
95
+                ->rewind();
96 96
     }
97 97
 
98 98
     /**
Please login to merge, or discard this patch.