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 55
66class Stopwatch {
77
8- private $ accrued = 0 ;
8+ private float $ accrued = 0 ;
99
10- private $ timestamp ;
10+ private float $ timestamp ;
1111
12- private $ running = false ;
12+ private bool $ running = false ;
1313
1414 public function __construct () {
1515 $ this ->start ();
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class Timer {
3535 *
3636 * @var Stopwatch[]
3737 */
38- static private $ timers = [];
38+ static private array $ timers = [];
3939
4040 /**
4141 * Start or resume the timer.
@@ -136,7 +136,7 @@ private static function secondsToTimeString(float $time): string {
136136 *
137137 * @throws LogicException If the attempted timer has not started already.
138138 */
139- public static function stop ($ key = 'default ' ): void {
139+ public static function stop (string $ key = 'default ' ): void {
140140 if (!isset (self ::$ timers [$ key ])) {
141141 throw new LogicException ('Stopping timer when the given key timer was not initialized. ' );
142142 }
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public function testTimerStoppedValueRetention(): void {
2121 $ this ->assertSame ($ time_1 , $ time_2 );
2222 }
2323
24- public function testTimerContiniuous (): void {
24+ public function testTimerContinious (): void {
2525 $ stopwatch = new Stopwatch ();
2626 $ time_1 = $ stopwatch ->read ();
2727 $ this ->assertIsFloat ($ time_1 );
Original file line number Diff line number Diff line change 1111 */
1212class TimerTest2 extends TestCase {
1313
14- public function testTimerDefaultRunning () {
14+ public function testTimerDefaultRunning (): void {
1515 Timer::start ();
1616 sleep (20 );
1717 $ this ->assertSame ('20000 ' , Timer::read ());
1818 }
1919
20- public function testNamedTimerRunning () {
20+ public function testNamedTimerRunning (): void {
2121 $ name = __FUNCTION__ ;
2222 Timer::start ($ name );
2323 $ time_1 = Timer::read ($ name );
2424 $ time_2 = Timer::read ($ name );
2525 $ this ->assertSame ($ time_1 , $ time_2 );
2626 }
2727
28- public function testUnknownTimerThrowsException () {
28+ public function testUnknownTimerThrowsException (): void {
2929 Timer::start (__FUNCTION__ );
3030 Timer::reset (__FUNCTION__ );
3131 $ this ->expectException (\LogicException::class);
You can’t perform that action at this time.
0 commit comments