mirror of
https://github.com/rectorphp/rector.git
synced 2024-09-03 22:22:14 +00:00
add more default Kernel class names to DefaultAnalyzedSymfonyApplicationContainer [closes #468]
This commit is contained in:
parent
75ea3963d3
commit
bf953ab842
@ -58,10 +58,26 @@ final class DefaultAnalyzedSymfonyApplicationContainer implements AnalyzedApplic
|
||||
private function getContainer(): Container
|
||||
{
|
||||
$kernelClass = $this->parameterProvider->provideParameter(Option::KERNEL_CLASS_PARAMETER);
|
||||
if ($kernelClass === null) {
|
||||
$kernelClass = $this->getDefaultKernelClass();
|
||||
}
|
||||
|
||||
$this->symfonyKernelParameterGuard->ensureKernelClassIsValid($kernelClass);
|
||||
|
||||
/** @var string $kernelClass */
|
||||
return $this->containerFactory->createFromKernelClass($kernelClass);
|
||||
}
|
||||
|
||||
private function getDefaultKernelClass(): ?string
|
||||
{
|
||||
$possibleKernelClasses = ['App\Kernel', 'Kernel', 'AppKernel'];
|
||||
|
||||
foreach ($possibleKernelClasses as $possibleKernelClass) {
|
||||
if (class_exists($possibleKernelClass)) {
|
||||
return $possibleKernelClass;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,3 @@
|
||||
parameters:
|
||||
# default Symfony Kernel class
|
||||
kernel_class: 'App\Kernel'
|
||||
|
||||
imports:
|
||||
- { resource: '../../packages/**/src/config/*services.yml' }
|
||||
- { resource: 'services.yml' }
|
||||
|
@ -13,10 +13,7 @@ final class InvalidConfigurationConstructorInjectionRectorTest extends AbstractR
|
||||
public function test(): void
|
||||
{
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'Kernel class "App\Kernel" provided in "parameters > kernel_class" is not autoloadable.'
|
||||
. ' Make sure composer.json of your application is valid and rector is loading "vendor/autoload.php" of your application.'
|
||||
);
|
||||
$this->expectExceptionMessage('Make sure "kernel_class" parameters is set in rector.yml in "parameters:" section');
|
||||
|
||||
$this->doTestFileMatchesExpectedContent(__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user