1 | <?php |
||
26 | class ObjectCollection extends AbstractCollection |
||
27 | { |
||
28 | /** |
||
29 | * The required object type. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $type; |
||
34 | |||
35 | /** |
||
36 | * ObjectCollection constructor. |
||
37 | * |
||
38 | * @param array<object>|SplObjectStorage|null $data An array of objects or SplObjectStorage object |
||
39 | * @param string $type A class that all objects should be an instance of |
||
|
|||
40 | */ |
||
41 | public function __construct($data = null, $type = null) |
||
49 | |||
50 | /** |
||
51 | * Set the required object type. |
||
52 | * |
||
53 | * If a required type is set, all objects added to this collection must be of this type. |
||
54 | * |
||
55 | * @param string|null $type The required object type |
||
56 | * |
||
57 | * @return $this |
||
58 | */ |
||
59 | public function setRequiredType($type) |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function join($delimiter = '') |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function set($index, $val) |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function push(...$items) |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function unshift(...$items) |
||
113 | |||
114 | /** |
||
115 | * Pad this collection to a certain size. |
||
116 | * |
||
117 | * Returns a new collection, padded to the given size, with clones of the given object. |
||
118 | * |
||
119 | * @param int $size The number of items that should be in the collection |
||
120 | * @param object|null $with The value to pad the collection with |
||
121 | * |
||
122 | * @return ObjectCollection |
||
123 | */ |
||
124 | public function pad($size, $with = null) |
||
137 | |||
138 | /** |
||
139 | * {@inheritdoc} |
||
140 | */ |
||
141 | protected function prepareData($data) |
||
155 | |||
156 | /** |
||
157 | * Is correct input data type? |
||
158 | * |
||
159 | * @param mixed $data The data to assert correct type of |
||
160 | * |
||
161 | * @return bool |
||
162 | */ |
||
163 | protected function isConsistentDataStructure($data) |
||
179 | |||
180 | /** |
||
181 | * Assert a value is of valid type. |
||
182 | * |
||
183 | * @param mixed $value The value to check type of |
||
184 | * |
||
185 | * @throws InvalidArgumentException |
||
186 | */ |
||
187 | protected function assertValidType($value) |
||
204 | } |
||
205 |
This check looks for
@param
annotations 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.
Most often this is a case of a parameter that can be null in addition to its declared types.