From 7a21246cae9dd7968bf7bef92223b53f5d681b72 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 12 Sep 2021 23:22:17 +0200 Subject: [PATCH] [BCB] Removed autoload_files --- conf/config.neon | 3 -- src/Command/CommandHelper.php | 29 ------------------- .../BetterReflectionSourceLocatorFactory.php | 7 +---- 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/conf/config.neon b/conf/config.neon index 741dafc2b8..0026004d23 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -9,7 +9,6 @@ parameters: excludes_analyse: [] excludePaths: null autoload_directories: [] - autoload_files: [] level: null paths: [] exceptions: @@ -195,7 +194,6 @@ parametersSchema: ]) ), nullable()) autoload_directories: listOf(string()) - autoload_files: listOf(string()) level: schema(anyOf(int(), string()), nullable()) paths: listOf(string()) exceptions: structure([ @@ -1687,7 +1685,6 @@ services: parser: @phpParserDecorator php8Parser: @php8PhpParser autoloadDirectories: %autoload_directories% - autoloadFiles: %autoload_files% scanFiles: %scanFiles% scanDirectories: %scanDirectories% analysedPaths: %analysedPaths% diff --git a/src/Command/CommandHelper.php b/src/Command/CommandHelper.php index e743d13cf8..20569322de 100644 --- a/src/Command/CommandHelper.php +++ b/src/Command/CommandHelper.php @@ -308,25 +308,6 @@ public static function begin( throw new \PHPStan\Command\InceptionNotSuccessfulException(); } - $autoloadFiles = $container->getParameter('autoload_files'); - if ($manageMemoryLimitFile && count($autoloadFiles) > 0) { - $errorOutput->writeLineFormatted('⚠️ You\'re using a deprecated config option autoload_files. ⚠️️'); - $errorOutput->writeLineFormatted(''); - $errorOutput->writeLineFormatted('You might not need it anymore - try removing it from your'); - $errorOutput->writeLineFormatted('configuration file and run PHPStan again.'); - $errorOutput->writeLineFormatted(''); - $errorOutput->writeLineFormatted('If the analysis fails, there are now two distinct options'); - $errorOutput->writeLineFormatted('to choose from to replace autoload_files:'); - $errorOutput->writeLineFormatted('1) scanFiles - PHPStan will scan those for classes and functions'); - $errorOutput->writeLineFormatted(' definitions. PHPStan will not execute those files.'); - $errorOutput->writeLineFormatted('2) bootstrapFiles - PHPStan will execute these files to prepare'); - $errorOutput->writeLineFormatted(' the PHP runtime environment for the analysis.'); - $errorOutput->writeLineFormatted(''); - $errorOutput->writeLineFormatted('Read more about this in PHPStan\'s documentation:'); - $errorOutput->writeLineFormatted('https://phpstan.org/user-guide/discovering-symbols'); - $errorOutput->writeLineFormatted(''); - } - $autoloadDirectories = $container->getParameter('autoload_directories'); if (count($autoloadDirectories) > 0 && $manageMemoryLimitFile) { $errorOutput->writeLineFormatted('⚠️ You\'re using a deprecated config option autoload_directories. ⚠️️'); @@ -341,16 +322,6 @@ public static function begin( $errorOutput->writeLineFormatted(''); } - foreach ($autoloadFiles as $parameterAutoloadFile) { - if (!file_exists($parameterAutoloadFile)) { - $errorOutput->writeLineFormatted(sprintf('Autoload file %s does not exist.', $parameterAutoloadFile)); - throw new \PHPStan\Command\InceptionNotSuccessfulException(); - } - (static function (string $file) use ($container): void { - require_once $file; - })($parameterAutoloadFile); - } - $bootstrapFile = $container->getParameter('bootstrap'); if ($bootstrapFile !== null) { if ($manageMemoryLimitFile) { diff --git a/src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php b/src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php index ad3962e587..63108ab313 100644 --- a/src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php +++ b/src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php @@ -56,9 +56,6 @@ class BetterReflectionSourceLocatorFactory /** @var string[] */ private $autoloadDirectories; - /** @var string[] */ - private $autoloadFiles; - /** @var string[] */ private $scanFiles; @@ -102,7 +99,6 @@ public function __construct( AutoloadSourceLocator $autoloadSourceLocator, Container $container, array $autoloadDirectories, - array $autoloadFiles, array $scanFiles, array $scanDirectories, array $analysedPaths, @@ -122,7 +118,6 @@ public function __construct( $this->autoloadSourceLocator = $autoloadSourceLocator; $this->container = $container; $this->autoloadDirectories = $autoloadDirectories; - $this->autoloadFiles = $autoloadFiles; $this->scanFiles = $scanFiles; $this->scanDirectories = $scanDirectories; $this->analysedPaths = $analysedPaths; @@ -156,7 +151,7 @@ public function create(): SourceLocator $analysedDirectories[] = $analysedPath; } - $analysedFiles = array_unique(array_merge($analysedFiles, $this->autoloadFiles, $this->scanFiles)); + $analysedFiles = array_unique(array_merge($analysedFiles, $this->scanFiles)); foreach ($analysedFiles as $analysedFile) { $locators[] = $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($analysedFile); }