Skip to content

Commit 4c1271b

Browse files
committed
GitHub Actions
1 parent c538f6e commit 4c1271b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Psr6/CacheItem.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CacheItem implements CacheItemInterface
2525
protected bool $hit;
2626

2727
/**
28-
* @var DateTime
28+
* @var DateTimeInterface
2929
*/
3030
protected DateTimeInterface $expiration;
3131

@@ -85,7 +85,8 @@ public function isHit(): bool
8585
public function expiresAt(?DateTimeInterface $expiration): static
8686
{
8787
if (empty($expiration)) {
88-
$this->expiration = new DateTime('now +1 year');
88+
// We need to set a especific date far from now
89+
$this->expiration = new DateTime('now +99 year');
8990
return $this;
9091
}
9192

@@ -98,21 +99,22 @@ public function expiresAt(?DateTimeInterface $expiration): static
9899
#[\Override]
99100
public function expiresAfter(int|\DateInterval|null $time): static
100101
{
101-
$this->expiration = new DateTime('now +1 year');
102102
if (is_numeric($time)) {
103-
$this->expiration = new DateTime('now +' . $time . ' seconds');
103+
$this->expiresAt(new DateTime('now +' . $time . ' seconds'));
104104
} else if ($time instanceof DateInterval) {
105105
$expiration = new DateTime();
106106
$expiration->add($time);
107-
$this->expiration = $expiration;
107+
$this->expiresAt($expiration);
108+
} else {
109+
$this->expiresAt(null);
108110
}
109111
return $this;
110112
}
111113

112114
/**
113-
* @return DateTime
115+
* @return ?DateTime
114116
*/
115-
public function getExpiresAt(): DateTime
117+
public function getExpiresAt(): ?DateTime
116118
{
117119
return $this->expiration;
118120
}

0 commit comments

Comments
 (0)