Skip to content

Commit 0804a38

Browse files
staabmclxmstaab
andcommitted
don't overwrite reflection cache, when analyzing only a single file in phpstorm (#454)
Co-authored-by: Markus Staab <[email protected]>
1 parent 0f46ee8 commit 0804a38

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/QueryReflection/ReflectionCache.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ public function persist(): void
174174
return;
175175
}
176176

177+
if ($this->isPHPStormSingleFileRun()) {
178+
// don't overwrite reflection cache, when analyzing only a single file
179+
return;
180+
}
181+
177182
try {
178183
flock(self::$lockHandle, LOCK_EX);
179184

@@ -330,4 +335,13 @@ public function putResultType(string $queryString, int $fetchType, ?Type $result
330335
$this->cacheIsDirty = true;
331336
}
332337
}
338+
339+
private function isPHPStormSingleFileRun(): bool
340+
{
341+
if (!\array_key_exists('__CFBundleIdentifier', $_SERVER)) {
342+
return false;
343+
}
344+
345+
return 'com.jetbrains.PhpStorm' === $_SERVER['__CFBundleIdentifier'];
346+
}
333347
}

tests/rules/config/.phpunit-phpstan-dba-mysqli.cache

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)