Skip to content

Commit de8a2c2

Browse files
georgringernicolas-grekas
authored andcommitted
[RateLimiter] Add typecase to SlidingWindow::getExpirationTime
1 parent 4840563 commit de8a2c2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/RateLimiter/Policy/SlidingWindow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getId(): string
7676
*/
7777
public function getExpirationTime(): int
7878
{
79-
return $this->windowEndAt + $this->intervalInSeconds - microtime(true);
79+
return (int) ($this->windowEndAt + $this->intervalInSeconds - microtime(true));
8080
}
8181

8282
public function isExpired(): bool

src/Symfony/Component/RateLimiter/Tests/Policy/SlidingWindowTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function testGetExpirationTime()
3434

3535
$new = SlidingWindow::createFromPreviousWindow($cachedWindow, 15);
3636
$this->assertSame(2 * 15, $new->getExpirationTime());
37+
38+
usleep(10.1);
39+
$this->assertIsInt($new->getExpirationTime());
3740
}
3841

3942
public function testInvalidInterval()

0 commit comments

Comments
 (0)