@@ -239,8 +239,12 @@ |
||
239 | 239 | { |
240 | 240 | $n = count($this); |
241 | 241 | |
242 | - if ($n < 2) return 0; |
|
243 | - if ($r < 0) return $n - (abs($r) % $n); |
|
242 | + if ($n < 2) { |
|
243 | + return 0; |
|
244 | + } |
|
245 | + if ($r < 0) { |
|
246 | + return $n - (abs($r) % $n); |
|
247 | + } |
|
244 | 248 | |
245 | 249 | return $r % $n; |
246 | 250 | } |
@@ -118,7 +118,7 @@ |
||
118 | 118 | { |
119 | 119 | $this->capacity = max( |
120 | 120 | self::MIN_CAPACITY, |
121 | - $this->capacity() * $this->getDecayFactor() |
|
121 | + $this->capacity() * $this->getDecayFactor() |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 |
@@ -642,15 +642,15 @@ |
||
642 | 642 | */ |
643 | 643 | private function compactPairRefs() |
644 | 644 | { |
645 | - // Renumber indices from 0 ascending. |
|
646 | - $this->pairRefs = array_slice($this->pairRefs, 0); |
|
647 | - $this->nextPairIndex = count($this->pairRefs); |
|
645 | + // Renumber indices from 0 ascending. |
|
646 | + $this->pairRefs = array_slice($this->pairRefs, 0); |
|
647 | + $this->nextPairIndex = count($this->pairRefs); |
|
648 | 648 | |
649 | - $updateIndex = function(PairRef $pairRef, int $position): void { |
|
650 | - $pairRef->pairIndex = $position; |
|
651 | - }; |
|
649 | + $updateIndex = function(PairRef $pairRef, int $position): void { |
|
650 | + $pairRef->pairIndex = $position; |
|
651 | + }; |
|
652 | 652 | |
653 | - array_walk($this->pairRefs, $updateIndex); |
|
653 | + array_walk($this->pairRefs, $updateIndex); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | private function lookupKey($key, &$hash = null) |
296 | 296 | { |
297 | 297 | $hash = $this->getHash($key); |
298 | - if (!array_key_exists($hash, $this->table)) { |
|
298 | + if ( ! array_key_exists($hash, $this->table)) { |
|
299 | 299 | return null; |
300 | 300 | } |
301 | 301 | |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | $pairRef = new PairRef($pairIndex, $key, $value); |
504 | 504 | $this->pairRefs[$pairIndex] = $pairRef; |
505 | 505 | |
506 | - if (!array_key_exists($hash, $this->table)) { |
|
506 | + if ( ! array_key_exists($hash, $this->table)) { |
|
507 | 507 | $this->table[$hash] = $pairRef; |
508 | 508 | } else { |
509 | - $hashMatch =& $this->table[$hash]; |
|
510 | - if (!is_array($hashMatch)) { |
|
509 | + $hashMatch = & $this->table[$hash]; |
|
510 | + if ( ! is_array($hashMatch)) { |
|
511 | 511 | $this->table[$hash] = [$hashMatch, $pairRef]; |
512 | 512 | } else { |
513 | 513 | $hashMatch[] = $pairRef; |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | |
580 | 580 | // Remove from lookup table. |
581 | 581 | |
582 | - $hashMatch =& $this->table[$hash]; |
|
582 | + $hashMatch = & $this->table[$hash]; |
|
583 | 583 | |
584 | 584 | if ($hashMatch instanceof PairRef) { |
585 | 585 | unset($this->table[$hash]); |
@@ -964,7 +964,8 @@ |
||
964 | 964 | * @template-covariant TKey |
965 | 965 | * @template-covariant TValue |
966 | 966 | */ |
967 | -final class PairRef { |
|
967 | +final class PairRef |
|
968 | +{ |
|
968 | 969 | /** |
969 | 970 | * @var int |
970 | 971 | */ |