From de7e03b03d8e5a471142da6e02dfb6ccdfd56e34 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 6 Mar 2024 14:10:50 +0100 Subject: [PATCH] Raise PHPStan level to 8 --- phpstan.neon.dist | 2 +- src/DependencyFactory.php | 8 ++++---- src/Tools/Console/Command/DoctrineCommand.php | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9da956f32..957f21f1c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,5 @@ parameters: - level: 7 + level: 8 paths: - src - tests diff --git a/src/DependencyFactory.php b/src/DependencyFactory.php index f415b5729..e30ebb891 100644 --- a/src/DependencyFactory.php +++ b/src/DependencyFactory.php @@ -145,7 +145,7 @@ public function getConfiguration(): Configuration { if ($this->configuration === null) { $this->configuration = $this->configurationLoader->getConfiguration(); - $this->freeze(); + $this->frozen = true; } return $this->configuration; @@ -157,7 +157,7 @@ public function getConnection(): Connection $this->connection = $this->hasEntityManager() ? $this->getEntityManager()->getConnection() : $this->connectionLoader->getConnection($this->getConfiguration()->getConnectionName()); - $this->freeze(); + $this->frozen = true; } return $this->connection; @@ -171,7 +171,7 @@ public function getEntityManager(): EntityManagerInterface } $this->em = $this->emLoader->getEntityManager($this->getConfiguration()->getEntityManagerName()); - $this->freeze(); + $this->frozen = true; } return $this->em; @@ -222,7 +222,7 @@ public function getSchemaDumper(): SchemaDumper private function getEmptySchemaProvider(): SchemaProvider { - return $this->getDependency(EmptySchemaProvider::class, fn (): SchemaProvider => new EmptySchemaProvider($this->connection->createSchemaManager())); + return $this->getDependency(EmptySchemaProvider::class, fn (): SchemaProvider => new EmptySchemaProvider($this->getConnection()->createSchemaManager())); } public function hasSchemaProvider(): bool diff --git a/src/Tools/Console/Command/DoctrineCommand.php b/src/Tools/Console/Command/DoctrineCommand.php index d7b54a5b4..01f90b140 100644 --- a/src/Tools/Console/Command/DoctrineCommand.php +++ b/src/Tools/Console/Command/DoctrineCommand.php @@ -88,16 +88,17 @@ protected function initialize(InputInterface $input, OutputInterface $output): v $configurationLoader = new ConfigurationFileWithFallback($configurationParameter); $this->dependencyFactory->setConfigurationLoader($configurationLoader); } + $dependencyFactory = $this->dependencyFactory; $this->setNamedEmOrConnection($input); - if ($this->dependencyFactory->isFrozen()) { + if ($dependencyFactory->isFrozen()) { return; } $logger = new ConsoleLogger($output); - $this->dependencyFactory->setService(LoggerInterface::class, $logger); - $this->dependencyFactory->freeze(); + $dependencyFactory->setService(LoggerInterface::class, $logger); + $dependencyFactory->freeze(); } protected function getDependencyFactory(): DependencyFactory @@ -116,6 +117,7 @@ protected function canExecute(string $question, InputInterface $input): bool private function setNamedEmOrConnection(InputInterface $input): void { + assert($this->dependencyFactory !== null); $emName = $input->getOption('em'); $connName = $input->getOption('conn'); if ($emName !== null && $connName !== null) {