Skip to content

Commit cff7b43

Browse files
mad-brillerondrejmirtes
authored andcommitted
Fix time not being considered an impure function.
1 parent f3dc81e commit cff7b43

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

bin/functionMetadata_original.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
'str_decrement' => ['hasSideEffects' => false],
118118
'str_increment' => ['hasSideEffects' => false],
119119
'symlink' => ['hasSideEffects' => true],
120+
'time' => ['hasSideEffects' => true],
120121
'tempnam' => ['hasSideEffects' => true],
121122
'tmpfile' => ['hasSideEffects' => true],
122123
'touch' => ['hasSideEffects' => true],

resources/functionMetadata.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,7 @@
17371737
'tan' => ['hasSideEffects' => false],
17381738
'tanh' => ['hasSideEffects' => false],
17391739
'tempnam' => ['hasSideEffects' => true],
1740+
'time' => ['hasSideEffects' => true],
17401741
'timezone_abbreviations_list' => ['hasSideEffects' => false],
17411742
'timezone_identifiers_list' => ['hasSideEffects' => true],
17421743
'timezone_location_get' => ['hasSideEffects' => true],

tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,9 @@ public function testBug3387(): void
269269
$this->analyse([__DIR__ . '/data/bug-3387.php'], []);
270270
}
271271

272+
public function testBug13874(): void
273+
{
274+
$this->analyse([__DIR__ . '/data/bug-13874.php'], []);
275+
}
276+
272277
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php declare(strict_types = 1);
2+
3+
class Repro
4+
{
5+
public static function func(): void
6+
{
7+
if (time() > 1764702390) { return; }
8+
sleep(3);
9+
if (time() > 1764702390) { return; }
10+
}
11+
}

0 commit comments

Comments
 (0)