Skip to content

Commit 9deab00

Browse files
Replace "use-by-ref" by static vars when possible in closures
1 parent ce99d4a commit 9deab00

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ChoiceList/ArrayChoiceList.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ public function __construct(iterable $choices, callable $value = null)
7272
$this->valueCallback = $value;
7373
} else {
7474
// Otherwise generate incrementing integers as values
75-
$i = 0;
76-
$value = function () use (&$i) {
75+
$value = function () {
76+
static $i = 0;
77+
7778
return $i++;
7879
};
7980
}

0 commit comments

Comments
 (0)