File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 5
5
6
6
class Stopwatch {
7
7
8
- private $ accrued = 0 ;
8
+ private float $ accrued = 0 ;
9
9
10
- private $ timestamp ;
10
+ private float $ timestamp ;
11
11
12
- private $ running = false ;
12
+ private bool $ running = false ;
13
13
14
14
public function __construct () {
15
15
$ this ->start ();
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class Timer {
35
35
*
36
36
* @var Stopwatch[]
37
37
*/
38
- static private $ timers = [];
38
+ static private array $ timers = [];
39
39
40
40
/**
41
41
* Start or resume the timer.
@@ -136,7 +136,7 @@ private static function secondsToTimeString(float $time): string {
136
136
*
137
137
* @throws LogicException If the attempted timer has not started already.
138
138
*/
139
- public static function stop ($ key = 'default ' ): void {
139
+ public static function stop (string $ key = 'default ' ): void {
140
140
if (!isset (self ::$ timers [$ key ])) {
141
141
throw new LogicException ('Stopping timer when the given key timer was not initialized. ' );
142
142
}
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public function testTimerStoppedValueRetention(): void {
21
21
$ this ->assertSame ($ time_1 , $ time_2 );
22
22
}
23
23
24
- public function testTimerContiniuous (): void {
24
+ public function testTimerContinious (): void {
25
25
$ stopwatch = new Stopwatch ();
26
26
$ time_1 = $ stopwatch ->read ();
27
27
$ this ->assertIsFloat ($ time_1 );
Original file line number Diff line number Diff line change 11
11
*/
12
12
class TimerTest2 extends TestCase {
13
13
14
- public function testTimerDefaultRunning () {
14
+ public function testTimerDefaultRunning (): void {
15
15
Timer::start ();
16
16
sleep (20 );
17
17
$ this ->assertSame ('20000 ' , Timer::read ());
18
18
}
19
19
20
- public function testNamedTimerRunning () {
20
+ public function testNamedTimerRunning (): void {
21
21
$ name = __FUNCTION__ ;
22
22
Timer::start ($ name );
23
23
$ time_1 = Timer::read ($ name );
24
24
$ time_2 = Timer::read ($ name );
25
25
$ this ->assertSame ($ time_1 , $ time_2 );
26
26
}
27
27
28
- public function testUnknownTimerThrowsException () {
28
+ public function testUnknownTimerThrowsException (): void {
29
29
Timer::start (__FUNCTION__ );
30
30
Timer::reset (__FUNCTION__ );
31
31
$ this ->expectException (\LogicException::class);
You can’t perform that action at this time.
0 commit comments