diff --git a/src/Symfony/Component/RateLimiter/Policy/NoLimiter.php b/src/Symfony/Component/RateLimiter/Policy/NoLimiter.php index 03d4e54331..88efa5f5e0 100644 --- a/src/Symfony/Component/RateLimiter/Policy/NoLimiter.php +++ b/src/Symfony/Component/RateLimiter/Policy/NoLimiter.php @@ -29,12 +29,12 @@ final class NoLimiter implements LimiterInterface { public function reserve(int $tokens = 1, ?float $maxTime = null): Reservation { - return new Reservation(time(), new RateLimit(\INF, new \DateTimeImmutable(), true, \INF)); + return new Reservation(time(), new RateLimit(\PHP_INT_MAX, new \DateTimeImmutable(), true, \PHP_INT_MAX)); } public function consume(int $tokens = 1): RateLimit { - return new RateLimit(\INF, new \DateTimeImmutable(), true, \INF); + return new RateLimit(\PHP_INT_MAX, new \DateTimeImmutable(), true, \PHP_INT_MAX); } public function reset(): void diff --git a/src/Symfony/Component/RateLimiter/Tests/Policy/NoLimiterTest.php b/src/Symfony/Component/RateLimiter/Tests/Policy/NoLimiterTest.php new file mode 100644 index 0000000000..ecfc9400e2 --- /dev/null +++ b/src/Symfony/Component/RateLimiter/Tests/Policy/NoLimiterTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\RateLimiter\Tests\Policy; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\RateLimiter\Policy\NoLimiter; +use Symfony\Component\RateLimiter\RateLimit; +use Symfony\Component\RateLimiter\Reservation; + +class NoLimiterTest extends TestCase +{ + public function testConsume() + { + $limiter = new NoLimiter(); + $this->assertInstanceOf(RateLimit::class, $limiter->consume()); + } + + public function testReserve() + { + $limiter = new NoLimiter(); + $this->assertInstanceOf(Reservation::class, $limiter->reserve()); + } +}