Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Apr 8, 2021
1 parent 49dbfe1 commit 4d42892
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Expand Up @@ -39,8 +39,6 @@ parameters:
PHPUnit\Framework\Constraint\Constraint:
- fail
ignoreErrors:
# Real problems, hard to fix
- '#Parameter \#2 \$dqlPart of method Doctrine\\ORM\\QueryBuilder::add\(\) expects array\|object, string given\.#'
# False positives
-
message: '#Strict comparison using !== between .+ and .+ will always evaluate to false\.#'
Expand Down
Expand Up @@ -150,6 +150,7 @@ private function getQueryBuilderWithNewAliases(QueryBuilder $queryBuilder, Query
$replacements[] = "$newAlias.";
$condition = str_replace($aliases, $replacements, $joinPart->getCondition());
$join = new Join($joinPart->getJoinType(), $joinPart->getJoin(), $newAlias, $joinPart->getConditionType(), $condition);
/** @phpstan-ignore-next-line */
$queryBuilderClone->add('join', [$replacement => $join], true);
}

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 false|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 \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 \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 \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 \Doctrine\ORM\Mapping\ClassMetadata[] $classes */
$classes = $this->manager->getMetadataFactory()->getAllMetadata();
$this->schemaTool->dropSchema($classes);
$this->manager->clear();
Expand Down

0 comments on commit 4d42892

Please sign in to comment.