Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Apr 7, 2021
1 parent 49dbfe1 commit 8619658
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Expand Up @@ -40,7 +40,7 @@ parameters:
- fail
ignoreErrors:
# Real problems, hard to fix
- '#Parameter \#2 \$dqlPart of method Doctrine\\ORM\\QueryBuilder::add\(\) expects array\|object, string given\.#'
- '#Parameter \#2 \$dqlPart of method Doctrine\\ORM\\QueryBuilder::add\(\) expects .+#'
# False positives
-
message: '#Strict comparison using !== between .+ and .+ will always evaluate to false\.#'
Expand Down
1 change: 1 addition & 0 deletions src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php
Expand Up @@ -186,6 +186,7 @@ public static function getExistingJoin(QueryBuilder $queryBuilder, string $alias
*/
private static function mapRootAliases(array $rootAliases, array $rootEntities): array
{
/** @var bool|array $aliasMap */
$aliasMap = array_combine($rootAliases, $rootEntities);
if (false === $aliasMap) {
throw new \LogicException('Number of root aliases and root entities do not match.');
Expand Down
9 changes: 5 additions & 4 deletions tests/Behat/DoctrineContext.php
Expand Up @@ -182,7 +182,6 @@ final class DoctrineContext implements Context
private $passwordEncoder;
private $schemaTool;
private $schemaManager;
private $classes;

/**
* Initializes context.
Expand All @@ -198,17 +197,19 @@ public function __construct(ManagerRegistry $doctrine, UserPasswordEncoderInterf
$this->manager = $doctrine->getManager();
$this->schemaTool = $this->manager instanceof EntityManagerInterface ? new SchemaTool($this->manager) : null;
$this->schemaManager = $this->manager instanceof DocumentManager ? $this->manager->getSchemaManager() : null;
$this->classes = $this->manager->getMetadataFactory()->getAllMetadata();
}

/**
* @BeforeScenario @createSchema
*/
public function createDatabase()
{
/** @var array<int, \Doctrine\ORM\Mapping\ClassMetadata> $classes */
$classes = $this->manager->getMetadataFactory()->getAllMetadata();

if ($this->isOrm()) {
$this->schemaTool->dropSchema($this->classes);
$this->schemaTool->createSchema($this->classes);
$this->schemaTool->dropSchema($classes);
$this->schemaTool->createSchema($classes);
}

if ($this->isOdm()) {
Expand Down
1 change: 1 addition & 0 deletions tests/Bridge/Symfony/Bundle/Test/ApiTestCaseTest.php
Expand Up @@ -165,6 +165,7 @@ public function testFindIriBy(): void
* @var EntityManagerInterface
*/
$manager = self::$container->get('doctrine')->getManager();
/** @var array<int, \Doctrine\ORM\Mapping\ClassMetadata> $classes */
$classes = $manager->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($manager);

Expand Down
1 change: 1 addition & 0 deletions tests/Bridge/Symfony/Bundle/Test/ClientTest.php
Expand Up @@ -29,6 +29,7 @@ protected function setUp(): void
* @var EntityManagerInterface
*/
$manager = self::$container->get('doctrine')->getManager();
/** @var array<int, \Doctrine\ORM\Mapping\ClassMetadata> $classes */
$classes = $manager->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($manager);

Expand Down
Expand Up @@ -50,6 +50,7 @@ protected function setUp(): void
$manager = $doctrine->getManager();
$this->manager = $manager;
$this->schemaTool = new SchemaTool($this->manager);
/** @var array<int, \Doctrine\ORM\Mapping\ClassMetadata> $classes */
$classes = $this->manager->getMetadataFactory()->getAllMetadata();
$this->schemaTool->dropSchema($classes);
$this->manager->clear();
Expand Down

0 comments on commit 8619658

Please sign in to comment.