Complex classes like AbstractCollection often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractCollection, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 43 | abstract class AbstractCollection implements |
||
| 44 | CollectionInterface, |
||
| 45 | ArrayableInterface, |
||
| 46 | ArrayAccess, |
||
| 47 | Countable, |
||
| 48 | Iterator |
||
| 49 | { |
||
| 50 | use IsArrayable; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var array The collection of data this object represents |
||
| 54 | */ |
||
| 55 | protected $data = []; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var bool True unless we have advanced past the end of the data array |
||
| 59 | */ |
||
| 60 | protected $isValid = true; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * AbstractCollection constructor. |
||
| 64 | * |
||
| 65 | * @param mixed $data The data to wrap |
||
| 66 | */ |
||
| 67 | public function __construct($data = []) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Set collection data. |
||
| 74 | * |
||
| 75 | * Sets the collection data. |
||
| 76 | * |
||
| 77 | * @param array $data The data to wrap |
||
| 78 | * |
||
| 79 | * @return $this |
||
| 80 | */ |
||
| 81 | protected function setData($data) |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Assert input data is of the correct structure. |
||
| 98 | * |
||
| 99 | * @param mixed $data Data to check |
||
| 100 | * |
||
| 101 | * @throws InvalidArgumentException If invalid data structure |
||
| 102 | */ |
||
| 103 | protected function assertCorrectInputDataType($data) |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Determine whether data is consistent with a given collection type. |
||
| 114 | * |
||
| 115 | * This method is used to determine whether input data is consistent with a |
||
| 116 | * given collection type. For instance, |
||
| 117 | * NumericCollection requires an array or traversable set of numeric data. |
||
| 118 | * TabularCollection requires a two-dimensional data structure where all the |
||
| 119 | * keys are the same in every row. |
||
| 120 | * |
||
| 121 | * @param mixed $data Data structure to check for consistency |
||
| 122 | * |
||
| 123 | * @return bool |
||
| 124 | */ |
||
| 125 | abstract protected function isConsistentDataStructure($data); |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Convert input data to an array. |
||
| 129 | * |
||
| 130 | * Convert the input data to an array that can be worked with by a collection. |
||
| 131 | * |
||
| 132 | * @param mixed $data The input data |
||
| 133 | * |
||
| 134 | * @return array |
||
| 135 | */ |
||
| 136 | abstract protected function prepareData($data); |
||
| 137 | |||
| 138 | /** |
||
| 139 | * Invoke object. |
||
| 140 | * |
||
| 141 | * Magic "invoke" method. Called when object is invoked as if it were a function. |
||
| 142 | * |
||
| 143 | * @param mixed $val The value (depends on other param value) |
||
| 144 | * @param mixed $index The index (depends on other param value) |
||
| 145 | * |
||
| 146 | * @return array|CollectionInterface (Depends on parameter values) |
||
| 147 | */ |
||
| 148 | public function __invoke($val = null, $index = null) |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Whether a offset exists. |
||
| 167 | * |
||
| 168 | * @param mixed $offset An offset to check for. |
||
| 169 | * |
||
| 170 | * @return bool true on success or false on failure. |
||
| 171 | * |
||
| 172 | * @see http://php.net/manual/en/arrayaccess.offsetexists.php |
||
| 173 | */ |
||
| 174 | public function offsetExists($offset) |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Offset to retrieve. |
||
| 181 | * |
||
| 182 | * @param mixed $offset The offset to retrieve. |
||
| 183 | * |
||
| 184 | * @return mixed Can return all value types. |
||
| 185 | * |
||
| 186 | * @see http://php.net/manual/en/arrayaccess.offsetget.php |
||
| 187 | */ |
||
| 188 | public function offsetGet($offset) |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Offset to set. |
||
| 195 | * |
||
| 196 | * @param mixed $offset The offset to assign the value to. |
||
| 197 | * @param mixed $value The value to set. |
||
| 198 | * |
||
| 199 | * @see http://php.net/manual/en/arrayaccess.offsetset.php |
||
| 200 | */ |
||
| 201 | public function offsetSet($offset, $value) |
||
| 205 | |||
| 206 | /** |
||
| 207 | * Offset to unset. |
||
| 208 | * |
||
| 209 | * @param mixed $offset The offset to unset. |
||
| 210 | * |
||
| 211 | * @see http://php.net/manual/en/arrayaccess.offsetunset.php |
||
| 212 | */ |
||
| 213 | public function offsetUnset($offset) |
||
| 217 | |||
| 218 | /** |
||
| 219 | * Get count. |
||
| 220 | * If a callback is supplied, this method will return the number of items that cause the callback to return true. |
||
| 221 | * Otherwise, all items in the collection will be counted. |
||
| 222 | * |
||
| 223 | * @param callable $callback The (optional) callback function |
||
|
|
|||
| 224 | * |
||
| 225 | * @return int |
||
| 226 | */ |
||
| 227 | public function count(callable $callback = null) |
||
| 234 | |||
| 235 | /** |
||
| 236 | * Return the current element. |
||
| 237 | * |
||
| 238 | * Returns the current element in the collection. The internal array pointer |
||
| 239 | * of the data array wrapped by the collection should not be advanced by this |
||
| 240 | * method. No side effects. Return current element only. |
||
| 241 | * |
||
| 242 | * @return mixed |
||
| 243 | */ |
||
| 244 | public function current() |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Return the current key. |
||
| 251 | * |
||
| 252 | * Returns the current key in the collection. No side effects. |
||
| 253 | * |
||
| 254 | * @return mixed |
||
| 255 | */ |
||
| 256 | public function key() |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Advance the internal pointer forward. |
||
| 263 | * |
||
| 264 | * Although this method will return the current value after advancing the |
||
| 265 | * pointer, you should not expect it to. The interface does not require it |
||
| 266 | * to return any value at all. |
||
| 267 | * |
||
| 268 | * @return mixed |
||
| 269 | */ |
||
| 270 | public function next() |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Rewind the internal pointer. |
||
| 282 | * |
||
| 283 | * Return the internal pointer to the first element in the collection. Again, |
||
| 284 | * this method is not required to return anything by its interface, so you |
||
| 285 | * should not count on a return value. |
||
| 286 | * |
||
| 287 | * @return mixed |
||
| 288 | */ |
||
| 289 | public function rewind() |
||
| 295 | |||
| 296 | /** |
||
| 297 | * Is internal pointer in a valid position? |
||
| 298 | * |
||
| 299 | * If the internal pointer is advanced beyond the end of the collection, this method will return false. |
||
| 300 | * |
||
| 301 | * @return bool True if internal pointer isn't past the end |
||
| 302 | */ |
||
| 303 | public function valid() |
||
| 307 | |||
| 308 | public function sort($alg = null) |
||
| 317 | |||
| 318 | /** |
||
| 319 | * Does this collection have a value at given index? |
||
| 320 | * |
||
| 321 | * @param mixed $index The index to check |
||
| 322 | * |
||
| 323 | * @return bool |
||
| 324 | */ |
||
| 325 | public function has($index) |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Set a value at a given index. |
||
| 332 | * |
||
| 333 | * Setter for this collection. Allows setting a value at a given index. |
||
| 334 | * |
||
| 335 | * @param mixed $index The index to set a value at |
||
| 336 | * @param mixed $val The value to set $index to |
||
| 337 | * |
||
| 338 | * @return $this |
||
| 339 | */ |
||
| 340 | public function set($index, $val) |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Unset a value at a given index. |
||
| 349 | * |
||
| 350 | * Unset (delete) value at the given index. |
||
| 351 | * |
||
| 352 | * @param mixed $index The index to unset |
||
| 353 | * @param bool $throw True if you want an exception to be thrown if no data found at $index |
||
| 354 | * |
||
| 355 | * @throws OutOfBoundsException If $throw is true and $index isn't found |
||
| 356 | * |
||
| 357 | * @return $this |
||
| 358 | */ |
||
| 359 | public function delete($index, $throw = false) |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Get index of a value. |
||
| 374 | * |
||
| 375 | * Given a value, this method will return the index of the first occurrence of that value. |
||
| 376 | * |
||
| 377 | * @param mixed $value Value to get the index of |
||
| 378 | * @param bool $throw Whether to throw an exception if value isn't found |
||
| 379 | * |
||
| 380 | * @return int|null|string |
||
| 381 | */ |
||
| 382 | public function indexOf($value, $throw = true) |
||
| 399 | |||
| 400 | /** |
||
| 401 | * Get this collection's keys as a collection. |
||
| 402 | * |
||
| 403 | * @return CollectionInterface Containing this collection's keys |
||
| 404 | */ |
||
| 405 | public function keys() |
||
| 409 | |||
| 410 | /** |
||
| 411 | * Get this collection's values as a collection. |
||
| 412 | * |
||
| 413 | * This method returns this collection's values but completely re-indexed (numerically). |
||
| 414 | * |
||
| 415 | * @return CollectionInterface Containing this collection's values |
||
| 416 | */ |
||
| 417 | public function values() |
||
| 421 | |||
| 422 | /** |
||
| 423 | * Merge data into collection. |
||
| 424 | * |
||
| 425 | * Merges input data into this collection. Input can be an array or another collection. |
||
| 426 | * Returns a NEW collection object. |
||
| 427 | * |
||
| 428 | * @param Traversable|array $data The data to merge with this collection |
||
| 429 | * |
||
| 430 | * @return CollectionInterface A new collection with $data merged in |
||
| 431 | */ |
||
| 432 | public function merge($data) |
||
| 442 | |||
| 443 | /** |
||
| 444 | * Determine if this collection contains a value. |
||
| 445 | * |
||
| 446 | * Allows you to pass in a value or a callback function and optionally an index, |
||
| 447 | * and tells you whether or not this collection contains that value. |
||
| 448 | * If the $index param is specified, only that index will be looked under. |
||
| 449 | * |
||
| 450 | * @param mixed|callable $value The value to check for |
||
| 451 | * @param mixed $index The (optional) index to look under |
||
| 452 | * |
||
| 453 | * @return bool True if this collection contains $value |
||
| 454 | * |
||
| 455 | * @todo Maybe add $identical param for identical comparison (===) |
||
| 456 | * @todo Allow negative offset for second param |
||
| 457 | */ |
||
| 458 | public function contains($value, $index = null) |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Pop an element off the end of this collection. |
||
| 483 | * |
||
| 484 | * @return mixed The last item in this collectio n |
||
| 485 | */ |
||
| 486 | public function pop() |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Shift an element off the beginning of this collection. |
||
| 493 | * |
||
| 494 | * @return mixed The first item in this collection |
||
| 495 | */ |
||
| 496 | public function shift() |
||
| 500 | |||
| 501 | /** |
||
| 502 | * Pad this collection to a certain size. |
||
| 503 | * |
||
| 504 | * Returns a new collection, padded to the given size, with the given value. |
||
| 505 | * |
||
| 506 | * @param int $size The number of items that should be in the collection |
||
| 507 | * @param mixed $with The value to pad the collection with |
||
| 508 | * |
||
| 509 | * @return CollectionInterface A new collection padded to specified length |
||
| 510 | */ |
||
| 511 | public function pad($size, $with = null) |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Apply a callback to each item in collection. |
||
| 518 | * |
||
| 519 | * Applies a callback to each item in collection and returns a new collection |
||
| 520 | * containing each iteration's return value. |
||
| 521 | * |
||
| 522 | * @param callable $callback The callback to apply |
||
| 523 | * |
||
| 524 | * @return CollectionInterface A new collection with callback return values |
||
| 525 | */ |
||
| 526 | public function map(callable $callback) |
||
| 535 | |||
| 536 | /** |
||
| 537 | * Apply a callback to each item in collection. |
||
| 538 | * |
||
| 539 | * Applies a callback to each item in collection. The callback should return |
||
| 540 | * false to filter any item from the collection. |
||
| 541 | * |
||
| 542 | * @param callable $callback The callback function |
||
| 543 | * @param null $extraContext Extra context to pass as third param in callback |
||
| 544 | * |
||
| 545 | * @return $this |
||
| 546 | * |
||
| 547 | * @see php.net array_walk |
||
| 548 | */ |
||
| 549 | public function walk(callable $callback, $extraContext = null) |
||
| 555 | |||
| 556 | /** |
||
| 557 | * Iterate over each item in the collection, calling $callback on it. Return false to stop iterating. |
||
| 558 | * |
||
| 559 | * @param callable $callback A callback to use |
||
| 560 | * |
||
| 561 | * @return $this |
||
| 562 | */ |
||
| 563 | public function each(callable $callback) |
||
| 573 | |||
| 574 | /** |
||
| 575 | * Filter the collection. |
||
| 576 | * |
||
| 577 | * Using a callback function, this method will filter out unwanted values, returning |
||
| 578 | * a new collection containing only the values that weren't filtered. |
||
| 579 | * |
||
| 580 | * @param callable $callback The callback function used to filter |
||
| 581 | * |
||
| 582 | * @return CollectionInterface A new collection with only values that weren't filtered |
||
| 583 | */ |
||
| 584 | public function filter(callable $callback) |
||
| 595 | |||
| 596 | /** |
||
| 597 | * Filter the collection. |
||
| 598 | * |
||
| 599 | * Using a callback function, this method will filter out unwanted values, returning |
||
| 600 | * a new collection containing only the values that weren't filtered. |
||
| 601 | * |
||
| 602 | * @param callable $callback The callback function used to filter |
||
| 603 | * |
||
| 604 | * @return CollectionInterface A new collection with only values that weren't filtered |
||
| 605 | */ |
||
| 606 | public function exclude(callable $callback) |
||
| 617 | |||
| 618 | /** |
||
| 619 | * Return the first item that meets given criteria. |
||
| 620 | * |
||
| 621 | * Using a callback function, this method will return the first item in the collection |
||
| 622 | * that causes the callback function to return true. |
||
| 623 | * |
||
| 624 | * @param callable|null $callback The callback function |
||
| 625 | * @param mixed|null $default The default return value |
||
| 626 | * |
||
| 627 | * @return mixed |
||
| 628 | */ |
||
| 629 | public function first(callable $callback = null, $default = null) |
||
| 643 | |||
| 644 | /** |
||
| 645 | * Return the last item that meets given criteria. |
||
| 646 | * |
||
| 647 | * Using a callback function, this method will return the last item in the collection |
||
| 648 | * that causes the callback function to return true. |
||
| 649 | * |
||
| 650 | * @param callable|null $callback The callback function |
||
| 651 | * @param mixed|null $default The default return value |
||
| 652 | * |
||
| 653 | * @return mixed |
||
| 654 | */ |
||
| 655 | public function last(callable $callback = null, $default = null) |
||
| 663 | |||
| 664 | /** |
||
| 665 | * Returns collection in reverse order. |
||
| 666 | * |
||
| 667 | * @return CollectionInterface This collection in reverse order. |
||
| 668 | */ |
||
| 669 | public function reverse() |
||
| 673 | |||
| 674 | /** |
||
| 675 | * Get unique items. |
||
| 676 | * |
||
| 677 | * Returns a collection of all the unique items in this collection. |
||
| 678 | * |
||
| 679 | * @return CollectionInterface This collection with duplicate items removed |
||
| 680 | */ |
||
| 681 | public function unique() |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Collection factory method. |
||
| 688 | * |
||
| 689 | * This method will analyze input data and determine the most appropriate Collection |
||
| 690 | * class to use. It will then instantiate said Collection class with the given |
||
| 691 | * data and return it. |
||
| 692 | * |
||
| 693 | * @param mixed $data The data to wrap |
||
| 694 | * |
||
| 695 | * @return CollectionInterface A collection containing $data |
||
| 696 | */ |
||
| 697 | public static function factory($data = null) |
||
| 713 | |||
| 714 | /** |
||
| 715 | * Is data structure all objects? |
||
| 716 | * |
||
| 717 | * Does the data structure passed in contain only objects? |
||
| 718 | * |
||
| 719 | * @param mixed $data The data structure to check |
||
| 720 | * |
||
| 721 | * @return bool |
||
| 722 | */ |
||
| 723 | public static function isAllObjects($data) |
||
| 736 | |||
| 737 | /** |
||
| 738 | * Is input data tabular? |
||
| 739 | * |
||
| 740 | * Returns true if input data is tabular in nature. This means that it is a |
||
| 741 | * two-dimensional array with the same keys (columns) for each element (row). |
||
| 742 | * |
||
| 743 | * @param mixed $data The data structure to check |
||
| 744 | * |
||
| 745 | * @return bool True if data structure is tabular |
||
| 746 | */ |
||
| 747 | public static function isTabular($data) |
||
| 774 | |||
| 775 | /** |
||
| 776 | * Check data for multiple dimensions. |
||
| 777 | * |
||
| 778 | * This method is to determine whether a data structure is multi-dimensional. |
||
| 779 | * That is to say, it is a traversable structure that contains at least one |
||
| 780 | * traversable structure. |
||
| 781 | * |
||
| 782 | * @param mixed $data The input data |
||
| 783 | * |
||
| 784 | * @return bool |
||
| 785 | */ |
||
| 786 | public static function isMultiDimensional($data) |
||
| 799 | |||
| 800 | /** |
||
| 801 | * Determine if structure contains all numeric values. |
||
| 802 | * |
||
| 803 | * @param mixed $data The input data |
||
| 804 | * |
||
| 805 | * @return bool |
||
| 806 | */ |
||
| 807 | public static function isAllNumeric($data) |
||
| 820 | |||
| 821 | /** |
||
| 822 | * Is data a string of characters? |
||
| 823 | * |
||
| 824 | * Just checks to see if input is a string of characters or a string |
||
| 825 | * of digits. |
||
| 826 | * |
||
| 827 | * @param mixed $data Data to check |
||
| 828 | * |
||
| 829 | * @return bool |
||
| 830 | */ |
||
| 831 | public static function isCharacterSet($data) |
||
| 837 | |||
| 838 | /** |
||
| 839 | * @inheritdoc |
||
| 840 | */ |
||
| 841 | public function hasOffset($offset) |
||
| 850 | |||
| 851 | /** |
||
| 852 | * @inheritdoc |
||
| 853 | */ |
||
| 854 | public function getOffsetKey($offset) |
||
| 863 | |||
| 864 | /** |
||
| 865 | * @inheritdoc |
||
| 866 | */ |
||
| 867 | public function getOffset($offset) |
||
| 871 | |||
| 872 | /** |
||
| 873 | * @param int $pos The numerical position |
||
| 874 | * |
||
| 875 | * @throws OutOfBoundsException if no pair at position |
||
| 876 | * |
||
| 877 | * @return array |
||
| 878 | */ |
||
| 879 | public function getPairAtPosition($pos) |
||
| 885 | |||
| 886 | /** |
||
| 887 | * Get each key/value as an array pair. |
||
| 888 | * |
||
| 889 | * Returns a collection of arrays where each item in the collection is [key,value] |
||
| 890 | * |
||
| 891 | * @return CollectionInterface |
||
| 892 | */ |
||
| 893 | public function pairs() |
||
| 903 | |||
| 904 | /** |
||
| 905 | * Get duplicate values. |
||
| 906 | * |
||
| 907 | * Returns a collection of arrays where the key is the duplicate value |
||
| 908 | * and the value is an array of keys from the original collection. |
||
| 909 | * |
||
| 910 | * @return CollectionInterface A new collection with duplicate values. |
||
| 911 | */ |
||
| 912 | public function duplicates() |
||
| 923 | |||
| 924 | // END Iterator methods |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Counts how many times each value occurs in a collection. |
||
| 928 | * |
||
| 929 | * Returns a new collection with values as keys and how many times that |
||
| 930 | * value appears in the collection. Works best with scalar values but will |
||
| 931 | * attempt to work on collections of objects as well. |
||
| 932 | * |
||
| 933 | * @return CollectionInterface |
||
| 934 | * |
||
| 935 | * @todo Right now, collections of arrays or objects are supported via the |
||
| 936 | * __toString() or spl_object_hash() |
||
| 937 | * @todo NumericCollection::counts() does the same thing... |
||
| 938 | */ |
||
| 939 | public function frequency() |
||
| 962 | |||
| 963 | /** |
||
| 964 | * @inheritDoc |
||
| 965 | */ |
||
| 966 | public function add($index, $value) |
||
| 973 | |||
| 974 | /** |
||
| 975 | * @inheritdoc |
||
| 976 | */ |
||
| 977 | public function get($index, $default = null) |
||
| 985 | |||
| 986 | /** |
||
| 987 | * @inheritdoc |
||
| 988 | */ |
||
| 989 | public function retrieve($index) |
||
| 996 | |||
| 997 | /** |
||
| 998 | * @inheritDoc |
||
| 999 | */ |
||
| 1000 | public function take($index) |
||
| 1011 | |||
| 1012 | /** |
||
| 1013 | * @inheritDoc |
||
| 1014 | */ |
||
| 1015 | public function prepend($item) |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | * @inheritDoc |
||
| 1024 | */ |
||
| 1025 | public function append($item) |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * @inheritDoc |
||
| 1034 | */ |
||
| 1035 | public function chunk($size) |
||
| 1048 | |||
| 1049 | /** |
||
| 1050 | * @inheritDoc |
||
| 1051 | */ |
||
| 1052 | public function combine($values) |
||
| 1068 | |||
| 1069 | /** |
||
| 1070 | * @inheritDoc |
||
| 1071 | */ |
||
| 1072 | public function diff($data) |
||
| 1081 | |||
| 1082 | /** |
||
| 1083 | * @inheritDoc |
||
| 1084 | */ |
||
| 1085 | public function diffKeys($data) |
||
| 1094 | |||
| 1095 | /** |
||
| 1096 | * @inheritDoc |
||
| 1097 | */ |
||
| 1098 | public function every($nth, $offset = null) |
||
| 1104 | |||
| 1105 | /** |
||
| 1106 | * @inheritDoc |
||
| 1107 | */ |
||
| 1108 | public function except($indexes) |
||
| 1112 | |||
| 1113 | /** |
||
| 1114 | * @inheritDoc |
||
| 1115 | */ |
||
| 1116 | public function flip() |
||
| 1120 | |||
| 1121 | /** |
||
| 1122 | * @inheritDoc |
||
| 1123 | */ |
||
| 1124 | public function intersect($data) |
||
| 1133 | |||
| 1134 | /** |
||
| 1135 | * @inheritDoc |
||
| 1136 | */ |
||
| 1137 | public function intersectKeys($data) |
||
| 1146 | |||
| 1147 | /** |
||
| 1148 | * @inheritDoc |
||
| 1149 | */ |
||
| 1150 | public function isEmpty(callable $callback = null) |
||
| 1157 | |||
| 1158 | /** |
||
| 1159 | * @inheritDoc |
||
| 1160 | */ |
||
| 1161 | public function only($indices) |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * @inheritDoc |
||
| 1168 | */ |
||
| 1169 | public function pipe(callable $callback) |
||
| 1173 | |||
| 1174 | /** |
||
| 1175 | * @inheritDoc |
||
| 1176 | */ |
||
| 1177 | public function random($num) |
||
| 1181 | |||
| 1182 | /** |
||
| 1183 | * @inheritDoc |
||
| 1184 | */ |
||
| 1185 | public function indicesOf($value) |
||
| 1193 | |||
| 1194 | /** |
||
| 1195 | * @inheritDoc |
||
| 1196 | */ |
||
| 1197 | public function shuffle() |
||
| 1201 | |||
| 1202 | /** |
||
| 1203 | * @inheritDoc |
||
| 1204 | */ |
||
| 1205 | public function slice($offset, $length = null) |
||
| 1209 | |||
| 1210 | /** |
||
| 1211 | * @inheritDoc |
||
| 1212 | */ |
||
| 1213 | public function splice($offset, $length = null) |
||
| 1217 | |||
| 1218 | /** |
||
| 1219 | * @inheritDoc |
||
| 1220 | */ |
||
| 1221 | public function split($num) |
||
| 1235 | |||
| 1236 | /** |
||
| 1237 | * @inheritDoc |
||
| 1238 | */ |
||
| 1239 | public function transform(callable $callback) |
||
| 1244 | |||
| 1245 | /** |
||
| 1246 | * @inheritDoc |
||
| 1247 | */ |
||
| 1248 | public function union($data) |
||
| 1258 | |||
| 1259 | /** |
||
| 1260 | * @inheritDoc |
||
| 1261 | */ |
||
| 1262 | public function zip(...$data) |
||
| 1271 | |||
| 1272 | /** |
||
| 1273 | * @inheritDoc |
||
| 1274 | */ |
||
| 1275 | public function foldRight(callable $callback, $initial = null) |
||
| 1284 | |||
| 1285 | /** |
||
| 1286 | * @inheritDoc |
||
| 1287 | */ |
||
| 1288 | public function foldLeft(callable $callback, $initial = null) |
||
| 1292 | |||
| 1293 | /** |
||
| 1294 | * @inheritDoc |
||
| 1295 | */ |
||
| 1296 | public function all(callable $callback = null) |
||
| 1305 | |||
| 1306 | /** |
||
| 1307 | * @inheritDoc |
||
| 1308 | */ |
||
| 1309 | public function none(callable $callback = null) |
||
| 1318 | |||
| 1319 | } |
||
| 1320 |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
arrayand suggests a stricter type likearray<String>.Most often this is a case of a parameter that can be null in addition to its declared types.