Skip to content

Commit 4318276

Browse files
authored
Merge branch refs/heads/1.11.x into 1.12.x
2 parents ee51854 + 582a0f8 commit 4318276

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

Diff for: conf/config.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ services:
470470
class: PHPStan\PhpDoc\DefaultStubFilesProvider
471471
arguments:
472472
stubFiles: %stubFiles%
473-
currentWorkingDirectory: %currentWorkingDirectory%
473+
composerAutoloaderProjectPaths: %composerAutoloaderProjectPaths%
474474
autowired:
475475
- PHPStan\PhpDoc\StubFilesProvider
476476

Diff for: src/PhpDoc/DefaultStubFilesProvider.php

+15-11
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ final class DefaultStubFilesProvider implements StubFilesProvider
2020

2121
/**
2222
* @param string[] $stubFiles
23+
* @param string[] $composerAutoloaderProjectPaths
2324
*/
2425
public function __construct(
2526
private Container $container,
2627
private array $stubFiles,
27-
private string $currentWorkingDirectory,
28+
private array $composerAutoloaderProjectPaths,
2829
)
2930
{
3031
}
@@ -52,19 +53,22 @@ public function getProjectStubFiles(): array
5253
return $this->cachedProjectFiles;
5354
}
5455

55-
$composerConfig = ComposerHelper::getComposerConfig($this->currentWorkingDirectory);
56+
$filteredStubFiles = $this->getStubFiles();
57+
foreach ($this->composerAutoloaderProjectPaths as $composerAutoloaderProjectPath) {
58+
$composerConfig = ComposerHelper::getComposerConfig($composerAutoloaderProjectPath);
59+
if ($composerConfig === null) {
60+
continue;
61+
}
5662

57-
if ($composerConfig === null) {
58-
return $this->getStubFiles();
63+
$vendorDir = ComposerHelper::getVendorDirFromComposerConfig($composerAutoloaderProjectPath, $composerConfig);
64+
$vendorDir = strtr($vendorDir, '\\', '/');
65+
$filteredStubFiles = array_filter(
66+
$filteredStubFiles,
67+
static fn (string $file): bool => !str_contains(strtr($file, '\\', '/'), $vendorDir)
68+
);
5969
}
6070

61-
$vendorDir = ComposerHelper::getVendorDirFromComposerConfig($this->currentWorkingDirectory, $composerConfig);
62-
$vendorDir = strtr($vendorDir, '\\', '/');
63-
64-
return $this->cachedProjectFiles = array_values(array_filter(
65-
$this->getStubFiles(),
66-
static fn (string $file): bool => !str_contains(strtr($file, '\\', '/'), $vendorDir)
67-
));
71+
return $this->cachedProjectFiles = array_values($filteredStubFiles);
6872
}
6973

7074
}

0 commit comments

Comments
 (0)