Skip to content

Commit

Permalink
Raise PHPStan level to 8 (#1409)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Mar 11, 2024
1 parent 7767cf4 commit 6458e87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon.dist
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 8
paths:
- src
- tests
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyFactory.php
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -171,7 +171,7 @@ public function getEntityManager(): EntityManagerInterface
}

$this->em = $this->emLoader->getEntityManager($this->getConfiguration()->getEntityManagerName());
$this->freeze();
$this->frozen = true;
}

return $this->em;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/Tools/Console/Command/DoctrineCommand.php
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 6458e87

Please sign in to comment.