8000 Fixed the lap method. Added upgrade notes. Some CS fixes · symfony/symfony@bdf0334 · GitHub
[go: up one dir, main page]

Skip to content

Commit bdf0334

Browse files
committed
Fixed the lap method. Added upgrade notes. Some CS fixes
1 parent 7ed728a commit bdf0334

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

UPGRADE-2.2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
`MongoDate` instead of `MongoTimestamp`, which also makes it possible to use
1111
TTL collections in MongoDB 2.2+ instead of relying on the `gc()` method.
1212

13+
* The Stopwatch functionality was moved from HttpKernel\Debug to its own component
14+
1315
#### Deprecations
1416

1517
* The `Request::splitHttpAcceptHeader()` is deprecated and will be removed in 2.3.

src/Symfony/Component/Stopwatch/Stopwatch.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
*/
1919
class Stopwatch
2020
{
21+
/**
22+
* @var Section[]
23+
*/
2124
private $sections;
25+
26+
/**
27+
* @var array
28+
*/
2229
private $activeSections;
2330

2431
public function __construct()
@@ -54,6 +61,8 @@ public function openSection($id = null)
5461
* @see getSectionEvents
5562
*
5663
* @param string $id The identifier of the section
64+
*
65+
* @throws \LogicException When there's no started section to be stopped
5766
*/
5867
public function stopSection($id)
5968
{
@@ -117,11 +126,32 @@ public function getSectionEvents($id)
117126
}
118127
}
119128

129+
130+
/**
131+
* @internal This class is for internal usage only
132+
*
133+
* @author Fabien Potencier <fabien@symfony.com>
134+
*/
120135
class Section
121136
{
137+
/**
138+
* @var StopwatchEvent[]
139+
*/
122140
private $events = array();
141+
142+
/**
143+
* @var null|float
144+
*/
123145
private $origin;
146+
147+
/**
148+
* @var string
149+
*/
124150
private $id;
151+
152+
/**
153+
* @var Section[]
154+
*/
125155
private $children = array();
126156

127157
/**
@@ -236,7 +266,7 @@ public function stopEvent($name)
236266
*/
237267
public function lap($name)
238268
{
239-
return $this->stop($name)->start();
269+
return $this->stopEvent($name)->start();
240270
}
241271

242272
/**
@@ -249,3 +279,4 @@ public function getEvents()
249279
return $this->events;
250280
}
251281
}
282+

src/Symfony/Component/Stopwatch/StopwatchEvent.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,24 @@
1818
*/
1919
class StopwatchEvent
2020
{
21+
/**
22+
* @var StopwatchPeriod[]
23+
*/
2124
private $periods;
25+
26+
/**
27+
* @var float
28+
*/
2229
private $origin;
30+
31+
/**
32+
* @var string
33+
*/
2334
private $category;
35+
36+
/**
37+
* @var float[]
38+
*/
2439
private $started;
2540

2641
/**
@@ -74,6 +89,8 @@ public function start()
7489
/**
7590
* Stops the last started event period.
7691
*
92+
* @throws \LogicException When start wasn't called before stopping
93+
*
7794
* @return StopwatchEvent The event
7895
*/
7996
public function stop()
@@ -182,7 +199,7 @@ protected function getNow()
182199
/**
183200
* Formats a time.
184201
*
185-
* @param numerical $time A raw time
202+
* @param integer|float $time A raw time
186203
*
187204
* @return float The formatted time
188205
*

0 commit comments

Comments
 (0)
0