Skip to content

Commit

Permalink
Raise PHPStan level to 8
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Mar 6, 2024
1 parent 0a09b85 commit de7e03b
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 8
paths:
- src
- tests
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyFactory.php
Original file line number Diff line number Diff line change
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()));

Check warning on line 225 in src/DependencyFactory.php

View check run for this annotation

Codecov / codecov/patch

src/DependencyFactory.php#L225

Added line #L225 was not covered by tests
}

public function hasSchemaProvider(): bool
Expand Down
8 changes: 5 additions & 3 deletions src/Tools/Console/Command/DoctrineCommand.php
Original file line number Diff line number Diff line change
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 de7e03b

Please sign in to comment.