Skip to content

Commit c689022

Browse files
minor #49763 Replace "use-by-ref" by static vars when possible in closures (nicolas-grekas)
This PR was merged into the 6.3 branch. Discussion ---------- Replace "use-by-ref" by static vars when possible in closures | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Might be easier to grasp. Commits ------- 65422ecf4b Replace "use-by-ref" by static vars when possible in closures
2 parents 3665b19 + 9d12f22 commit c689022

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)