Skip to content

Commit 9d12f22

Browse files
Replace "use-by-ref" by static vars when possible in closures
1 parent 94e1832 commit 9d12f22

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

AcceptHeader.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ public function __construct(array $items)
4646
*/
4747
public static function fromString(?string $headerValue): self
4848
{
49-
$index = 0;
50-
5149
$parts = HeaderUtils::split($headerValue ?? '', ',;=');
5250

53-
return new self(array_map(function ($subParts) use (&$index) {
51+
return new self(array_map(function ($subParts) {
52+
static $index = 0;
5453
$part = array_shift($subParts);
5554
$attributes = HeaderUtils::combine($subParts);
5655

0 commit comments

Comments
 (0)