| Total Complexity | 103 |
| Total Lines | 513 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Complex classes like TPriorityList 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.
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 TPriorityList, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 52 | class TPriorityList extends TList |
||
| 53 | { |
||
| 54 | use TPriorityCollectionTrait; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Constructor. |
||
| 58 | * Initializes the list with an array or an iterable object. |
||
| 59 | * @param null|array|\Iterator $data the initial data. Default is null, meaning no initial data. |
||
| 60 | * @param bool $readOnly whether the list is read-only |
||
| 61 | * @param numeric $defaultPriority the default priority of items without specified priorities. |
||
|
|
|||
| 62 | * @param int $precision the precision of the numeric priorities |
||
| 63 | * @throws TInvalidDataTypeException If data is not null and is neither an array nor an iterator. |
||
| 64 | */ |
||
| 65 | public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8) |
||
| 66 | { |
||
| 67 | $this->setPrecision($precision); |
||
| 68 | $this->setDefaultPriority($defaultPriority); |
||
| 69 | parent::__construct($data, $readOnly); |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Returns the item at the index of a flattened priority list. |
||
| 74 | * {@link offsetGet} calls this method. |
||
| 75 | * @param int $index the index of the item to get |
||
| 76 | * @throws TInvalidDataValueException Issued when the index is invalid |
||
| 77 | * @return mixed the element at the offset |
||
| 78 | */ |
||
| 79 | public function itemAt($index) |
||
| 80 | { |
||
| 81 | if ($index >= 0 && $index < $this->getCount()) { |
||
| 82 | $this->flattenPriorities(); |
||
| 83 | return $this->_fd[$index]; |
||
| 84 | } else { |
||
| 85 | throw new TInvalidDataValueException('list_index_invalid', $index); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Returns the item at an index within a priority |
||
| 91 | * @param int $index the index into the list of items at priority |
||
| 92 | * @param null|numeric $priority the priority which to index. no parameter or null |
||
| 93 | * will result in the default priority |
||
| 94 | * @throws TInvalidDataValueException if the index is out of the range at the |
||
| 95 | * priority or no items at the priority. |
||
| 96 | * @return mixed the element at the offset, false if no element is found at the offset |
||
| 97 | */ |
||
| 98 | public function itemAtIndexInPriority($index, $priority = null) |
||
| 99 | { |
||
| 100 | $priority = $this->ensurePriority($priority); |
||
| 101 | if (isset($this->_d[$priority]) && 0 <= $index && $index < count($this->_d[$priority])) { |
||
| 102 | return $this->_d[$priority][$index]; |
||
| 103 | } else { |
||
| 104 | throw new TInvalidDataValueException('prioritylist_index_invalid', $index, count($this->_d[$priority] ?? []), $priority); |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Appends an item into the list at the end of the specified priority. The position of the added item may |
||
| 110 | * not be at the end of the list. |
||
| 111 | * @param mixed $item item to add into the list at priority |
||
| 112 | * @param null|numeric $priority priority blank or null for the default priority |
||
| 113 | * @throws TInvalidOperationException if the map is read-only |
||
| 114 | * @return int the index within the flattened array |
||
| 115 | */ |
||
| 116 | public function add($item, $priority = null) |
||
| 117 | { |
||
| 118 | if ($this->getReadOnly()) { |
||
| 119 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 120 | } |
||
| 121 | |||
| 122 | return $this->insertAtIndexInPriority($item, false, $priority, true); |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Inserts an item at an index. It reads the priority of the item at index within the flattened list |
||
| 127 | * and then inserts the item at that priority-index. |
||
| 128 | * @param int $index the specified position in the flattened list. |
||
| 129 | * @param mixed $item new item to add |
||
| 130 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
||
| 131 | * @throws TInvalidOperationException if the list is read-only |
||
| 132 | */ |
||
| 133 | public function insertAt($index, $item) |
||
| 134 | { |
||
| 135 | if ($this->getReadOnly()) { |
||
| 136 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 137 | } |
||
| 138 | |||
| 139 | if (($priority = $this->priorityAt($index, true)) !== false) { |
||
| 140 | $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
||
| 141 | } else { |
||
| 142 | throw new TInvalidDataValueException('list_index_invalid', $index); |
||
| 143 | } |
||
| 144 | } |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Inserts an item at the specified index within a priority. Override and call this method to |
||
| 148 | * insert your own functionality. |
||
| 149 | * @param mixed $item item to add within the list. |
||
| 150 | * @param false|int $index index within the priority to add the item, defaults to false which appends the item at the priority |
||
| 151 | * @param null|numeric $priority priority of the item. defaults to null, which sets it to the default priority |
||
| 152 | * @param bool $preserveCache preserveCache specifies if this is a special quick function or not. This defaults to false. |
||
| 153 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
||
| 154 | * @throws TInvalidOperationException if the list is read-only |
||
| 155 | */ |
||
| 156 | public function insertAtIndexInPriority($item, $index = false, $priority = null, $preserveCache = false) |
||
| 157 | { |
||
| 158 | if ($this->getReadOnly()) { |
||
| 159 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 160 | } |
||
| 161 | |||
| 162 | $itemPriority = null; |
||
| 163 | if (($isPriorityItem = ($item instanceof IPriorityItem)) && ($priority === null || !is_numeric($priority))) { |
||
| 164 | $itemPriority = $priority = $item->getPriority(); |
||
| 165 | } |
||
| 166 | $priority = $this->ensurePriority($priority); |
||
| 167 | if (($item instanceof IPriorityCapture) && (!$isPriorityItem || $itemPriority !== $priority)) { |
||
| 168 | $item->setPriority($priority); |
||
| 169 | } |
||
| 170 | |||
| 171 | if (isset($this->_d[$priority])) { |
||
| 172 | if ($index === false) { |
||
| 173 | $c = count($this->_d[$priority]); |
||
| 174 | $this->_d[$priority][] = $item; |
||
| 175 | } elseif (0 <= $index && $index <= count($this->_d[$priority])) { |
||
| 176 | $c = $index; |
||
| 177 | array_splice($this->_d[$priority], $index, 0, [$item]); |
||
| 178 | } else { |
||
| 179 | throw new TInvalidDataValueException('prioritylist_index_invalid', $index, count($this->_d[$priority] ?? []), $priority); |
||
| 180 | } |
||
| 181 | } elseif ($index === 0 || $index === false) { |
||
| 182 | $c = 0; |
||
| 183 | $this->_o = false; |
||
| 184 | $this->_d[$priority] = [$item]; |
||
| 185 | } else { |
||
| 186 | throw new TInvalidDataValueException('prioritylist_index_invalid', $index, 0, $priority); |
||
| 187 | } |
||
| 188 | |||
| 189 | if ($preserveCache) { |
||
| 190 | if ($this->_fd !== null) { |
||
| 191 | $this->sortPriorities(); |
||
| 192 | foreach ($this->_d as $prioritykey => $items) { |
||
| 193 | if ($prioritykey >= $priority) { |
||
| 194 | break; |
||
| 195 | } else { |
||
| 196 | $c += count($items); |
||
| 197 | } |
||
| 198 | } |
||
| 199 | array_splice($this->_fd, $c, 0, [$item]); |
||
| 200 | } |
||
| 201 | } else { |
||
| 202 | if ($this->_fd !== null && count($this->_d) == 1) { |
||
| 203 | array_splice($this->_fd, $c, 0, [$item]); |
||
| 204 | } else { |
||
| 205 | $this->_fd = null; |
||
| 206 | $c = null; |
||
| 207 | } |
||
| 208 | } |
||
| 209 | |||
| 210 | $this->_c++; |
||
| 211 | |||
| 212 | return $c; |
||
| 213 | } |
||
| 214 | |||
| 215 | |||
| 216 | /** |
||
| 217 | * Removes an item from the priority list. |
||
| 218 | * The list will search for the item. The first matching item found will be removed from the list. |
||
| 219 | * @param mixed $item item the item to be removed. |
||
| 220 | * @param null|bool|float $priority priority of item to remove. without this parameter it defaults to false. |
||
| 221 | * A value of false means any priority. null will be filled in with the default priority. |
||
| 222 | * @throws TInvalidDataValueException If the item does not exist |
||
| 223 | * @return int index within the flattened list at which the item is being removed |
||
| 224 | */ |
||
| 225 | public function remove($item, $priority = false) |
||
| 226 | { |
||
| 227 | if ($this->getReadOnly()) { |
||
| 228 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 229 | } |
||
| 230 | |||
| 231 | if (($p = $this->priorityOf($item, true)) !== false) { |
||
| 232 | if ($priority !== false) { |
||
| 233 | $priority = $this->ensurePriority($priority); |
||
| 234 | if ($p[0] != $priority) { |
||
| 235 | throw new TInvalidDataValueException('list_item_inexistent'); |
||
| 236 | } |
||
| 237 | } |
||
| 238 | $this->removeAtIndexInPriority($p[1], $p[0]); |
||
| 239 | return $p[2]; |
||
| 240 | } else { |
||
| 241 | throw new TInvalidDataValueException('list_item_inexistent'); |
||
| 242 | } |
||
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * Removes an item at the specified index in the flattened list. |
||
| 247 | * @param int $index index of the item to be removed. |
||
| 248 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
||
| 249 | * @throws TInvalidOperationException if the list is read-only |
||
| 250 | * @return mixed the removed item. |
||
| 251 | */ |
||
| 252 | public function removeAt($index) |
||
| 253 | { |
||
| 254 | if ($this->getReadOnly()) { |
||
| 255 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 256 | } |
||
| 257 | |||
| 258 | if (($priority = $this->priorityAt($index, true)) !== false) { |
||
| 259 | return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
||
| 260 | } |
||
| 261 | throw new TInvalidDataValueException('list_index_invalid', $index); |
||
| 262 | } |
||
| 263 | |||
| 264 | /** |
||
| 265 | * Removes the item at a specific index within a priority. Override |
||
| 266 | * and call this method to insert your own functionality. |
||
| 267 | * @param int $index index of item to remove within the priority. |
||
| 268 | * @param null|numeric $priority priority of the item to remove, defaults to null, or left blank, it is then set to the default priority |
||
| 269 | * @throws TInvalidDataValueException If the item does not exist |
||
| 270 | * @return mixed the removed item. |
||
| 271 | */ |
||
| 272 | public function removeAtIndexInPriority($index, $priority = null) |
||
| 273 | { |
||
| 274 | if ($this->getReadOnly()) { |
||
| 275 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 276 | } |
||
| 277 | |||
| 278 | $priority = $this->ensurePriority($priority); |
||
| 279 | if (!isset($this->_d[$priority]) || $index < 0 || $index >= ($c = count($this->_d[$priority]))) { |
||
| 280 | throw new TInvalidDataValueException('list_item_inexistent'); |
||
| 281 | } |
||
| 282 | |||
| 283 | if ($index === $c - 1) { |
||
| 284 | $value = array_pop($this->_d[$priority]); |
||
| 285 | } else { |
||
| 286 | $value = array_splice($this->_d[$priority], $index, 1); |
||
| 287 | $value = $value[0]; |
||
| 288 | } |
||
| 289 | if (!count($this->_d[$priority])) { |
||
| 290 | unset($this->_d[$priority]); |
||
| 291 | } |
||
| 292 | |||
| 293 | $this->_c--; |
||
| 294 | $this->_fd = null; |
||
| 295 | return $value; |
||
| 296 | } |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Removes all items in the priority list by calling removeAtIndexInPriority from the last item to the first. |
||
| 300 | */ |
||
| 301 | public function clear(): void |
||
| 302 | { |
||
| 303 | if ($this->getReadOnly()) { |
||
| 304 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 305 | } |
||
| 306 | |||
| 307 | foreach (array_keys($this->_d) as $priority) { |
||
| 308 | for ($index = count($this->_d[$priority]) - 1; $index >= 0; $index--) { |
||
| 309 | $this->removeAtIndexInPriority($index, $priority); |
||
| 310 | } |
||
| 311 | } |
||
| 312 | } |
||
| 313 | |||
| 314 | /** |
||
| 315 | * @param mixed $item item |
||
| 316 | * @return int the index of the item in the flattened list (0 based), -1 if not found. |
||
| 317 | */ |
||
| 318 | public function indexOf($item) |
||
| 319 | { |
||
| 320 | $this->flattenPriorities(); |
||
| 321 | if (($index = array_search($item, $this->_fd, true)) === false) { |
||
| 322 | return -1; |
||
| 323 | } else { |
||
| 324 | return $index; |
||
| 325 | } |
||
| 326 | } |
||
| 327 | |||
| 328 | /** |
||
| 329 | * Returns the priority of a particular item |
||
| 330 | * @param mixed $item the item to look for within the list |
||
| 331 | * @param bool $withindex this specifies if the full positional data of the item within the list is returned. |
||
| 332 | * This defaults to false, if no parameter is provided, so only provides the priority number of the item by default. |
||
| 333 | * @return array|false|numeric the priority of the item in the list, false if not found. |
||
| 334 | * if $withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
||
| 335 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
||
| 336 | */ |
||
| 337 | public function priorityOf($item, $withindex = false) |
||
| 338 | { |
||
| 339 | $this->sortPriorities(); |
||
| 340 | |||
| 341 | $absindex = 0; |
||
| 342 | foreach (array_keys($this->_d) as $priority) { |
||
| 343 | if (($index = array_search($item, $this->_d[$priority], true)) !== false) { |
||
| 344 | $absindex += $index; |
||
| 345 | return $withindex ? [$priority, $index, $absindex, |
||
| 346 | 'priority' => $priority, 'index' => $index, 'absindex' => $absindex, ] : $priority; |
||
| 347 | } else { |
||
| 348 | $absindex += count($this->_d[$priority]); |
||
| 349 | } |
||
| 350 | } |
||
| 351 | |||
| 352 | return false; |
||
| 353 | } |
||
| 354 | |||
| 355 | /** |
||
| 356 | * Returns the priority of an item at a particular flattened index. The index after |
||
| 357 | * the last item does not exist but receives a priority from the last item so that |
||
| 358 | * priority information about any new items being appended is available. |
||
| 359 | * @param int $index index of the item within the list |
||
| 360 | * @param bool $withindex this specifies if the full positional data of the item within the list is returned. |
||
| 361 | * This defaults to false, if no parameter is provided, so only provides the priority number of the item by default. |
||
| 362 | * @return array|false|numeric the priority of the item in the list, false if not found. |
||
| 363 | * if $withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
||
| 364 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
||
| 365 | */ |
||
| 366 | public function priorityAt($index, $withindex = false) |
||
| 367 | { |
||
| 368 | if (0 <= $index && $index <= $this->_c) { |
||
| 369 | $c = $absindex = $index; |
||
| 370 | $priority = null; |
||
| 371 | $this->sortPriorities(); |
||
| 372 | foreach (array_keys($this->_d) as $priority) { |
||
| 373 | if ($index >= ($c = count($this->_d[$priority]))) { |
||
| 374 | $index -= $c; |
||
| 375 | } else { |
||
| 376 | return $withindex ? [$priority, $index, $absindex, |
||
| 377 | 'priority' => $priority, 'index' => $index, 'absindex' => $absindex, ] : $priority; |
||
| 378 | } |
||
| 379 | } |
||
| 380 | return $withindex ? [$priority, $c, $absindex, |
||
| 381 | 'priority' => $priority, 'index' => $c, 'absindex' => $absindex, ] : $priority; |
||
| 382 | } |
||
| 383 | return false; |
||
| 384 | } |
||
| 385 | |||
| 386 | /** |
||
| 387 | * This inserts an item before another item within the list. It uses the same priority as the |
||
| 388 | * found index item and places the new item before it. |
||
| 389 | * @param mixed $indexitem the item to index |
||
| 390 | * @param mixed $item the item to add before indexitem |
||
| 391 | * @throws TInvalidDataValueException If the item does not exist |
||
| 392 | * @return int where the item has been inserted in the flattened list |
||
| 393 | */ |
||
| 394 | public function insertBefore($indexitem, $item) |
||
| 395 | { |
||
| 396 | if ($this->getReadOnly()) { |
||
| 397 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 398 | } |
||
| 399 | |||
| 400 | if (($priority = $this->priorityOf($indexitem, true)) === false) { |
||
| 401 | throw new TInvalidDataValueException('list_item_inexistent'); |
||
| 402 | } |
||
| 403 | |||
| 404 | $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
||
| 405 | |||
| 406 | return $priority[2]; |
||
| 407 | } |
||
| 408 | |||
| 409 | /** |
||
| 410 | * This inserts an item after another item within the list. It uses the same priority as the |
||
| 411 | * found index item and places the new item after it. |
||
| 412 | * @param mixed $indexitem the item to index |
||
| 413 | * @param mixed $item the item to add after indexitem |
||
| 414 | * @throws TInvalidDataValueException If the item does not exist |
||
| 415 | * @return int where the item has been inserted in the flattened list |
||
| 416 | */ |
||
| 417 | public function insertAfter($indexitem, $item) |
||
| 418 | { |
||
| 419 | if ($this->getReadOnly()) { |
||
| 420 | throw new TInvalidOperationException('list_readonly', $this::class); |
||
| 421 | } |
||
| 422 | |||
| 423 | if (($priority = $this->priorityOf($indexitem, true)) === false) { |
||
| 424 | throw new TInvalidDataValueException('list_item_inexistent'); |
||
| 425 | } |
||
| 426 | |||
| 427 | $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
||
| 428 | |||
| 429 | return $priority[2] + 1; |
||
| 430 | } |
||
| 431 | |||
| 432 | /** |
||
| 433 | * Copies iterable data into the priority list. |
||
| 434 | * Note, existing data in the map will be cleared first. |
||
| 435 | * @param mixed $data the data to be copied from, must be an array or object implementing Traversable |
||
| 436 | * @throws TInvalidDataTypeException If data is neither an array nor an iterator. |
||
| 437 | */ |
||
| 438 | public function copyFrom($data): void |
||
| 439 | { |
||
| 440 | if ($data instanceof TPriorityList) { |
||
| 441 | if ($this->getCount() > 0) { |
||
| 442 | $this->clear(); |
||
| 443 | } |
||
| 444 | $array = $data->toPriorityArray(); |
||
| 445 | foreach (array_keys($array) as $priority) { |
||
| 446 | for ($i = 0, $c = count($array[$priority]); $i < $c; $i++) { |
||
| 447 | $this->insertAtIndexInPriority($array[$priority][$i], false, $priority); |
||
| 448 | } |
||
| 449 | } |
||
| 450 | } elseif ($data instanceof TPriorityMap) { |
||
| 451 | if ($this->getCount() > 0) { |
||
| 452 | $this->clear(); |
||
| 453 | } |
||
| 454 | $array = $data->toPriorityArray(); |
||
| 455 | foreach (array_keys($array) as $priority) { |
||
| 456 | foreach ($array[$priority] as $item) { |
||
| 457 | $this->insertAtIndexInPriority($item, false, $priority); |
||
| 458 | } |
||
| 459 | } |
||
| 460 | } elseif (is_array($data) || $data instanceof \Traversable) { |
||
| 461 | if ($this->getCount() > 0) { |
||
| 462 | $this->clear(); |
||
| 463 | } |
||
| 464 | foreach ($data as $item) { |
||
| 465 | $this->insertAtIndexInPriority($item); |
||
| 466 | } |
||
| 467 | } elseif ($data !== null) { |
||
| 468 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
||
| 469 | } |
||
| 470 | } |
||
| 471 | |||
| 472 | /** |
||
| 473 | * Merges iterable data into the priority list. |
||
| 474 | * New data will be appended to the end of the existing data. If another TPriorityList is merged, |
||
| 475 | * the incoming parameter items will be appended at the priorities they are present. These items will be added |
||
| 476 | * to the end of the existing items with equal priorities, if there are any. |
||
| 477 | * @param mixed $data the data to be merged with, must be an array or object implementing Traversable |
||
| 478 | * @throws TInvalidDataTypeException If data is neither an array nor an iterator. |
||
| 479 | */ |
||
| 480 | public function mergeWith($data): void |
||
| 481 | { |
||
| 482 | if ($data instanceof TPriorityList) { |
||
| 483 | $array = $data->toPriorityArray(); |
||
| 484 | foreach (array_keys($array) as $priority) { |
||
| 485 | for ($i = 0, $c = count($array[$priority]); $i < $c; $i++) { |
||
| 486 | $this->insertAtIndexInPriority($array[$priority][$i], false, $priority); |
||
| 487 | } |
||
| 488 | } |
||
| 489 | } elseif ($data instanceof TPriorityMap) { |
||
| 490 | $array = $data->toPriorityArray(); |
||
| 491 | foreach (array_keys($array) as $priority) { |
||
| 492 | foreach ($array[$priority] as $item) { |
||
| 493 | $this->insertAtIndexInPriority($item, false, $priority); |
||
| 494 | } |
||
| 495 | } |
||
| 496 | } elseif (is_array($data) || $data instanceof \Traversable) { |
||
| 497 | foreach ($data as $item) { |
||
| 498 | $this->insertAtIndexInPriority($item); |
||
| 499 | } |
||
| 500 | } elseif ($data !== null) { |
||
| 501 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
||
| 502 | } |
||
| 503 | } |
||
| 504 | |||
| 505 | /** |
||
| 506 | * Returns whether there is an element at the specified offset. |
||
| 507 | * This method is required by the interface \ArrayAccess. |
||
| 508 | * @param mixed $offset the offset to check on |
||
| 509 | * @return bool |
||
| 510 | */ |
||
| 511 | public function offsetExists($offset): bool |
||
| 512 | { |
||
| 513 | return ($offset >= 0 && $offset < $this->getCount()); |
||
| 514 | } |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Sets the element at the specified offset. This method is required by the interface \ArrayAccess. |
||
| 518 | * Setting elements in a priority list is not straight forword when appending and setting at the |
||
| 519 | * end boundary. When appending without an offset (a null offset), the item will be added at |
||
| 520 | * the default priority. The item may not be the last item in the list. When appending with an |
||
| 521 | * offset equal to the count of the list, the item will get be appended with the last items priority. |
||
| 522 | * |
||
| 523 | * All together, when setting the location of an item, the item stays in that location, but appending |
||
| 524 | * an item into a priority list doesn't mean the item is at the end of the list. |
||
| 525 | * @param int $offset the offset to set element |
||
| 526 | * @param mixed $item the element value |
||
| 527 | */ |
||
| 528 | public function offsetSet($offset, $item): void |
||
| 529 | { |
||
| 530 | if ($offset === null) { |
||
| 531 | $this->add($item); |
||
| 532 | return; |
||
| 533 | } |
||
| 534 | if ($offset === $this->getCount()) { |
||
| 535 | $priority = $this->priorityAt($offset, true); |
||
| 536 | } else { |
||
| 537 | $priority = $this->priorityAt($offset, true); |
||
| 538 | $this->removeAtIndexInPriority($priority[1], $priority[0]); |
||
| 539 | } |
||
| 540 | $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
||
| 541 | } |
||
| 542 | |||
| 543 | /** |
||
| 544 | * Unsets the element at the specified offset. |
||
| 545 | * This method is required by the interface \ArrayAccess. |
||
| 546 | * @param mixed $offset the offset to unset element |
||
| 547 | */ |
||
| 548 | public function offsetUnset($offset): void |
||
| 549 | { |
||
| 550 | $this->removeAt($offset); |
||
| 551 | } |
||
| 552 | |||
| 553 | /** |
||
| 554 | * Returns an array with the names of all variables of this object that should NOT be serialized |
||
| 555 | * because their value is the default one or useless to be cached for the next page loads. |
||
| 556 | * Reimplement in derived classes to add new variables, but remember to also to call the parent |
||
| 557 | * implementation first. |
||
| 558 | * @param array $exprops by reference |
||
| 559 | * @since 4.2.3 |
||
| 560 | */ |
||
| 561 | protected function _getZappableSleepProps(&$exprops) |
||
| 565 | } |
||
| 566 | } |
||
| 567 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths