Skip to content

Commit

Permalink
unlink() also clears stat cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Apr 3, 2021
1 parent d72e9f6 commit 63d0670
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
$scope = $scope->afterExtractCall();
}

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

Expand Down
8 changes: 8 additions & 0 deletions tests/PHPStan/Analyser/data/clear-stat-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ function (string $a, string $b, bool $c): string {
assertType('true', $c);
}
};

function (): void {
if (file_exists('foo')) {
assertType('true', file_exists('foo'));
unlink('foo');
assertType('bool', file_exists('foo'));
}
};

0 comments on commit 63d0670

Please sign in to comment.