Skip to content

Commit aad1bf8

Browse files
committed
Introduce bootstrapFiles config option; deprecate bootstrap config option
1 parent 6f9f9aa commit aad1bf8

File tree

6 files changed

+21
-2
lines changed

6 files changed

+21
-2
lines changed

build/phpstan.neon

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ includes:
77
- ../conf/bleedingEdge.neon
88
- ../phpstan-baseline.neon
99
parameters:
10-
bootstrap: %rootDir%/tests/phpstan-bootstrap.php
10+
bootstrapFiles:
11+
- %rootDir%/tests/phpstan-bootstrap.php
1112
excludes_analyse:
1213
- %rootDir%/src/Reflection/SignatureMap/functionMap.php
1314
- %rootDir%/src/Reflection/SignatureMap/functionMetadata.php

conf/config.neon

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
parameters:
22
bootstrap: null
3+
bootstrapFiles: []
34
excludes_analyse: []
45
autoload_directories: []
56
autoload_files: []
@@ -132,6 +133,7 @@ extensions:
132133

133134
parametersSchema:
134135
bootstrap: schema(string(), nullable())
136+
bootstrapFiles: listOf(string())
135137
excludes_analyse: listOf(string())
136138
autoload_directories: listOf(string())
137139
autoload_files: listOf(string())

src/Command/CommandHelper.php

+10
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,19 @@ public static function begin(
310310

311311
$bootstrapFile = $container->getParameter('bootstrap');
312312
if ($bootstrapFile !== null) {
313+
$errorOutput->writeLineFormatted('⚠️ You\'re using a deprecated config option <fg=cyan>bootstrap</>. ⚠️️');
314+
$errorOutput->writeLineFormatted('');
315+
$errorOutput->writeLineFormatted('This option has been replaced with <fg=cyan>bootstrapFiles</> which accepts a list of files');
316+
$errorOutput->writeLineFormatted('to execute before the analysis.');
317+
$errorOutput->writeLineFormatted('');
318+
313319
self::executeBootstrapFile($bootstrapFile, $container, $errorOutput, $debugEnabled);
314320
}
315321

322+
foreach ($container->getParameter('bootstrapFiles') as $bootstrapFileFromArray) {
323+
self::executeBootstrapFile($bootstrapFileFromArray, $container, $errorOutput, $debugEnabled);
324+
}
325+
316326
/** @var FileFinder $fileFinder */
317327
$fileFinder = $container->getByType(FileFinder::class);
318328

src/DependencyInjection/NeonAdapter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class NeonAdapter implements Adapter
1515
{
1616

17-
public const CACHE_KEY = 'v7';
17+
public const CACHE_KEY = 'v8';
1818

1919
private const PREVENT_MERGING_SUFFIX = '!';
2020

@@ -95,6 +95,7 @@ public function process(array $arr, string $fileKey, string $file): array
9595
'[parameters][ignoreErrors][][paths][]',
9696
'[parameters][ignoreErrors][][path]',
9797
'[parameters][bootstrap]',
98+
'[parameters][bootstrapFiles][]',
9899
'[parameters][tmpDir]',
99100
'[parameters][memoryLimitFile]',
100101
'[parameters][benchmarkFile]',

tests/PHPStan/Command/CommandHelperTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ public function dataResolveRelativePaths(): array
166166
__DIR__ . '/relative-paths/root.neon',
167167
[
168168
'bootstrap' => __DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
169+
'bootstrapFiles' => [
170+
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
171+
],
169172
'autoload_files' => [
170173
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
171174
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'there.php',

tests/PHPStan/Command/relative-paths/root.neon

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
parameters:
22
bootstrap: here.php
3+
bootstrapFiles:
4+
- here.php
35
autoload_files:
46
- here.php
57
- test/there.php

0 commit comments

Comments
 (0)