Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4f9eedf

Browse files
committed
[RateLimiter] Fix infinite values with NoLimiter
1 parent3811030 commit4f9eedf

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

‎src/Symfony/Component/RateLimiter/Policy/NoLimiter.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ final class NoLimiter implements LimiterInterface
2929
{
3030
publicfunctionreserve(int$tokens =1, ?float$maxTime =null):Reservation
3131
{
32-
returnnewReservation(time(),newRateLimit(\INF,new \DateTimeImmutable(),true, \INF));
32+
returnnewReservation(time(),newRateLimit(\PHP_INT_MAX,new \DateTimeImmutable(),true, \PHP_INT_MAX));
3333
}
3434

3535
publicfunctionconsume(int$tokens =1):RateLimit
3636
{
37-
returnnewRateLimit(\INF,new \DateTimeImmutable(),true, \INF);
37+
returnnewRateLimit(\PHP_INT_MAX,new \DateTimeImmutable(),true, \PHP_INT_MAX);
3838
}
3939

4040
publicfunctionreset():void
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\RateLimiter\Tests\Policy;
13+
14+
usePHPUnit\Framework\TestCase;
15+
useSymfony\Component\RateLimiter\Policy\NoLimiter;
16+
useSymfony\Component\RateLimiter\RateLimit;
17+
useSymfony\Component\RateLimiter\Reservation;
18+
19+
class NoLimiterTestextends TestCase
20+
{
21+
publicfunctiontestConsume()
22+
{
23+
$limiter =newNoLimiter();
24+
$this->assertInstanceOf(RateLimit::class,$limiter->consume());
25+
}
26+
27+
publicfunctiontestReserve()
28+
{
29+
$limiter =newNoLimiter();
30+
$this->assertInstanceOf(Reservation::class,$limiter->reserve());
31+
}
32+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp