Skip to content

Commit 63d0670

Browse files
committed
unlink() also clears stat cache
1 parent d72e9f6 commit 63d0670

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19131913
$scope = $scope->afterExtractCall();
19141914
}
19151915

1916-
if (isset($functionReflection) && $functionReflection->getName() === 'clearstatcache') {
1916+
if (isset($functionReflection) && ($functionReflection->getName() === 'clearstatcache' || $functionReflection->getName() === 'unlink')) {
19171917
$scope = $scope->afterClearstatcacheCall();
19181918
}
19191919

tests/PHPStan/Analyser/data/clear-stat-cache.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@ function (string $a, string $b, bool $c): string {
5252
assertType('true', $c);
5353
}
5454
};
55+
56+
function (): void {
57+
if (file_exists('foo')) {
58+
assertType('true', file_exists('foo'));
59+
unlink('foo');
60+
assertType('bool', file_exists('foo'));
61+
}
62+
};

0 commit comments

Comments
 (0)