Complex classes like SortedSets 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 SortedSets, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 9 | trait SortedSets | ||
| 10 | { | ||
| 11 | /* | ||
| 12 | * Available Set Operations | ||
| 13 | */ | ||
| 14 | protected $SET_OPERATIONS = ['SUM', 'MIN', 'MAX']; | ||
| 15 | |||
| 16 | |||
| 17 | /** | ||
| 18 | * Block until Redis can pop the highest or lowest scoring members from one | ||
| 19 | * or more ZSETs. There are two commands (BZPOPMIN and BZPOPMAX for popping | ||
| 20 | * the lowest and highest scoring elements respectively.) | ||
| 21 | * | ||
| 22 | * Note: Calling these functions with an array of keys or with a variable | ||
| 23 | * number of arguments is functionally identical. | ||
| 24 | * | ||
| 25 | * See: https://redis.io/commands/bzpopmin. | ||
| 26 | * See: https://redis.io/commands/bzpopmax. | ||
| 27 | * | ||
| 28 | * @param array $keys The ZSETs you wish to run against | ||
| 29 | * @param int $timeout [description] | ||
| 30 | * @param bool|boolean $max [description] | ||
| 31 | * | ||
| 32 | * @return array Either an array with the key member and score | ||
| 33 | * of the highest or lowest element or an empty | ||
| 34 | * array if the timeout was reached without an | ||
| 35 | * element to pop. | ||
| 36 | */ | ||
| 37 | public function bzPop(array $keys, int $timeout, bool $max = false): array | ||
| 43 | |||
| 44 | /** | ||
| 45 | * Block until Redis can pop the lowest scoring members from one or more ZSETs. | ||
| 46 | * | ||
| 47 | * See: https://redis.io/commands/bzpopmin. | ||
| 48 | * | ||
| 49 | * @param array $keys The ZSETs you wish to run against | ||
| 50 | * @param int $timeout [description] | ||
| 51 | * | ||
| 52 | * @return array Either an array with the key member and score | ||
| 53 | * of the highest or lowest element or an empty | ||
| 54 | * array if the timeout was reached without an | ||
| 55 | * element to pop. | ||
| 56 | */ | ||
| 57 | public function bzPopMin(array $keys, int $timeout): array | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Block until Redis can pop the lowest scoring members from one or more ZSETs. | ||
| 64 | * | ||
| 65 | * See: https://redis.io/commands/bzpopmax. | ||
| 66 | * | ||
| 67 | * @param array $keys The ZSETs you wish to run against | ||
| 68 | * @param int $timeout [description] | ||
| 69 | * | ||
| 70 | * @return array Either an array with the key member and score | ||
| 71 | * of the highest or lowest element or an empty | ||
| 72 | * array if the timeout was reached without an | ||
| 73 | * element to pop. | ||
| 74 | */ | ||
| 75 | public function bzPopMax(array $keys, int $timeout): array | ||
| 79 | |||
| 80 | |||
| 81 | /** | ||
| 82 | * Add one or more members to a sorted set or update its score if it | ||
| 83 | * already exists. | ||
| 84 | * | ||
| 85 | * See: https://redis.io/commands/zadd. | ||
| 86 | * | ||
| 87 | * @param string $key | ||
| 88 | * @param float $score | ||
| 89 | * @param mixed] $member | ||
| 90 | * | ||
| 91 | * @return int 1 if the element is added. 0 otherwise. | ||
| 92 | */ | ||
| 93 | public function zAdd(string $key, float $score, $member): int | ||
| 97 | |||
| 98 | |||
| 99 | /** | ||
| 100 | * Get the number of members in a sorted set. | ||
| 101 | * See: https://redis.io/commands/zcard. | ||
| 102 | * | ||
| 103 | * @param string $key | ||
| 104 | * | ||
| 105 | * @return int The Set's cardinality | ||
| 106 | */ | ||
| 107 | public function zCard(string $key): int | ||
| 111 | |||
| 112 | |||
| 113 | /** | ||
| 114 | * Get the number of members in a sorted set. | ||
| 115 | * | ||
| 116 | * Note: zSize is an alias for zCard and will be removed in future | ||
| 117 | * versions of phpredis. | ||
| 118 | * | ||
| 119 | * See: https://redis.io/commands/zcard. | ||
| 120 | * | ||
| 121 | * @param string $key | ||
| 122 | * | ||
| 123 | * @return int The Set's cardinality | ||
| 124 | */ | ||
| 125 | public function zSize(string $key): int | ||
| 129 | |||
| 130 | |||
| 131 | /** | ||
| 132 | * Returns the number of elements of the sorted set stored at the specified | ||
| 133 | * key which have scores in the range [start, end]. Adding a parenthesis | ||
| 134 | * before start or end excludes it from the range. +inf and -inf are also | ||
| 135 | * valid limits. | ||
| 136 | * | ||
| 137 | * See: https://redis.io/commands/zcount. | ||
| 138 | * | ||
| 139 | * @param string $key | ||
| 140 | * @param mixed|int|string $start | ||
| 141 | * @param mixed|int|string $end | ||
| 142 | * | ||
| 143 | * @return int the size of a corresponding zRangeByScore. | ||
| 144 | */ | ||
| 145 | public function zCount(string $key, $start, $end): int | ||
| 149 | |||
| 150 | |||
| 151 | /** | ||
| 152 | * Increments the score of a member from a sorted set by a given amount. | ||
| 153 | * | ||
| 154 | * See: https://redis.io/commands/zincrby. | ||
| 155 | * | ||
| 156 | * @param string $key | ||
| 157 | * @param float $value (double) value that will be added to the | ||
| 158 | * member's score). | ||
| 159 | * @param string $member | ||
| 160 | * | ||
| 161 | * @return float the new value | ||
| 162 | */ | ||
| 163 | public function zIncrBy(string $key, float $value, $member): float | ||
| 167 | |||
| 168 | |||
| 169 | /** | ||
| 170 | * Creates an intersection of sorted sets given in second argument. | ||
| 171 | * The result of the union will be stored in the sorted set defined by the | ||
| 172 | * first argument. | ||
| 173 | * | ||
| 174 | * The third optional argument defines weights to apply to the sorted sets | ||
| 175 | * in input. In this case, the weights will be multiplied by the score of | ||
| 176 | * each element in the sorted set before applying the aggregation. The | ||
| 177 | * forth argument defines the AGGREGATE option which specify how the | ||
| 178 | * results of the union are aggregated. | ||
| 179 | * | ||
| 180 | * See: https://redis.io/commands/zinterstore. | ||
| 181 | * | ||
| 182 | * @param string $keyOutput | ||
| 183 | * @param array $arrayZSetKeys | ||
| 184 | * @param array $arrayWeights | ||
| 185 | * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": | ||
| 186 | * defines the behaviour to use on | ||
| 187 | * duplicate entries during the | ||
| 188 | * zInterStore. | ||
| 189 | * | ||
| 190 | * @return int The number of values in the new | ||
| 191 | * sorted set. | ||
| 192 | */ | ||
| 193 | public function zInterStore( | ||
| 218 | |||
| 219 | |||
| 220 | /** | ||
| 221 | * Creates an intersection of sorted sets given in second argument. | ||
| 222 | * The result of the union will be stored in the sorted set defined by the | ||
| 223 | * first argument. | ||
| 224 | * | ||
| 225 | * The third optional argument defines weights to apply to the sorted sets | ||
| 226 | * in input. In this case, the weights will be multiplied by the score of | ||
| 227 | * each element in the sorted set before applying the aggregation. The | ||
| 228 | * forth argument defines the AGGREGATE option which specify how the | ||
| 229 | * results of the union are aggregated. | ||
| 230 | * | ||
| 231 | * Note: zInter is an alias for zinterstore and will be removed in future | ||
| 232 | * versions of phpredis. | ||
| 233 | * | ||
| 234 | * See: https://redis.io/commands/zinterstore. | ||
| 235 | * | ||
| 236 | * @param string $keyOutput | ||
| 237 | * @param array $arrayZSetKeys | ||
| 238 | * @param array $arrayWeights | ||
| 239 | * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": | ||
| 240 | * defines the behaviour to use on | ||
| 241 | * duplicate entries during the | ||
| 242 | * zInterStore. | ||
| 243 | * | ||
| 244 | * @return int The number of values in the new | ||
| 245 | * sorted set. | ||
| 246 | */ | ||
| 247 | public function zInter( | ||
| 272 | |||
| 273 | |||
| 274 | /** | ||
| 275 | * Can pop the highest or lowest scoring members from one ZSETs. | ||
| 276 | * There are two commands (ZPOPMIN and ZPOPMAX for popping the lowest and | ||
| 277 | * highest scoring elements respectively.). | ||
| 278 | * | ||
| 279 | * See: https://redis.io/commands/zpopmin. | ||
| 280 | * See: https://redis.io/commands/zpopmax. | ||
| 281 | * | ||
| 282 | * @param string $key | ||
| 283 | * @param int|integer $count | ||
| 284 | * @param bool|boolean $max | ||
| 285 | * | ||
| 286 | * @return array Either an array with the key member and | ||
| 287 | * score of the highest or lowest element | ||
| 288 | * or an empty array if there is no element | ||
| 289 | * available. | ||
| 290 | */ | ||
| 291 | public function zPop(string $key, int $count = 1, bool $max = true): array | ||
| 295 | |||
| 296 | |||
| 297 | /** | ||
| 298 | * Can pop the lowest scoring members from one ZSETs. | ||
| 299 | * | ||
| 300 | * See: https://redis.io/commands/zpopmin. | ||
| 301 | * | ||
| 302 | * @param string $key | ||
| 303 | * @param int|integer $count | ||
| 304 | * | ||
| 305 | * @return array Either an array with the key member and | ||
| 306 | * score of the highest or lowest element | ||
| 307 | * or an empty array if there is no element | ||
| 308 | * available. | ||
| 309 | */ | ||
| 310 | public function zPopMin(string $key, int $count = 1): array | ||
| 314 | |||
| 315 | |||
| 316 | /** | ||
| 317 | * Can pop the highest scoring members from one ZSETs. | ||
| 318 | * | ||
| 319 | * See: https://redis.io/commands/zpopmax. | ||
| 320 | * | ||
| 321 | * @param string $key | ||
| 322 | * @param int|integer $count | ||
| 323 | * | ||
| 324 | * @return array Either an array with the key member and | ||
| 325 | * score of the highest or lowest element | ||
| 326 | * or an empty array if there is no element | ||
| 327 | * available. | ||
| 328 | */ | ||
| 329 | public function zPopMax(string $key, int $count = 1): array | ||
| 333 | |||
| 334 | |||
| 335 | /** | ||
| 336 | * Returns a range of elements from the ordered set stored at the specified | ||
| 337 | * key, with values in the range [start, end]. | ||
| 338 | * | ||
| 339 | * Start and stop are interpreted as zero-based indices: | ||
| 340 | * 0 the first element, 1 the second ... | ||
| 341 | * -1 the last element, -2 the penultimate ... | ||
| 342 | * | ||
| 343 | * See: https://redis.io/commands/zrange. | ||
| 344 | * | ||
| 345 | * @param string $key | ||
| 346 | * @param int|integer $start | ||
| 347 | * @param int|integer $end | ||
| 348 | * @param bool|boolean $withScores | ||
| 349 | * | ||
| 350 | * @return array Array containing the values in specified range. | ||
| 351 | */ | ||
| 352 | public function zRange(string $key, int $start = 0, int $end = -1, bool $withScores = false): array | ||
| 356 | |||
| 357 | |||
| 358 | /** | ||
| 359 | * Returns the elements of the sorted set stored at the specified key which | ||
| 360 | * have scores in the range [start,end]. Adding a parenthesis before start | ||
| 361 | * or end excludes it from the range. +inf and -inf are also valid limits. | ||
| 362 | * | ||
| 363 | * See: https://redis.io/commands/zrangebyscore. | ||
| 364 | * | ||
| 365 | * @param string $key | ||
| 366 | * @param mixed|int|string $start | ||
| 367 | * @param mixed|int|string $end | ||
| 368 | * @param array|null $options Two options are available: | ||
| 369 | * - withscores => TRUE, | ||
| 370 | * and limit => [$offset, $count] | ||
| 371 | * | ||
| 372 | * @return array Array containing the values in | ||
| 373 | * specified range. | ||
| 374 | */ | ||
| 375 | public function zRangeByScore(string $key, $start, $end, ?array $options = null): array | ||
| 389 | |||
| 390 | |||
| 391 | /** | ||
| 392 | * Returns the elements of the sorted set stored at the specified key which | ||
| 393 | * have scores in the range [start,end]. Adding a parenthesis before start | ||
| 394 | * or end excludes it from the range. +inf and -inf are also valid limits. | ||
| 395 | * | ||
| 396 | * zRevRangeByScore returns the same items in reverse order, when the start | ||
| 397 | * and end parameters are swapped. | ||
| 398 | * | ||
| 399 | * See: https://redis.io/commands/zrevrangebyscore. | ||
| 400 | * | ||
| 401 | * @param string $key | ||
| 402 | * @param mixed|int|string $start | ||
| 403 | * @param mixed|int|string $end | ||
| 404 | * @param array|null $options Two options are available: | ||
| 405 | * - withscores => TRUE, | ||
| 406 | * and limit => [$offset, $count] | ||
| 407 | * | ||
| 408 | * @return array Array containing the values in | ||
| 409 | * specified range. | ||
| 410 | */ | ||
| 411 | public function zRevRangeByScore(string $key, $start, $end, ?array $options = null): array | ||
| 425 | |||
| 426 | |||
| 427 | /** | ||
| 428 | * Returns a lexicographical range of members in a sorted set, assuming the | ||
| 429 | * members have the same score. The min and max values are required to start | ||
| 430 |      * with '(' (exclusive), '[' (inclusive), or be exactly the values | ||
| 431 | * '-' (negative inf) or '+' (positive inf). | ||
| 432 | * | ||
| 433 | * The command must be called with either three or five arguments or will | ||
| 434 | * return FALSE. | ||
| 435 | * | ||
| 436 | * See: https://redis.io/commands/zrangebylex | ||
| 437 | * | ||
| 438 | * @param string $key The ZSET you wish to run against | ||
| 439 | * @param mixed|string $min The minimum alphanumeric value you wish to get | ||
| 440 | * @param mixed|string $max The maximum alphanumeric value you wish to get | ||
| 441 | * @param int|null $offset Optional argument if you wish to start | ||
| 442 | * somewhere other than the first element. | ||
| 443 | * @param int|null $limit Optional argument if you wish to limit the | ||
| 444 | * number of elements returned. | ||
| 445 | * | ||
| 446 | * @return array Array containing the values in the specified | ||
| 447 | * range. | ||
| 448 | */ | ||
| 449 | public function zRangeByLex(string $key, $min, $max, ?int $offset = null, ?int $limit = null): array | ||
| 465 | |||
| 466 | |||
| 467 | /** | ||
| 468 | * Returns the rank of a given member in the specified sorted set, starting | ||
| 469 | * at 0 for the item with the smallest score. | ||
| 470 | * | ||
| 471 | * See: https://redis.io/commands/zrank. | ||
| 472 | * | ||
| 473 | * @param string $key The ZSET you wish to run against | ||
| 474 | * @param mixed|string|int|float $member The member to look for | ||
| 475 | * | ||
| 476 | * @return int The member's rank position | ||
| 477 | */ | ||
| 478 | public function zRank(string $key, $member): int | ||
| 482 | |||
| 483 | |||
| 484 | /** | ||
| 485 | * Returns the rank of a given member in the specified sorted set, starting | ||
| 486 | * at 0 for the item with the smallest score. | ||
| 487 | * | ||
| 488 | * zRevRank starts at 0 for the item with the largest score. | ||
| 489 | * | ||
| 490 | * See: https://redis.io/commands/zrevrank. | ||
| 491 | * | ||
| 492 | * @param string $key The ZSET you wish to run against | ||
| 493 | * @param mixed|string|int|float $member The member to look for | ||
| 494 | * | ||
| 495 | * @return int The member's rank position | ||
| 496 | */ | ||
| 497 | public function zRevRank(string $key, $member): int | ||
| 501 | |||
| 502 | |||
| 503 | /** | ||
| 504 | * Delete one or more members from a sorted set. | ||
| 505 | * | ||
| 506 | * See: https://redis.io/commands/zrem. | ||
| 507 | * | ||
| 508 | * @param string $key The ZSET you wish to run against | ||
| 509 | * @param splay $members Member(s) to be removed from the ZSET | ||
| 510 | * | ||
| 511 | * @return int The number of members deleted. | ||
| 512 | */ | ||
| 513 | public function zRem(string $key, ...$members): int | ||
| 517 | |||
| 518 | |||
| 519 | /** | ||
| 520 | * Delete one or more members from a sorted set. | ||
| 521 | * | ||
| 522 | * Note: zDelete and zRemove are an alias for zRem and will be removed | ||
| 523 | * in future versions of phpredis. | ||
| 524 | * | ||
| 525 | * See: https://redis.io/commands/zrem. | ||
| 526 | * | ||
| 527 | * @param string $key The ZSET you wish to run against | ||
| 528 | * @param splay $members Member(s) to be removed from the ZSET | ||
| 529 | * | ||
| 530 | * @return int The number of members deleted. | ||
| 531 | */ | ||
| 532 | public function zDelete(string $key, ...$members): int | ||
| 536 | |||
| 537 | |||
| 538 | /** | ||
| 539 | * Delete one or more members from a sorted set. | ||
| 540 | * | ||
| 541 | * Note: zDelete and zRemove are an alias for zRem and will be removed | ||
| 542 | * in future versions of phpredis. | ||
| 543 | * | ||
| 544 | * See: https://redis.io/commands/zrem. | ||
| 545 | * | ||
| 546 | * @param string $key The ZSET you wish to run against | ||
| 547 | * @param splay $members Member(s) to be removed from the ZSET | ||
| 548 | * | ||
| 549 | * @return int The number of members deleted. | ||
| 550 | */ | ||
| 551 | public function zRemove(string $key, ...$members): int | ||
| 555 | |||
| 556 | |||
| 557 | /** | ||
| 558 | * Deletes the elements of the sorted set stored at the specified key which | ||
| 559 | * have rank in the range [start,end]. | ||
| 560 | * | ||
| 561 | * See: https://redis.io/commands/zremrangebyrank. | ||
| 562 | * | ||
| 563 | * @param string $key The ZSET you wish to run against | ||
| 564 | * @param int $start | ||
| 565 | * @param int $end | ||
| 566 | * | ||
| 567 | * @return int The number of values deleted from the sorted set | ||
| 568 | */ | ||
| 569 | public function zRemRangeByRank(string $key, int $start, int $end): int | ||
| 577 | |||
| 578 | |||
| 579 | /** | ||
| 580 | * Deletes the elements of the sorted set stored at the specified key which | ||
| 581 | * have rank in the range [start,end]. | ||
| 582 | * | ||
| 583 | * Note: zDeleteRangeByRank is an alias for zRemRangeByRank and will be | ||
| 584 | * removed in future versions of phpredis. | ||
| 585 | * | ||
| 586 | * See: https://redis.io/commands/zremrangebyrank. | ||
| 587 | * | ||
| 588 | * @param string $key The ZSET you wish to run against | ||
| 589 | * @param int $start | ||
| 590 | * @param int $end | ||
| 591 | * | ||
| 592 | * @return int The number of values deleted from the sorted set | ||
| 593 | */ | ||
| 594 | public function zDeleteRangeByRank(string $key, int $start, int $end): int | ||
| 602 | |||
| 603 | |||
| 604 | /** | ||
| 605 | * Deletes the elements of the sorted set stored at the specified key which | ||
| 606 | * have scores in the range [start,end]. | ||
| 607 | * | ||
| 608 | * See: https://redis.io/commands/zremrangebyscore. | ||
| 609 | * | ||
| 610 | * @param string $key The ZSET you wish to run against | ||
| 611 | * @param mixed|float|string $start double or "+inf" or "-inf" string | ||
| 612 | * @param mixed|float|string $end double or "+inf" or "-inf" string | ||
| 613 | * | ||
| 614 | * @return The number of values deleted from the sorted set | ||
| 615 | */ | ||
| 616 | public function zRemRangeByScore(string $key, $start, $end): int | ||
| 628 | |||
| 629 | |||
| 630 | /** | ||
| 631 | * Deletes the elements of the sorted set stored at the specified key which | ||
| 632 | * have scores in the range [start,end]. | ||
| 633 | * | ||
| 634 | * Note: zDeleteRangeByScore and zRemoveRangeByScore are an alias for | ||
| 635 | * zRemRangeByScore and will be removed in future versions of phpredis. | ||
| 636 | * | ||
| 637 | * See: https://redis.io/commands/zremrangebyscore. | ||
| 638 | * | ||
| 639 | * @param string $key The ZSET you wish to run against | ||
| 640 | * @param mixed|float|string $start double or "+inf" or "-inf" string | ||
| 641 | * @param mixed|float|string $end double or "+inf" or "-inf" string | ||
| 642 | * | ||
| 643 | * @return The number of values deleted from the sorted set | ||
| 644 | */ | ||
| 645 | public function zDeleteRangeByScore(string $key, $start, $end): int | ||
| 657 | |||
| 658 | |||
| 659 | /** | ||
| 660 | * Deletes the elements of the sorted set stored at the specified key which | ||
| 661 | * have scores in the range [start,end]. | ||
| 662 | * | ||
| 663 | * Note: zDeleteRangeByScore and zRemoveRangeByScore are an alias for | ||
| 664 | * zRemRangeByScore and will be removed in future versions of phpredis. | ||
| 665 | * | ||
| 666 | * See: https://redis.io/commands/zremrangebyscore. | ||
| 667 | * | ||
| 668 | * @param string $key The ZSET you wish to run against | ||
| 669 | * @param mixed|float|string $start double or "+inf" or "-inf" string | ||
| 670 | * @param mixed|float|string $end double or "+inf" or "-inf" string | ||
| 671 | * | ||
| 672 | * @return The number of values deleted from the sorted set | ||
| 673 | */ | ||
| 674 | public function zRemoveRangeByScore(string $key, $start, $end): int | ||
| 686 | |||
| 687 | |||
| 688 | /** | ||
| 689 | * Returns the elements of the sorted set stored at the specified key in | ||
| 690 | * the range [start, end] in reverse order. start and stop are interpreted | ||
| 691 | * as zero-based indices: | ||
| 692 | * 0 the first element, 1 the second ... | ||
| 693 | * -1 the last element, -2 the penultimate ... | ||
| 694 | * | ||
| 695 | * See: https://redis.io/commands/zrevrange. | ||
| 696 | * | ||
| 697 | * @param string $key The ZSET you wish to run against | ||
| 698 | * @param int $start 0 the first element, 1 the second ... | ||
| 699 | * @param int $end -1 the last element, -2 the penultimate ... | ||
| 700 | * @param bool|boolean $withScores false No Scores | true Scores in | ||
| 701 | * associative array | ||
| 702 | * | ||
| 703 | * @return array Array containing the values in | ||
| 704 | * specified range. | ||
| 705 | */ | ||
| 706 | public function zRevRange(string $key, int $start = 0, int $end = -1, bool $withScores = false): array | ||
| 710 | |||
| 711 | |||
| 712 | /** | ||
| 713 | * Returns the score of a given member in the specified sorted set. | ||
| 714 | * | ||
| 715 | * @param string $key The ZSET you wish to run against. | ||
| 716 | * @param mixed|string|float|int $member | ||
| 717 | * | ||
| 718 | * @return float The Score associated with the Member. | ||
| 719 | */ | ||
| 720 | public function zScore(string $key, $member): float | ||
| 724 | |||
| 725 | |||
| 726 | /** | ||
| 727 | * Creates an union of sorted sets given in second argument. | ||
| 728 | * The result of the union will be stored in the sorted set defined by the | ||
| 729 | * first argument. | ||
| 730 | * | ||
| 731 | * The third optional argument defines weights to apply to the sorted sets | ||
| 732 | * in input. In this case, the weights will be multiplied by the score of | ||
| 733 | * each element in the sorted set before applying the aggregation. The | ||
| 734 | * forth argument defines the AGGREGATE option which specify how the | ||
| 735 | * results of the union are aggregated. | ||
| 736 | * | ||
| 737 | * See: https://redis.io/commands/zunionstore. | ||
| 738 | * | ||
| 739 | * @param string $keyOutput The ZSET you wish to store the result. | ||
| 740 | * @param array $arrayZSetKeys | ||
| 741 | * @param array $arrayWeights | ||
| 742 | * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": | ||
| 743 | * defines the behaviour to use on | ||
| 744 | * duplicate entries during the | ||
| 745 | * zunionstore. | ||
| 746 | * | ||
| 747 | * @return [type] | ||
| 748 | */ | ||
| 749 | public function zUnionStore( | ||
| 773 | |||
| 774 | |||
| 775 | /** | ||
| 776 | * Creates an union of sorted sets given in second argument. | ||
| 777 | * The result of the union will be stored in the sorted set defined by the | ||
| 778 | * first argument. | ||
| 779 | * | ||
| 780 | * The third optional argument defines weights to apply to the sorted sets | ||
| 781 | * in input. In this case, the weights will be multiplied by the score of | ||
| 782 | * each element in the sorted set before applying the aggregation. The | ||
| 783 | * forth argument defines the AGGREGATE option which specify how the | ||
| 784 | * results of the union are aggregated. | ||
| 785 | * | ||
| 786 | * Note: zUnion is an alias for zunionstore and will be removed in future | ||
| 787 | * versions of phpredis. | ||
| 788 | * | ||
| 789 | * See: https://redis.io/commands/zunionstore. | ||
| 790 | * | ||
| 791 | * @param string $keyOutput The ZSET you wish to store the result. | ||
| 792 | * @param array $arrayZSetKeys | ||
| 793 | * @param array $arrayWeights | ||
| 794 | * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": | ||
| 795 | * defines the behaviour to use on | ||
| 796 | * duplicate entries during the | ||
| 797 | * zunionstore. | ||
| 798 | * | ||
| 799 | * @return [type] | ||
| 800 | */ | ||
| 801 | public function zUnion( | ||
| 825 | |||
| 826 | |||
| 827 | /** | ||
| 828 | * Scan a sorted set for members, with optional pattern and count. | ||
| 829 | * | ||
| 830 | * @param string $key The ZSET you wish to run against. | ||
| 831 | * @param int &$iterator Long (reference), initialized to NULL | ||
| 832 | * @param string $pattern String (optional), the pattern to match | ||
| 833 | * @param int|integer $count How many keys to return per iteration | ||
| 834 | * (Redis might return a different number). | ||
| 835 | * | ||
| 836 | * @return Array, boolean PHPRedis will return matching keys from Redis, | ||
| 837 | * or FALSE when iteration is complete | ||
| 838 | */ | ||
| 839 | public function zScan(string $key, ?int &$iterator, string $pattern = '*', int $count = 10) | ||
| 843 | |||
| 844 | |||
| 845 | /** | ||
| 846 | * ======================================================================== | ||
| 847 | * H E L P E R M E T H O D S | ||
| 848 | * ======================================================================== | ||
| 849 | */ | ||
| 850 | |||
| 851 | |||
| 852 | /** | ||
| 853 | * Validate Lex Params | ||
| 854 | * | ||
| 855 | * @param splat $params | ||
| 856 | * | ||
| 857 | * @return bool | ||
| 858 | */ | ||
| 859 | protected function _validateLexParams(...$params) | ||
| 863 | } | ||
| 864 | 
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: