Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c3cf577

Browse filesBrowse files
author
Alex Niedre
committed
bug #54854 [Stopwatch] undefined key error when trying to fetch a missing section
1 parent 14bff67 commit c3cf577
Copy full SHA for c3cf577

File tree

Expand file treeCollapse file tree

2 files changed

+6
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-1
lines changed

‎src/Symfony/Component/Stopwatch/Stopwatch.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Stopwatch/Stopwatch.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getEvent(string $name): StopwatchEvent
140140
*/
141141
public function getSectionEvents(string $id): array
142142
{
143-
return $this->sections[$id]->getEvents() ?? [];
143+
return isset($this->sections[$id]) ? $this->sections[$id]->getEvents() : [];
144144
}
145145

146146
/**

‎src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,9 @@ public function testReset()
187187

188188
$this->assertEquals(new Stopwatch(), $stopwatch);
189189
}
190+
191+
public function testShouldReturnEmptyArrayWhenSectionMissing()
192+
{
193+
$this->assertSame([], (new Stopwatch())->getSectionEvents('missing'));
194+
}
190195
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.