Skip to content

Commit

Permalink
cache the current time
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Dec 14, 2023
1 parent 4ae4249 commit 93e36e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/TodoByRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ final class TodoByRule implements Rule
{
private const PATTERN = '/^TODO:?\s*([0-9]{4}-[0-9]{2}-[0-9]{2}):?(.*)$/';

private int $now;

public function __construct()
{
$this->now = time();
}

public function getNodeType(): string
{
return Node::class;
Expand Down Expand Up @@ -47,7 +54,7 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop

$date = $matches[1];
$todoText = trim($matches[2]);
if (strtotime($date) > time()) {
if (strtotime($date) > $this->now) {
continue;
}

Expand Down

0 comments on commit 93e36e6

Please sign in to comment.