Skip to content

Commit 6c116e6

Browse files
Replace "use-by-ref" by static vars when possible in closures
1 parent 2655810 commit 6c116e6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Question/Question.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ public function setAutocompleterValues(?iterable $values): static
148148

149149
$callback = static fn () => $values;
150150
} elseif ($values instanceof \Traversable) {
151-
$valueCache = null;
152-
$callback = static function () use ($values, &$valueCache) {
151+
$callback = static function () use ($values) {
152+
static $valueCache;
153+
153154
return $valueCache ??= iterator_to_array($values, false);
154155
};
155156
} else {

0 commit comments

Comments
 (0)