Skip to content

Commit

Permalink
Merge branch '5.4' into 6.0
Browse files Browse the repository at this point in the history
* 5.4:
  Remove more dynamic properties
  [Serializer] fix support for unset properties on PHP < 7.4
  • Loading branch information
nicolas-grekas committed Nov 17, 2021
2 parents 10d1b65 + 9392f30 commit 0f56750
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Policy/TokenBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
final class TokenBucket implements LimiterStateInterface
{
private string $stringRate;
private string $id;
private Rate $rate;
private int $tokens;
Expand All @@ -34,6 +35,8 @@ final class TokenBucket implements LimiterStateInterface
*/
public function __construct(string $id, int $initialTokens, Rate $rate, float $timer = null)
{
unset($this->stringRate);

if ($initialTokens < 1) {
throw new \InvalidArgumentException(sprintf('Cannot set the limit of "%s" to 0, as that would never accept any hit.', TokenBucketLimiter::class));
}
Expand Down Expand Up @@ -91,10 +94,6 @@ public function __sleep(): array
*/
public function __wakeup(): void
{
if (!\is_string($this->stringRate)) {
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

$this->rate = Rate::fromString($this->stringRate);
unset($this->stringRate);
}
Expand Down

0 comments on commit 0f56750

Please sign in to comment.