diff --git a/.phpstan-dba-mysqli.cache b/.phpstan-dba-mysqli.cache index f2b0f4ddf..ea901271f 100644 --- a/.phpstan-dba-mysqli.cache +++ b/.phpstan-dba-mysqli.cache @@ -249,4 +249,4 @@ 'debugMode' => false, 'stringifyTypes' => false, ), -); \ No newline at end of file +); diff --git a/.phpstan-dba-pdo-mysql.cache b/.phpstan-dba-pdo-mysql.cache index 9688c6149..9f47fa03c 100644 --- a/.phpstan-dba-pdo-mysql.cache +++ b/.phpstan-dba-pdo-mysql.cache @@ -146,4 +146,4 @@ 'debugMode' => false, 'stringifyTypes' => false, ), -); \ No newline at end of file +); diff --git a/src/QueryReflection/ReflectionCache.php b/src/QueryReflection/ReflectionCache.php index 44b21d87c..f6f0ae715 100644 --- a/src/QueryReflection/ReflectionCache.php +++ b/src/QueryReflection/ReflectionCache.php @@ -174,6 +174,11 @@ public function persist(): void return; } + if ($this->isPHPStormSingleFileRun()) { + // don't overwrite reflection cache, when analyzing only a single file + return; + } + try { flock(self::$lockHandle, LOCK_EX); @@ -330,4 +335,13 @@ public function putResultType(string $queryString, int $fetchType, ?Type $result $this->cacheIsDirty = true; } } + + private function isPHPStormSingleFileRun(): bool + { + if (!\array_key_exists('__CFBundleIdentifier', $_SERVER)) { + return false; + } + + return 'com.jetbrains.PhpStorm' === $_SERVER['__CFBundleIdentifier']; + } } diff --git a/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache b/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache index 904e441c0..75ca617cb 100644 --- a/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache @@ -3541,4 +3541,4 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'debugMode' => false, 'stringifyTypes' => false, ), -); \ No newline at end of file +);