Skip to content

Commit

Permalink
Introduce bootstrapFiles config option; deprecate bootstrap config op…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
ondrejmirtes committed Jun 7, 2020
1 parent 6f9f9aa commit aad1bf8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ includes:
- ../conf/bleedingEdge.neon
- ../phpstan-baseline.neon
parameters:
bootstrap: %rootDir%/tests/phpstan-bootstrap.php
bootstrapFiles:
- %rootDir%/tests/phpstan-bootstrap.php
excludes_analyse:
- %rootDir%/src/Reflection/SignatureMap/functionMap.php
- %rootDir%/src/Reflection/SignatureMap/functionMetadata.php
Expand Down
2 changes: 2 additions & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
bootstrap: null
bootstrapFiles: []
excludes_analyse: []
autoload_directories: []
autoload_files: []
Expand Down Expand Up @@ -132,6 +133,7 @@ extensions:

parametersSchema:
bootstrap: schema(string(), nullable())
bootstrapFiles: listOf(string())
excludes_analyse: listOf(string())
autoload_directories: listOf(string())
autoload_files: listOf(string())
Expand Down
10 changes: 10 additions & 0 deletions src/Command/CommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,19 @@ public static function begin(

$bootstrapFile = $container->getParameter('bootstrap');
if ($bootstrapFile !== null) {
$errorOutput->writeLineFormatted('⚠️ You\'re using a deprecated config option <fg=cyan>bootstrap</>. ⚠️️');
$errorOutput->writeLineFormatted('');
$errorOutput->writeLineFormatted('This option has been replaced with <fg=cyan>bootstrapFiles</> which accepts a list of files');
$errorOutput->writeLineFormatted('to execute before the analysis.');
$errorOutput->writeLineFormatted('');

self::executeBootstrapFile($bootstrapFile, $container, $errorOutput, $debugEnabled);
}

foreach ($container->getParameter('bootstrapFiles') as $bootstrapFileFromArray) {
self::executeBootstrapFile($bootstrapFileFromArray, $container, $errorOutput, $debugEnabled);
}

/** @var FileFinder $fileFinder */
$fileFinder = $container->getByType(FileFinder::class);

Expand Down
3 changes: 2 additions & 1 deletion src/DependencyInjection/NeonAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class NeonAdapter implements Adapter
{

public const CACHE_KEY = 'v7';
public const CACHE_KEY = 'v8';

private const PREVENT_MERGING_SUFFIX = '!';

Expand Down Expand Up @@ -95,6 +95,7 @@ public function process(array $arr, string $fileKey, string $file): array
'[parameters][ignoreErrors][][paths][]',
'[parameters][ignoreErrors][][path]',
'[parameters][bootstrap]',
'[parameters][bootstrapFiles][]',
'[parameters][tmpDir]',
'[parameters][memoryLimitFile]',
'[parameters][benchmarkFile]',
Expand Down
3 changes: 3 additions & 0 deletions tests/PHPStan/Command/CommandHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public function dataResolveRelativePaths(): array
__DIR__ . '/relative-paths/root.neon',
[
'bootstrap' => __DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
'bootstrapFiles' => [
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
],
'autoload_files' => [
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'there.php',
Expand Down
2 changes: 2 additions & 0 deletions tests/PHPStan/Command/relative-paths/root.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
parameters:
bootstrap: here.php
bootstrapFiles:
- here.php
autoload_files:
- here.php
- test/there.php
Expand Down

0 comments on commit aad1bf8

Please sign in to comment.