Skip to content

Commit cd7fdef

Browse files
bug symfony#45925 [RateLimiter] Add typecase to SlidingWindow::getExpirationTime (georgringer)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [RateLimiter] Add typecase to SlidingWindow::getExpirationTime | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix symfony#45924 | License | MIT Commits ------- de8a2c2 [RateLimiter] Add typecase to SlidingWindow::getExpirationTime
2 parents 4840563 + de8a2c2 commit cd7fdef

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)