Skip to content

Commit 6ee3dbb

Browse files
committed
fix
1 parent 7c479f5 commit 6ee3dbb

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/Internal/ComposerHelper.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ final class ComposerHelper
2323

2424
private static ?string $betterReflectionVersion = null;
2525

26+
private static ?string $phpstomStubsVersion = null;
27+
2628
private static ?string $phpDocParserVersion = null;
2729

2830
/** @var array<string, mixed[]> */
@@ -124,6 +126,21 @@ public static function getBetterReflectionVersion(): string
124126
return self::$betterReflectionVersion = self::processPackageVersion($rootPackage);
125127
}
126128

129+
public static function getPhpStormStubsVersion(): string
130+
{
131+
if (self::$phpstomStubsVersion !== null) {
132+
return self::$phpstomStubsVersion;
133+
}
134+
135+
$installed = self::getInstalled();
136+
$rootPackage = $installed['versions']['jetbrains/phpstorm-stubs'] ?? null;
137+
if ($rootPackage === null) {
138+
return self::$phpstomStubsVersion = self::UNKNOWN_VERSION;
139+
}
140+
141+
return self::$phpstomStubsVersion = self::processPackageVersion($rootPackage);
142+
}
143+
127144
public static function getPhpDocParserVersion(): string
128145
{
129146
if (self::$phpDocParserVersion !== null) {

src/Reflection/BetterReflection/SourceLocator/PhpVersionBlacklistSourceLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class PhpVersionBlacklistSourceLocator implements SourceLocator
1515
{
1616

1717
public function __construct(
18-
private SourceLocator $sourceLocator,
18+
private SourceLocator $sourceLocator,
1919
private PhpStormStubsSourceStubber|CachedPhpStormStubsSourceStubber $phpStormStubsSourceStubber,
2020
)
2121
{

src/Reflection/BetterReflection/SourceStubber/CachedPhpStormStubsSourceStubber.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ public function __construct(
3232
*/
3333
private function getCacheKeys(): array
3434
{
35-
$stubsVersion = 'dev-master#5fd9e4ef2b4c2a00848ea62d78bf3aa81f43e038';
36-
$cacheKey = 'phpstorm-stubs';
37-
$variableCacheKey = sprintf('v1-%s-%s-%s', ComposerHelper::getBetterReflectionVersion(), $this->phpVersion->getVersionString(), $stubsVersion);
35+
$stubsVersion = ComposerHelper::getPhpStormStubsVersion();
36+
$cacheKey = sprintf('phpstorm-stubs-%s', $stubsVersion);
37+
$variableCacheKey = sprintf('v1-%s-%s', ComposerHelper::getBetterReflectionVersion(), $this->phpVersion->getVersionString());
3838

3939
return [$cacheKey, $variableCacheKey];
4040
}
4141

42+
#[\Override]
4243
public function generateClassStub(string $className): ?StubData
4344
{
4445
$this->cached['classes'] ??= [];
@@ -49,6 +50,7 @@ public function generateClassStub(string $className): ?StubData
4950
return $this->cached['classes'][$className];
5051
}
5152

53+
#[\Override]
5254
public function generateFunctionStub(string $functionName): ?StubData
5355
{
5456
$this->cached['functions'] ??= [];
@@ -59,6 +61,7 @@ public function generateFunctionStub(string $functionName): ?StubData
5961
return $this->cached['functions'][$functionName];
6062
}
6163

64+
#[\Override]
6265
public function generateConstantStub(string $constantName): ?StubData
6366
{
6467
$this->cached['constants'] ??= [];

0 commit comments

Comments
 (0)