Skip to content

Commit 2fcabc4

Browse files
committed
cs-fix in Toolbar. replace time() in Cookie class.
1 parent faf7403 commit 2fcabc4

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

system/Cookie/Cookie.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use ArrayAccess;
1515
use CodeIgniter\Cookie\Exceptions\CookieException;
16+
use CodeIgniter\I18n\Time;
1617
use Config\Cookie as CookieConfig;
1718
use DateTimeInterface;
1819
use InvalidArgumentException;
@@ -206,7 +207,7 @@ final public function __construct(string $name, string $value = '', array $optio
206207

207208
// If both `Expires` and `Max-Age` are set, `Max-Age` has precedence.
208209
if (isset($options['max-age']) && is_numeric($options['max-age'])) {
209-
$options['expires'] = time() + (int) $options['max-age'];
210+
$options['expires'] = Time::now()->getTimestamp() + (int) $options['max-age'];
210211
unset($options['max-age']);
211212
}
212213

@@ -314,15 +315,15 @@ public function getExpiresString(): string
314315
*/
315316
public function isExpired(): bool
316317
{
317-
return $this->expires === 0 || $this->expires < time();
318+
return $this->expires === 0 || $this->expires < Time::now()->getTimestamp();
318319
}
319320

320321
/**
321322
* {@inheritDoc}
322323
*/
323324
public function getMaxAge(): int
324325
{
325-
$maxAge = $this->expires - time();
326+
$maxAge = $this->expires - Time::now()->getTimestamp();
326327

327328
return $maxAge >= 0 ? $maxAge : 0;
328329
}
@@ -466,7 +467,7 @@ public function withNeverExpiring()
466467
{
467468
$cookie = clone $this;
468469

469-
$cookie->expires = time() + 5 * YEAR;
470+
$cookie->expires = Time::now()->getTimestamp() + 5 * YEAR;
470471

471472
return $cookie;
472473
}

system/Debug/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace CodeIgniter\Debug;
1313

1414
use CodeIgniter\CodeIgniter;
15-
use CodeIgniter\I18n\Time;
1615
use CodeIgniter\Debug\Toolbar\Collectors\BaseCollector;
1716
use CodeIgniter\Debug\Toolbar\Collectors\Config;
1817
use CodeIgniter\Debug\Toolbar\Collectors\History;
@@ -23,6 +22,7 @@
2322
use CodeIgniter\HTTP\RequestInterface;
2423
use CodeIgniter\HTTP\Response;
2524
use CodeIgniter\HTTP\ResponseInterface;
25+
use CodeIgniter\I18n\Time;
2626
use Config\Services;
2727
use Config\Toolbar as ToolbarConfig;
2828
use Kint\Kint;

0 commit comments

Comments
 (0)