From 1d97ce209b8b27a16331396b51071672bf8e412c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 16 Feb 2022 11:54:46 +0100 Subject: [PATCH] Split TreeWalker and SqlWalker --- lib/Doctrine/ORM/Query/QueryException.php | 15 +- lib/Doctrine/ORM/Query/SqlWalker.php | 515 ++++++--------- lib/Doctrine/ORM/Query/TreeWalker.php | 432 +------------ lib/Doctrine/ORM/Query/TreeWalkerAdapter.php | 493 +-------------- lib/Doctrine/ORM/Query/TreeWalkerChain.php | 597 +----------------- .../Tools/Pagination/CountOutputWalker.php | 22 +- .../ORM/Tools/Pagination/CountWalker.php | 17 +- .../Pagination/LimitSubqueryOutputWalker.php | 76 +-- .../Tools/Pagination/LimitSubqueryWalker.php | 30 +- .../ORM/Tools/Pagination/WhereInWalker.php | 39 +- phpstan-baseline.neon | 513 +-------------- psalm-baseline.xml | 278 +------- tests/Doctrine/Tests/Mocks/MockSqlWalker.php | 19 + tests/Doctrine/Tests/Mocks/MockTreeWalker.php | 21 - .../ORM/Functional/Ticket/DDC736Test.php | 12 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 8 +- .../ORM/Query/LanguageRecognitionTest.php | 41 +- .../ORM/Query/SelectSqlGenerationTest.php | 5 +- 18 files changed, 367 insertions(+), 2766 deletions(-) create mode 100644 tests/Doctrine/Tests/Mocks/MockSqlWalker.php delete mode 100644 tests/Doctrine/Tests/Mocks/MockTreeWalker.php diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index 5e5609ed3a4..f0cb8ca7cf5 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -7,6 +7,7 @@ use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Query\AST\PathExpression; use Exception; +use Stringable; /** * Description of QueryException. @@ -126,24 +127,14 @@ public static function parameterTypeMismatch() return new self('DQL Query parameter and type numbers mismatch, but have to be exactly equal.'); } - /** - * @param PathExpression $pathExpr - * - * @return QueryException - */ - public static function invalidPathExpression($pathExpr) + public static function invalidPathExpression(PathExpression $pathExpr): self { return new self( "Invalid PathExpression '" . $pathExpr->identificationVariable . '.' . $pathExpr->field . "'." ); } - /** - * @param string $literal - * - * @return QueryException - */ - public static function invalidLiteral($literal) + public static function invalidLiteral(string|Stringable $literal): self { return new self("Invalid literal '" . $literal . "'"); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index c93fa6f37f2..2e6745fcb81 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -46,7 +46,7 @@ * @psalm-import-type QueryComponent from Parser * @psalm-consistent-constructor */ -class SqlWalker implements TreeWalker +class SqlWalker { public const HINT_DISTINCT = 'doctrine.distinct'; @@ -55,166 +55,125 @@ class SqlWalker implements TreeWalker */ public const HINT_PARTIAL = 'doctrine.partial'; - /** @var ResultSetMapping */ - private $rsm; + private ResultSetMapping $rsm; /** * Counter for generating unique column aliases. - * - * @var int */ - private $aliasCounter = 0; + private int $aliasCounter = 0; /** * Counter for generating unique table aliases. - * - * @var int */ - private $tableAliasCounter = 0; + private int $tableAliasCounter = 0; /** * Counter for generating unique scalar result. - * - * @var int */ - private $scalarResultCounter = 1; + private int $scalarResultCounter = 1; /** * Counter for generating unique parameter indexes. - * - * @var int */ - private $sqlParamIndex = 0; + private int $sqlParamIndex = 0; /** * Counter for generating indexes. - * - * @var int */ - private $newObjectCounter = 0; - - /** @var ParserResult */ - private $parserResult; - - /** @var EntityManagerInterface */ - private $em; + private int $newObjectCounter = 0; - /** @var Connection */ - private $conn; - - /** @var Query */ - private $query; + private EntityManagerInterface $em; + private Connection $conn; /** @var mixed[] */ - private $tableAliasMap = []; + private array $tableAliasMap = []; /** * Map from result variable names to their SQL column alias names. * * @psalm-var array> */ - private $scalarResultAliasMap = []; + private array $scalarResultAliasMap = []; /** * Map from Table-Alias + Column-Name to OrderBy-Direction. * * @var array */ - private $orderedColumnsMap = []; + private array $orderedColumnsMap = []; /** * Map from DQL-Alias + Field-Name to SQL Column Alias. * * @var array> */ - private $scalarFields = []; - - /** - * Map of all components/classes that appear in the DQL query. - * - * @psalm-var array - */ - private $queryComponents; + private array $scalarFields = []; /** * A list of classes that appear in non-scalar SelectExpressions. * * @psalm-var array */ - private $selectedClasses = []; + private array $selectedClasses = []; /** * The DQL alias of the root class of the currently traversed query. * * @psalm-var list */ - private $rootAliases = []; + private array $rootAliases = []; /** * Flag that indicates whether to generate SQL table aliases in the SQL. * These should only be generated for SELECT queries, not for UPDATE/DELETE. - * - * @var bool */ - private $useSqlTableAliases = true; + private bool $useSqlTableAliases = true; /** * The database platform abstraction. - * - * @var AbstractPlatform */ - private $platform; + private AbstractPlatform $platform; /** * The quote strategy. - * - * @var QuoteStrategy */ - private $quoteStrategy; + private QuoteStrategy $quoteStrategy; /** - * @param Query $query The parsed Query. - * @param ParserResult $parserResult The result of the parsing process. * @psalm-param array $queryComponents The query components (symbol table). */ - public function __construct($query, $parserResult, array $queryComponents) - { - $this->query = $query; - $this->parserResult = $parserResult; - $this->queryComponents = $queryComponents; - $this->rsm = $parserResult->getResultSetMapping(); - $this->em = $query->getEntityManager(); - $this->conn = $this->em->getConnection(); - $this->platform = $this->conn->getDatabasePlatform(); - $this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy(); + public function __construct( + private Query $query, + private ParserResult $parserResult, + private array $queryComponents + ) { + $this->rsm = $parserResult->getResultSetMapping(); + $this->em = $query->getEntityManager(); + $this->conn = $this->em->getConnection(); + $this->platform = $this->conn->getDatabasePlatform(); + $this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy(); } /** * Gets the Query instance used by the walker. - * - * @return Query */ - public function getQuery() + public function getQuery(): Query { return $this->query; } /** * Gets the Connection used by the walker. - * - * @return Connection */ - public function getConnection() + public function getConnection(): Connection { return $this->conn; } /** * Gets the EntityManager used by the walker. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->em; } @@ -227,32 +186,33 @@ public function getEntityManager() * @return mixed[] * @psalm-return QueryComponent */ - public function getQueryComponent($dqlAlias) + public function getQueryComponent(string $dqlAlias): array { return $this->queryComponents[$dqlAlias]; } public function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata { - if (! isset($this->queryComponents[$dqlAlias]['metadata'])) { - throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); - } - - return $this->queryComponents[$dqlAlias]['metadata']; + return $this->queryComponents[$dqlAlias]['metadata'] + ?? throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); } /** - * {@inheritdoc} + * Returns internal queryComponents array. + * + * @return array */ - public function getQueryComponents() + public function getQueryComponents(): array { return $this->queryComponents; } /** - * {@inheritdoc} + * Sets or overrides a query component for a given dql alias. + * + * @psalm-param QueryComponent $queryComponent */ - public function setQueryComponent($dqlAlias, array $queryComponent) + public function setQueryComponent(string $dqlAlias, array $queryComponent): void { $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; @@ -264,39 +224,28 @@ public function setQueryComponent($dqlAlias, array $queryComponent) } /** - * {@inheritdoc} + * Gets an executor that can be used to execute the result of this walker. */ - public function getExecutor($AST) + public function getExecutor(AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST): ?Exec\AbstractSqlExecutor { - switch (true) { - case $AST instanceof AST\DeleteStatement: - $primaryClass = $this->em->getClassMetadata($AST->deleteClause->abstractSchemaName); - - return $primaryClass->isInheritanceTypeJoined() + return match (true) { + $AST instanceof AST\DeleteStatement + => $this->em->getClassMetadata($AST->deleteClause->abstractSchemaName)->isInheritanceTypeJoined() ? new Exec\MultiTableDeleteExecutor($AST, $this) - : new Exec\SingleTableDeleteUpdateExecutor($AST, $this); - - case $AST instanceof AST\UpdateStatement: - $primaryClass = $this->em->getClassMetadata($AST->updateClause->abstractSchemaName); - - return $primaryClass->isInheritanceTypeJoined() + : new Exec\SingleTableDeleteUpdateExecutor($AST, $this), + $AST instanceof AST\UpdateStatement + => $this->em->getClassMetadata($AST->updateClause->abstractSchemaName)->isInheritanceTypeJoined() ? new Exec\MultiTableUpdateExecutor($AST, $this) - : new Exec\SingleTableDeleteUpdateExecutor($AST, $this); - - default: - return new Exec\SingleSelectExecutor($AST, $this); - } + : new Exec\SingleTableDeleteUpdateExecutor($AST, $this), + $AST instanceof AST\SelectStatement + => new Exec\SingleSelectExecutor($AST, $this), + }; } /** * Generates a unique, short SQL table alias. - * - * @param string $tableName Table name - * @param string $dqlAlias The DQL alias. - * - * @return string Generated table alias. */ - public function getSQLTableAlias($tableName, $dqlAlias = '') + public function getSQLTableAlias(string $tableName, string $dqlAlias = ''): string { $tableName .= $dqlAlias ? '@[' . $dqlAlias . ']' : ''; @@ -311,14 +260,8 @@ public function getSQLTableAlias($tableName, $dqlAlias = '') /** * Forces the SqlWalker to use a specific alias for a table name, rather than * generating an alias on its own. - * - * @param string $tableName - * @param string $alias - * @param string $dqlAlias - * - * @return string */ - public function setSQLTableAlias($tableName, $alias, $dqlAlias = '') + public function setSQLTableAlias(string $tableName, string $alias, string $dqlAlias = ''): string { $tableName .= $dqlAlias ? '@[' . $dqlAlias . ']' : ''; @@ -329,12 +272,8 @@ public function setSQLTableAlias($tableName, $alias, $dqlAlias = '') /** * Gets an SQL column alias for a column name. - * - * @param string $columnName - * - * @return string */ - public function getSQLColumnAlias($columnName) + public function getSQLColumnAlias(string $columnName): string { return $this->quoteStrategy->getColumnAlias($columnName, $this->aliasCounter++, $this->platform); } @@ -342,11 +281,6 @@ public function getSQLColumnAlias($columnName) /** * Generates the SQL JOINs that are necessary for Class Table Inheritance * for the given class. - * - * @param ClassMetadata $class The class for which to generate the joins. - * @param string $dqlAlias The DQL alias of the class. - * - * @return string The SQL. */ private function generateClassTableInheritanceJoins( ClassMetadata $class, @@ -478,11 +412,6 @@ private function generateDiscriminatorColumnConditionSQL(array $dqlAliases): str /** * Generates the filter SQL for a given entity and table alias. - * - * @param ClassMetadata $targetEntity Metadata of the target entity. - * @param string $targetTableAlias The table alias of the joined/selected table. - * - * @return string The SQL query part to add to a query. */ private function generateFilterConditionSQL( ClassMetadata $targetEntity, @@ -525,9 +454,9 @@ private function generateFilterConditionSQL( } /** - * {@inheritdoc} + * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. */ - public function walkSelectStatement(AST\SelectStatement $AST) + public function walkSelectStatement(AST\SelectStatement $AST): string { $limit = $this->query->getMaxResults(); $offset = $this->query->getFirstResult(); @@ -583,9 +512,9 @@ public function walkSelectStatement(AST\SelectStatement $AST) } /** - * {@inheritdoc} + * Walks down a UpdateStatement AST node, thereby generating the appropriate SQL. */ - public function walkUpdateStatement(AST\UpdateStatement $AST) + public function walkUpdateStatement(AST\UpdateStatement $AST): string { $this->useSqlTableAliases = false; $this->rsm->isSelect = false; @@ -595,9 +524,9 @@ public function walkUpdateStatement(AST\UpdateStatement $AST) } /** - * {@inheritdoc} + * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. */ - public function walkDeleteStatement(AST\DeleteStatement $AST) + public function walkDeleteStatement(AST\DeleteStatement $AST): string { $this->useSqlTableAliases = false; $this->rsm->isSelect = false; @@ -609,12 +538,8 @@ public function walkDeleteStatement(AST\DeleteStatement $AST) /** * Walks down an IdentificationVariable AST node, thereby generating the appropriate SQL. * This one differs of ->walkIdentificationVariable() because it generates the entity identifiers. - * - * @param string $identVariable - * - * @return string */ - public function walkEntityIdentificationVariable($identVariable) + public function walkEntityIdentificationVariable(string $identVariable): string { $class = $this->getMetadataForDqlAlias($identVariable); $tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable); @@ -629,13 +554,8 @@ public function walkEntityIdentificationVariable($identVariable) /** * Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL. - * - * @param string $identificationVariable - * @param string $fieldName - * - * @return string The SQL. */ - public function walkIdentificationVariable($identificationVariable, $fieldName = null) + public function walkIdentificationVariable(string $identificationVariable, ?string $fieldName = null): string { $class = $this->getMetadataForDqlAlias($identificationVariable); @@ -650,9 +570,9 @@ public function walkIdentificationVariable($identificationVariable, $fieldName = } /** - * {@inheritdoc} + * Walks down a PathExpression AST node, thereby generating the appropriate SQL. */ - public function walkPathExpression($pathExpr) + public function walkPathExpression(AST\PathExpression $pathExpr): string { $sql = ''; assert($pathExpr->field !== null); @@ -707,9 +627,9 @@ public function walkPathExpression($pathExpr) } /** - * {@inheritdoc} + * Walks down a SelectClause AST node, thereby generating the appropriate SQL. */ - public function walkSelectClause($selectClause) + public function walkSelectClause(AST\SelectClause $selectClause): string { $sql = 'SELECT ' . ($selectClause->isDistinct ? 'DISTINCT ' : ''); $sqlSelectExpressions = array_filter(array_map([$this, 'walkSelectExpression'], $selectClause->selectExpressions)); @@ -823,9 +743,9 @@ public function walkSelectClause($selectClause) } /** - * {@inheritdoc} + * Walks down a FromClause AST node, thereby generating the appropriate SQL. */ - public function walkFromClause($fromClause) + public function walkFromClause(AST\FromClause $fromClause): string { $identificationVarDecls = $fromClause->identificationVariableDeclarations; $sqlParts = []; @@ -839,12 +759,8 @@ public function walkFromClause($fromClause) /** * Walks down a IdentificationVariableDeclaration AST node, thereby generating the appropriate SQL. - * - * @param AST\IdentificationVariableDeclaration $identificationVariableDecl - * - * @return string */ - public function walkIdentificationVariableDeclaration($identificationVariableDecl) + public function walkIdentificationVariableDeclaration(AST\IdentificationVariableDeclaration $identificationVariableDecl): string { $sql = $this->walkRangeVariableDeclaration($identificationVariableDecl->rangeVariableDeclaration); @@ -861,12 +777,8 @@ public function walkIdentificationVariableDeclaration($identificationVariableDec /** * Walks down a IndexBy AST node. - * - * @param AST\IndexBy $indexBy - * - * @return void */ - public function walkIndexBy($indexBy) + public function walkIndexBy(AST\IndexBy $indexBy): void { $pathExpression = $indexBy->singleValuedPathExpression; $alias = $pathExpression->identificationVariable; @@ -914,12 +826,8 @@ public function walkIndexBy($indexBy) /** * Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL. - * - * @param AST\RangeVariableDeclaration $rangeVariableDeclaration - * - * @return string */ - public function walkRangeVariableDeclaration($rangeVariableDeclaration) + public function walkRangeVariableDeclaration(AST\RangeVariableDeclaration $rangeVariableDeclaration): string { return $this->generateRangeVariableDeclarationSQL($rangeVariableDeclaration, false); } @@ -960,17 +868,15 @@ private function generateRangeVariableDeclarationSQL( /** * Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL. * - * @param AST\JoinAssociationDeclaration $joinAssociationDeclaration - * @param int $joinType - * @param AST\ConditionalExpression $condExpr * @psalm-param AST\Join::JOIN_TYPE_* $joinType * - * @return string - * * @throws QueryException */ - public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER, $condExpr = null) - { + public function walkJoinAssociationDeclaration( + AST\JoinAssociationDeclaration $joinAssociationDeclaration, + int $joinType = AST\Join::JOIN_TYPE_INNER, + ?AST\ConditionalPrimary $condExpr = null + ): string { $sql = ''; $associationPathExpression = $joinAssociationDeclaration->joinAssociationPathExpression; @@ -1127,17 +1033,17 @@ public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joi } /** - * {@inheritdoc} + * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. */ - public function walkFunction($function) + public function walkFunction(AST\Functions\FunctionNode $function): string { return $function->getSql($this); } /** - * {@inheritdoc} + * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. */ - public function walkOrderByClause($orderByClause) + public function walkOrderByClause(AST\OrderByClause $orderByClause): string { $orderByItems = array_map([$this, 'walkOrderByItem'], $orderByClause->orderByItems); @@ -1150,9 +1056,9 @@ public function walkOrderByClause($orderByClause) } /** - * {@inheritdoc} + * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. */ - public function walkOrderByItem($orderByItem) + public function walkOrderByItem(AST\OrderByItem $orderByItem): string { $type = strtoupper($orderByItem->type); $expr = $orderByItem->expression; @@ -1170,17 +1076,17 @@ public function walkOrderByItem($orderByItem) } /** - * {@inheritdoc} + * Walks down a HavingClause AST node, thereby generating the appropriate SQL. */ - public function walkHavingClause($havingClause) + public function walkHavingClause(AST\HavingClause $havingClause): string { return ' HAVING ' . $this->walkConditionalExpression($havingClause->conditionalExpression); } /** - * {@inheritdoc} + * Walks down a Join AST node and creates the corresponding SQL. */ - public function walkJoin($join) + public function walkJoin(AST\Join $join): string { $joinType = $join->joinType; $joinDeclaration = $join->joinAssociationDeclaration; @@ -1237,12 +1143,8 @@ public function walkJoin($join) /** * Walks down a CoalesceExpression AST node and generates the corresponding SQL. - * - * @param AST\CoalesceExpression $coalesceExpression - * - * @return string The SQL. */ - public function walkCoalesceExpression($coalesceExpression) + public function walkCoalesceExpression(AST\CoalesceExpression $coalesceExpression): string { $sql = 'COALESCE('; @@ -1257,12 +1159,8 @@ public function walkCoalesceExpression($coalesceExpression) /** * Walks down a NullIfExpression AST node and generates the corresponding SQL. - * - * @param AST\NullIfExpression $nullIfExpression - * - * @return string The SQL. */ - public function walkNullIfExpression($nullIfExpression) + public function walkNullIfExpression(AST\NullIfExpression $nullIfExpression): string { $firstExpression = is_string($nullIfExpression->firstExpression) ? $this->conn->quote($nullIfExpression->firstExpression) @@ -1277,10 +1175,8 @@ public function walkNullIfExpression($nullIfExpression) /** * Walks down a GeneralCaseExpression AST node and generates the corresponding SQL. - * - * @return string The SQL. */ - public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression) + public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression): string { $sql = 'CASE'; @@ -1296,12 +1192,8 @@ public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCase /** * Walks down a SimpleCaseExpression AST node and generates the corresponding SQL. - * - * @param AST\SimpleCaseExpression $simpleCaseExpression - * - * @return string The SQL. */ - public function walkSimpleCaseExpression($simpleCaseExpression) + public function walkSimpleCaseExpression(AST\SimpleCaseExpression $simpleCaseExpression): string { $sql = 'CASE ' . $this->walkStateFieldPathExpression($simpleCaseExpression->caseOperand); @@ -1316,9 +1208,9 @@ public function walkSimpleCaseExpression($simpleCaseExpression) } /** - * {@inheritdoc} + * Walks down a SelectExpression AST node and generates the corresponding SQL. */ - public function walkSelectExpression($selectExpression) + public function walkSelectExpression(AST\SelectExpression $selectExpression): string { $sql = ''; $expr = $selectExpression->expression; @@ -1507,18 +1399,15 @@ public function walkSelectExpression($selectExpression) return $sql; } - /** - * {@inheritdoc} - */ - public function walkQuantifiedExpression($qExpr) + public function walkQuantifiedExpression(AST\QuantifiedExpression $qExpr): string { return ' ' . strtoupper($qExpr->type) . '(' . $this->walkSubselect($qExpr->subselect) . ')'; } /** - * {@inheritdoc} + * Walks down a Subselect AST node, thereby generating the appropriate SQL. */ - public function walkSubselect($subselect) + public function walkSubselect(AST\Subselect $subselect): string { $useAliasesBefore = $this->useSqlTableAliases; $rootAliasesBefore = $this->rootAliases; @@ -1541,9 +1430,9 @@ public function walkSubselect($subselect) } /** - * {@inheritdoc} + * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. */ - public function walkSubselectFromClause($subselectFromClause) + public function walkSubselectFromClause(AST\SubselectFromClause $subselectFromClause): string { $identificationVarDecls = $subselectFromClause->identificationVariableDeclarations; $sqlParts = []; @@ -1556,29 +1445,20 @@ public function walkSubselectFromClause($subselectFromClause) } /** - * {@inheritdoc} + * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. */ - public function walkSimpleSelectClause($simpleSelectClause) + public function walkSimpleSelectClause(AST\SimpleSelectClause $simpleSelectClause): string { return 'SELECT' . ($simpleSelectClause->isDistinct ? ' DISTINCT' : '') . $this->walkSimpleSelectExpression($simpleSelectClause->simpleSelectExpression); } - /** - * @return string - */ - public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression) + public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression): string { return sprintf('(%s)', $parenthesisExpression->expression->dispatch($this)); } - /** - * @param AST\NewObjectExpression $newObjectExpression - * @param string|null $newObjectResultAlias - * - * @return string The SQL. - */ - public function walkNewObject($newObjectExpression, $newObjectResultAlias = null) + public function walkNewObject(AST\NewObjectExpression $newObjectExpression, ?string $newObjectResultAlias = null): string { $sqlSelectExpressions = []; $objIndex = $newObjectResultAlias ?: $this->newObjectCounter++; @@ -1646,10 +1526,7 @@ public function walkNewObject($newObjectExpression, $newObjectResultAlias = null return implode(', ', $sqlSelectExpressions); } - /** - * {@inheritdoc} - */ - public function walkSimpleSelectExpression($simpleSelectExpression) + public function walkSimpleSelectExpression(AST\SimpleSelectExpression $simpleSelectExpression): string { $expr = $simpleSelectExpression->expression; $sql = ' '; @@ -1697,19 +1574,13 @@ public function walkSimpleSelectExpression($simpleSelectExpression) return $sql; } - /** - * {@inheritdoc} - */ - public function walkAggregateExpression($aggExpression) + public function walkAggregateExpression(AST\AggregateExpression $aggExpression): string { return $aggExpression->functionName . '(' . ($aggExpression->isDistinct ? 'DISTINCT ' : '') . $this->walkSimpleArithmeticExpression($aggExpression->pathExpression) . ')'; } - /** - * {@inheritdoc} - */ - public function walkGroupByClause($groupByClause) + public function walkGroupByClause(AST\GroupByClause $groupByClause): string { $sqlParts = []; @@ -1721,9 +1592,9 @@ public function walkGroupByClause($groupByClause) } /** - * {@inheritdoc} + * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. */ - public function walkGroupByItem($groupByItem) + public function walkGroupByItem(AST\PathExpression|string $groupByItem): string { // StateFieldPathExpression if (! is_string($groupByItem)) { @@ -1768,9 +1639,9 @@ public function walkGroupByItem($groupByItem) } /** - * {@inheritdoc} + * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. */ - public function walkDeleteClause(AST\DeleteClause $deleteClause) + public function walkDeleteClause(AST\DeleteClause $deleteClause): string { $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName); $tableName = $class->getTableName(); @@ -1783,9 +1654,9 @@ public function walkDeleteClause(AST\DeleteClause $deleteClause) } /** - * {@inheritdoc} + * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. */ - public function walkUpdateClause($updateClause) + public function walkUpdateClause(AST\UpdateClause $updateClause): string { $class = $this->em->getClassMetadata($updateClause->abstractSchemaName); $tableName = $class->getTableName(); @@ -1798,9 +1669,9 @@ public function walkUpdateClause($updateClause) } /** - * {@inheritdoc} + * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. */ - public function walkUpdateItem($updateItem) + public function walkUpdateItem(AST\UpdateItem $updateItem): string { $useTableAliasesBefore = $this->useSqlTableAliases; $this->useSqlTableAliases = false; @@ -1808,19 +1679,11 @@ public function walkUpdateItem($updateItem) $sql = $this->walkPathExpression($updateItem->pathExpression) . ' = '; $newValue = $updateItem->newValue; - switch (true) { - case $newValue instanceof AST\Node: - $sql .= $newValue->dispatch($this); - break; - - case $newValue === null: - $sql .= 'NULL'; - break; - - default: - $sql .= $this->conn->quote($newValue); - break; - } + $sql .= match (true) { + $newValue instanceof AST\Node => $newValue->dispatch($this), + $newValue === null => 'NULL', + default => $this->conn->quote($newValue), + }; $this->useSqlTableAliases = $useTableAliasesBefore; @@ -1828,9 +1691,11 @@ public function walkUpdateItem($updateItem) } /** - * {@inheritdoc} + * Walks down a WhereClause AST node, thereby generating the appropriate SQL. + * + * WhereClause or not, the appropriate discriminator sql is added. */ - public function walkWhereClause($whereClause) + public function walkWhereClause(?AST\WhereClause $whereClause): string { $condSql = $whereClause !== null ? $this->walkConditionalExpression($whereClause->conditionalExpression) : ''; $discrSql = $this->generateDiscriminatorColumnConditionSQL($this->rootAliases); @@ -1868,10 +1733,11 @@ public function walkWhereClause($whereClause) } /** - * {@inheritdoc} + * Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL. */ - public function walkConditionalExpression($condExpr) - { + public function walkConditionalExpression( + AST\ConditionalExpression|AST\ConditionalPrimary|AST\ConditionalTerm|AST\ConditionalFactor $condExpr + ): string { // Phase 2 AST optimization: Skip processing of ConditionalExpression // if only one ConditionalTerm is defined if (! ($condExpr instanceof AST\ConditionalExpression)) { @@ -1882,10 +1748,11 @@ public function walkConditionalExpression($condExpr) } /** - * {@inheritdoc} + * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. */ - public function walkConditionalTerm($condTerm) - { + public function walkConditionalTerm( + AST\ConditionalTerm|AST\ConditionalPrimary|AST\ConditionalFactor $condTerm + ): string { // Phase 2 AST optimization: Skip processing of ConditionalTerm // if only one ConditionalFactor is defined if (! ($condTerm instanceof AST\ConditionalTerm)) { @@ -1896,10 +1763,11 @@ public function walkConditionalTerm($condTerm) } /** - * {@inheritdoc} + * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. */ - public function walkConditionalFactor($factor) - { + public function walkConditionalFactor( + AST\ConditionalFactor|AST\ConditionalPrimary $factor + ): string { // Phase 2 AST optimization: Skip processing of ConditionalFactor // if only one ConditionalPrimary is defined return ! ($factor instanceof AST\ConditionalFactor) @@ -1908,9 +1776,9 @@ public function walkConditionalFactor($factor) } /** - * {@inheritdoc} + * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. */ - public function walkConditionalPrimary($primary) + public function walkConditionalPrimary(AST\ConditionalPrimary $primary): string { if ($primary->isSimpleConditionalExpression()) { return $primary->simpleConditionalExpression->dispatch($this); @@ -1921,12 +1789,14 @@ public function walkConditionalPrimary($primary) return '(' . $this->walkConditionalExpression($condExpr) . ')'; } + + throw new LogicException('Unexpected state of ConditionalPrimary node.'); } /** - * {@inheritdoc} + * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. */ - public function walkExistsExpression($existsExpr) + public function walkExistsExpression(AST\ExistsExpression $existsExpr): string { $sql = $existsExpr->not ? 'NOT ' : ''; @@ -1936,9 +1806,9 @@ public function walkExistsExpression($existsExpr) } /** - * {@inheritdoc} + * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. */ - public function walkCollectionMemberExpression($collMemberExpr) + public function walkCollectionMemberExpression(AST\CollectionMemberExpression $collMemberExpr): string { $sql = $collMemberExpr->not ? 'NOT ' : ''; $sql .= 'EXISTS (SELECT 1 FROM '; @@ -2033,9 +1903,9 @@ public function walkCollectionMemberExpression($collMemberExpr) } /** - * {@inheritdoc} + * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) + public function walkEmptyCollectionComparisonExpression(AST\EmptyCollectionComparisonExpression $emptyCollCompExpr): string { $sizeFunc = new AST\Functions\SizeFunction('size'); $sizeFunc->collectionPathExpression = $emptyCollCompExpr->expression; @@ -2044,9 +1914,9 @@ public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) } /** - * {@inheritdoc} + * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. */ - public function walkNullComparisonExpression($nullCompExpr) + public function walkNullComparisonExpression(AST\NullComparisonExpression $nullCompExpr): string { $expression = $nullCompExpr->expression; $comparison = ' IS' . ($nullCompExpr->not ? ' NOT' : '') . ' NULL'; @@ -2065,9 +1935,9 @@ public function walkNullComparisonExpression($nullCompExpr) } /** - * {@inheritdoc} + * Walks down an InExpression AST node, thereby generating the appropriate SQL. */ - public function walkInExpression($inExpr) + public function walkInExpression(AST\InExpression $inExpr): string { $sql = $this->walkArithmeticExpression($inExpr->expression) . ($inExpr->not ? ' NOT' : '') . ' IN ('; @@ -2081,11 +1951,11 @@ public function walkInExpression($inExpr) } /** - * {@inheritdoc} + * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. * * @throws QueryException */ - public function walkInstanceOfExpression($instanceOfExpr) + public function walkInstanceOfExpression(AST\InstanceOfExpression $instanceOfExpr): string { $sql = ''; @@ -2106,42 +1976,27 @@ public function walkInstanceOfExpression($instanceOfExpr) return $sql; } - /** - * @param mixed $inParam - * - * @return string - */ - public function walkInParameter($inParam) + public function walkInParameter(mixed $inParam): string { return $inParam instanceof AST\InputParameter ? $this->walkInputParameter($inParam) : $this->walkArithmeticExpression($inParam); } - /** - * {@inheritdoc} - */ - public function walkLiteral($literal) + public function walkLiteral(AST\Literal $literal): string { - switch ($literal->type) { - case AST\Literal::STRING: - return $this->conn->quote($literal->value); - - case AST\Literal::BOOLEAN: - return (string) $this->conn->getDatabasePlatform()->convertBooleans(strtolower($literal->value) === 'true'); - - case AST\Literal::NUMERIC: - return (string) $literal->value; - - default: - throw QueryException::invalidLiteral($literal); - } + return match ($literal->type) { + AST\Literal::STRING => $this->conn->quote($literal->value), + AST\Literal::BOOLEAN => (string) $this->conn->getDatabasePlatform()->convertBooleans(strtolower($literal->value) === 'true'), + AST\Literal::NUMERIC => (string) $literal->value, + default => throw QueryException::invalidLiteral($literal), + }; } /** - * {@inheritdoc} + * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. */ - public function walkBetweenExpression($betweenExpr) + public function walkBetweenExpression(AST\BetweenExpression $betweenExpr): string { $sql = $this->walkArithmeticExpression($betweenExpr->expression); @@ -2156,9 +2011,9 @@ public function walkBetweenExpression($betweenExpr) } /** - * {@inheritdoc} + * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. */ - public function walkLikeExpression($likeExpr) + public function walkLikeExpression(AST\LikeExpression $likeExpr): string { $stringExpr = $likeExpr->stringExpression; $leftExpr = is_string($stringExpr) && isset($this->queryComponents[$stringExpr]['resultVariable']) @@ -2185,17 +2040,17 @@ public function walkLikeExpression($likeExpr) } /** - * {@inheritdoc} + * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. */ - public function walkStateFieldPathExpression($stateFieldPathExpression) + public function walkStateFieldPathExpression(AST\PathExpression $stateFieldPathExpression): string { return $this->walkPathExpression($stateFieldPathExpression); } /** - * {@inheritdoc} + * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. */ - public function walkComparisonExpression($compExpr) + public function walkComparisonExpression(AST\ComparisonExpression $compExpr): string { $leftExpr = $compExpr->leftExpression; $rightExpr = $compExpr->rightExpression; @@ -2215,9 +2070,9 @@ public function walkComparisonExpression($compExpr) } /** - * {@inheritdoc} + * Walks down an InputParameter AST node, thereby generating the appropriate SQL. */ - public function walkInputParameter($inputParam) + public function walkInputParameter(AST\InputParameter $inputParam): string { $this->parserResult->addParameterMapping($inputParam->name, $this->sqlParamIndex++); @@ -2234,9 +2089,9 @@ public function walkInputParameter($inputParam) } /** - * {@inheritdoc} + * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. */ - public function walkArithmeticExpression($arithmeticExpr) + public function walkArithmeticExpression(AST\ArithmeticExpression $arithmeticExpr): string { return $arithmeticExpr->isSimpleArithmeticExpression() ? $this->walkSimpleArithmeticExpression($arithmeticExpr->simpleArithmeticExpression) @@ -2244,9 +2099,9 @@ public function walkArithmeticExpression($arithmeticExpr) } /** - * {@inheritdoc} + * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr) + public function walkSimpleArithmeticExpression(AST\Node|string $simpleArithmeticExpr): string { if (! ($simpleArithmeticExpr instanceof AST\SimpleArithmeticExpression)) { return $this->walkArithmeticTerm($simpleArithmeticExpr); @@ -2256,9 +2111,9 @@ public function walkSimpleArithmeticExpression($simpleArithmeticExpr) } /** - * {@inheritdoc} + * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. */ - public function walkArithmeticTerm($term) + public function walkArithmeticTerm(AST\Node|string $term): string { if (is_string($term)) { return isset($this->queryComponents[$term]) @@ -2276,9 +2131,9 @@ public function walkArithmeticTerm($term) } /** - * {@inheritdoc} + * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. */ - public function walkArithmeticFactor($factor) + public function walkArithmeticFactor(AST\Node|string $factor): string { if (is_string($factor)) { return isset($this->queryComponents[$factor]) @@ -2299,12 +2154,8 @@ public function walkArithmeticFactor($factor) /** * Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed $primary - * - * @return string The SQL. */ - public function walkArithmeticPrimary($primary) + public function walkArithmeticPrimary(AST\Node|string $primary): string { if ($primary instanceof AST\SimpleArithmeticExpression) { return '(' . $this->walkSimpleArithmeticExpression($primary) . ')'; @@ -2318,9 +2169,9 @@ public function walkArithmeticPrimary($primary) } /** - * {@inheritdoc} + * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. */ - public function walkStringPrimary($stringPrimary) + public function walkStringPrimary(AST\Node|string $stringPrimary): string { return is_string($stringPrimary) ? $this->conn->quote($stringPrimary) @@ -2328,9 +2179,9 @@ public function walkStringPrimary($stringPrimary) } /** - * {@inheritdoc} + * Walks down a ResultVariable that represents an AST node, thereby generating the appropriate SQL. */ - public function walkResultVariable($resultVariable) + public function walkResultVariable(string $resultVariable): string { $resultAlias = $this->scalarResultAliasMap[$resultVariable]; diff --git a/lib/Doctrine/ORM/Query/TreeWalker.php b/lib/Doctrine/ORM/Query/TreeWalker.php index 5e34c35e92d..6c215773d4f 100644 --- a/lib/Doctrine/ORM/Query/TreeWalker.php +++ b/lib/Doctrine/ORM/Query/TreeWalker.php @@ -16,445 +16,29 @@ interface TreeWalker /** * Initializes TreeWalker with important information about the ASTs to be walked. * - * @param AbstractQuery $query The parsed Query. - * @param ParserResult $parserResult The result of the parsing process. - * @param mixed[] $queryComponents The query components (symbol table). * @psalm-param array $queryComponents The query components (symbol table). */ - public function __construct($query, $parserResult, array $queryComponents); + public function __construct(AbstractQuery $query, ParserResult $parserResult, array $queryComponents); /** * Returns internal queryComponents array. * - * @return array> * @psalm-return array */ - public function getQueryComponents(); + public function getQueryComponents(): array; /** - * Sets or overrides a query component for a given dql alias. - * - * @param string $dqlAlias The DQL alias. - * @param array $queryComponent - * @psalm-param QueryComponent $queryComponent - * - * @return void - */ - public function setQueryComponent($dqlAlias, array $queryComponent); - - /** - * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. - */ - public function walkSelectStatement(AST\SelectStatement $AST); - - /** - * Walks down a SelectClause AST node, thereby generating the appropriate SQL. - * - * @param AST\SelectClause $selectClause - * - * @return string The SQL. - */ - public function walkSelectClause($selectClause); - - /** - * Walks down a FromClause AST node, thereby generating the appropriate SQL. - * - * @param AST\FromClause $fromClause - * - * @return string The SQL. - */ - public function walkFromClause($fromClause); - - /** - * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. - * - * @param AST\Functions\FunctionNode $function - * - * @return string The SQL. - */ - public function walkFunction($function); - - /** - * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. - * - * @param AST\OrderByClause $orderByClause - * - * @return string The SQL. - */ - public function walkOrderByClause($orderByClause); - - /** - * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. - * - * @param AST\OrderByItem $orderByItem - * - * @return string The SQL. - */ - public function walkOrderByItem($orderByItem); - - /** - * Walks down a HavingClause AST node, thereby generating the appropriate SQL. - * - * @param AST\HavingClause $havingClause - * - * @return string The SQL. - */ - public function walkHavingClause($havingClause); - - /** - * Walks down a Join AST node and creates the corresponding SQL. - * - * @param AST\Join $join - * - * @return string The SQL. - */ - public function walkJoin($join); - - /** - * Walks down a SelectExpression AST node and generates the corresponding SQL. - * - * @param AST\SelectExpression $selectExpression - * - * @return string The SQL. - */ - public function walkSelectExpression($selectExpression); - - /** - * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\QuantifiedExpression $qExpr - * - * @return string The SQL. - */ - public function walkQuantifiedExpression($qExpr); - - /** - * Walks down a Subselect AST node, thereby generating the appropriate SQL. - * - * @param AST\Subselect $subselect - * - * @return string The SQL. - */ - public function walkSubselect($subselect); - - /** - * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. - * - * @param AST\SubselectFromClause $subselectFromClause - * - * @return string The SQL. + * Walks down a SelectStatement AST node. */ - public function walkSubselectFromClause($subselectFromClause); + public function walkSelectStatement(AST\SelectStatement $selectStatement): void; /** - * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. - * - * @param AST\SimpleSelectClause $simpleSelectClause - * - * @return string The SQL. + * Walks down an UpdateStatement AST node. */ - public function walkSimpleSelectClause($simpleSelectClause); + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void; /** - * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\SimpleSelectExpression $simpleSelectExpression - * - * @return string The SQL. - */ - public function walkSimpleSelectExpression($simpleSelectExpression); - - /** - * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\AggregateExpression $aggExpression - * - * @return string The SQL. - */ - public function walkAggregateExpression($aggExpression); - - /** - * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. - * - * @param AST\GroupByClause $groupByClause - * - * @return string The SQL. - */ - public function walkGroupByClause($groupByClause); - - /** - * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. - * - * @param AST\PathExpression|string $groupByItem - * - * @return string The SQL. - */ - public function walkGroupByItem($groupByItem); - - /** - * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. - */ - public function walkUpdateStatement(AST\UpdateStatement $AST); - - /** - * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. - */ - public function walkDeleteStatement(AST\DeleteStatement $AST); - - /** - * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. - */ - public function walkDeleteClause(AST\DeleteClause $deleteClause); - - /** - * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. - * - * @param AST\UpdateClause $updateClause - * - * @return string The SQL. - */ - public function walkUpdateClause($updateClause); - - /** - * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. - * - * @param AST\UpdateItem $updateItem - * - * @return string The SQL. - */ - public function walkUpdateItem($updateItem); - - /** - * Walks down a WhereClause AST node, thereby generating the appropriate SQL. - * WhereClause or not, the appropriate discriminator sql is added. - * - * @param AST\WhereClause $whereClause - * - * @return string The SQL. - */ - public function walkWhereClause($whereClause); - - /** - * Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalExpression $condExpr - * - * @return string The SQL. - */ - public function walkConditionalExpression($condExpr); - - /** - * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalTerm $condTerm - * - * @return string The SQL. - */ - public function walkConditionalTerm($condTerm); - - /** - * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalFactor $factor - * - * @return string The SQL. - */ - public function walkConditionalFactor($factor); - - /** - * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalPrimary $primary - * - * @return string The SQL. - */ - public function walkConditionalPrimary($primary); - - /** - * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ExistsExpression $existsExpr - * - * @return string The SQL. - */ - public function walkExistsExpression($existsExpr); - - /** - * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\CollectionMemberExpression $collMemberExpr - * - * @return string The SQL. - */ - public function walkCollectionMemberExpression($collMemberExpr); - - /** - * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\EmptyCollectionComparisonExpression $emptyCollCompExpr - * - * @return string The SQL. - */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr); - - /** - * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\NullComparisonExpression $nullCompExpr - * - * @return string The SQL. - */ - public function walkNullComparisonExpression($nullCompExpr); - - /** - * Walks down an InExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\InExpression $inExpr - * - * @return string The SQL. - */ - public function walkInExpression($inExpr); - - /** - * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\InstanceOfExpression $instanceOfExpr - * - * @return string The SQL. - */ - public function walkInstanceOfExpression($instanceOfExpr); - - /** - * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed $literal - * - * @return string The SQL. - */ - public function walkLiteral($literal); - - /** - * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\BetweenExpression $betweenExpr - * - * @return string The SQL. - */ - public function walkBetweenExpression($betweenExpr); - - /** - * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\LikeExpression $likeExpr - * - * @return string The SQL. - */ - public function walkLikeExpression($likeExpr); - - /** - * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\PathExpression $stateFieldPathExpression - * - * @return string The SQL. - */ - public function walkStateFieldPathExpression($stateFieldPathExpression); - - /** - * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ComparisonExpression $compExpr - * - * @return string The SQL. - */ - public function walkComparisonExpression($compExpr); - - /** - * Walks down an InputParameter AST node, thereby generating the appropriate SQL. - * - * @param AST\InputParameter $inputParam - * - * @return string The SQL. - */ - public function walkInputParameter($inputParam); - - /** - * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ArithmeticExpression $arithmeticExpr - * - * @return string The SQL. - */ - public function walkArithmeticExpression($arithmeticExpr); - - /** - * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. - * - * @param mixed $term - * - * @return string The SQL. - */ - public function walkArithmeticTerm($term); - - /** - * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed $stringPrimary - * - * @return string The SQL. - */ - public function walkStringPrimary($stringPrimary); - - /** - * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed $factor - * - * @return string The SQL. - */ - public function walkArithmeticFactor($factor); - - /** - * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\SimpleArithmeticExpression $simpleArithmeticExpr - * - * @return string The SQL. - */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr); - - /** - * Walks down a PathExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\PathExpression $pathExpr - * - * @return string The SQL. - */ - public function walkPathExpression($pathExpr); - - /** - * Walks down a ResultVariable that represents an AST node, thereby generating the appropriate SQL. - * - * @param string $resultVariable - * - * @return string The SQL. - */ - public function walkResultVariable($resultVariable); - - /** - * Gets an executor that can be used to execute the result of this walker. - * - * @param AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST - * - * @return Exec\AbstractSqlExecutor + * Walks down a DeleteStatement AST node. */ - public function getExecutor($AST); + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void; } diff --git a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php index bcec88cdaa5..92cc8710db8 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php @@ -5,9 +5,12 @@ namespace Doctrine\ORM\Query; use Doctrine\ORM\AbstractQuery; +use Doctrine\ORM\Mapping\ClassMetadata; +use LogicException; use function array_diff; use function array_keys; +use function sprintf; /** * An adapter implementation of the TreeWalker interface. The methods in this class @@ -17,507 +20,71 @@ */ abstract class TreeWalkerAdapter implements TreeWalker { - /** - * The original Query. - * - * @var AbstractQuery - */ - private $_query; - - /** - * The ParserResult of the original query that was produced by the Parser. - * - * @var ParserResult - */ - private $_parserResult; - - /** - * The query components of the original query (the "symbol table") that was produced by the Parser. - * - * @psalm-var array - */ - private $_queryComponents; - - /** - * {@inheritdoc} - */ - public function __construct($query, $parserResult, array $queryComponents) - { - $this->_query = $query; - $this->_parserResult = $parserResult; - $this->_queryComponents = $queryComponents; - } - - /** - * {@inheritdoc} - */ - public function getQueryComponents() - { - return $this->_queryComponents; - } - - /** - * {@inheritdoc} - */ - public function setQueryComponent($dqlAlias, array $queryComponent) - { - $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; - - if (array_diff($requiredKeys, array_keys($queryComponent))) { - throw QueryException::invalidQueryComponent($dqlAlias); - } - - $this->_queryComponents[$dqlAlias] = $queryComponent; - } - - /** - * {@inheritDoc} - */ - protected function _getQueryComponents() - { - return $this->_queryComponents; - } - - /** - * Retrieves the Query Instance responsible for the current walkers execution. - * - * @return AbstractQuery - */ - protected function _getQuery() - { - return $this->_query; - } - - /** - * Retrieves the ParserResult. - * - * @return ParserResult - */ - protected function _getParserResult() - { - return $this->_parserResult; - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSelectStatement(AST\SelectStatement $AST) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSelectClause($selectClause) - { - } - /** * {@inheritdoc} - * - * @return void */ - public function walkFromClause($fromClause) - { + public function __construct( + private AbstractQuery $query, + private ParserResult $parserResult, + private array $queryComponents + ) { } /** * {@inheritdoc} - * - * @return void */ - public function walkFunction($function) + public function getQueryComponents(): array { + return $this->queryComponents; } - /** - * {@inheritdoc} - * - * @return void - */ - public function walkOrderByClause($orderByClause) + public function walkSelectStatement(AST\SelectStatement $selectStatement): void { } - /** - * {@inheritdoc} - * - * @return void - */ - public function walkOrderByItem($orderByItem) + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void { } - /** - * {@inheritdoc} - * - * @return void - */ - public function walkHavingClause($havingClause) + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void { } /** - * {@inheritdoc} + * Sets or overrides a query component for a given dql alias. * - * @return void + * @psalm-param QueryComponent $queryComponent */ - public function walkJoin($join) + protected function setQueryComponent(string $dqlAlias, array $queryComponent): void { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSelectExpression($selectExpression) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkQuantifiedExpression($qExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSubselect($subselect) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSubselectFromClause($subselectFromClause) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSimpleSelectClause($simpleSelectClause) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSimpleSelectExpression($simpleSelectExpression) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkAggregateExpression($aggExpression) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkGroupByClause($groupByClause) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkGroupByItem($groupByItem) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkUpdateStatement(AST\UpdateStatement $AST) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkDeleteStatement(AST\DeleteStatement $AST) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkDeleteClause(AST\DeleteClause $deleteClause) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkUpdateClause($updateClause) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkUpdateItem($updateItem) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkWhereClause($whereClause) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalExpression($condExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalTerm($condTerm) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalFactor($factor) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalPrimary($primary) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkExistsExpression($existsExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkCollectionMemberExpression($collMemberExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkNullComparisonExpression($nullCompExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkInExpression($inExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkInstanceOfExpression($instanceOfExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkLiteral($literal) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkBetweenExpression($betweenExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkLikeExpression($likeExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkStateFieldPathExpression($stateFieldPathExpression) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkComparisonExpression($compExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkInputParameter($inputParam) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkArithmeticExpression($arithmeticExpr) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkArithmeticTerm($term) - { - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkStringPrimary($stringPrimary) - { - } + $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; - /** - * {@inheritdoc} - * - * @return void - */ - public function walkArithmeticFactor($factor) - { - } + if (array_diff($requiredKeys, array_keys($queryComponent))) { + throw QueryException::invalidQueryComponent($dqlAlias); + } - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr) - { + $this->queryComponents[$dqlAlias] = $queryComponent; } - /** - * {@inheritdoc} - * - * @return void - */ - public function walkPathExpression($pathExpr) + protected function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata { + return $this->queryComponents[$dqlAlias]['metadata'] + ?? throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); } /** - * {@inheritdoc} - * - * @return void + * Retrieves the Query Instance responsible for the current walkers execution. */ - public function walkResultVariable($resultVariable) + protected function _getQuery(): AbstractQuery { + return $this->query; } /** - * {@inheritdoc} - * - * @return void + * Retrieves the ParserResult. */ - public function getExecutor($AST) + protected function _getParserResult(): ParserResult { + return $this->parserResult; } } diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/lib/Doctrine/ORM/Query/TreeWalkerChain.php index 9a93b696152..6f9243790e3 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChain.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChain.php @@ -7,9 +7,6 @@ use Doctrine\ORM\AbstractQuery; use Generator; -use function array_diff; -use function array_keys; - /** * Represents a chain of tree walkers that modify an AST and finally emit output. * Only the last walker in the chain can emit output. Any previous walkers can modify @@ -25,80 +22,43 @@ class TreeWalkerChain implements TreeWalker * @var string[] * @psalm-var list> */ - private $walkers = []; - - /** @var AbstractQuery */ - private $query; - - /** @var ParserResult */ - private $parserResult; + private array $walkers = []; /** - * The query components of the original query (the "symbol table") that was produced by the Parser. - * - * @var array> - * @psalm-var array + * {@inheritdoc} */ - private $queryComponents; + public function __construct( + private AbstractQuery $query, + private ParserResult $parserResult, + private array $queryComponents + ) { + } /** * Returns the internal queryComponents array. * * {@inheritDoc} */ - public function getQueryComponents() + public function getQueryComponents(): array { return $this->queryComponents; } - /** - * {@inheritdoc} - * - * @return void - */ - public function setQueryComponent($dqlAlias, array $queryComponent) - { - $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; - - if (array_diff($requiredKeys, array_keys($queryComponent))) { - throw QueryException::invalidQueryComponent($dqlAlias); - } - - $this->queryComponents[$dqlAlias] = $queryComponent; - } - - /** - * {@inheritdoc} - */ - public function __construct($query, $parserResult, array $queryComponents) - { - $this->query = $query; - $this->parserResult = $parserResult; - $this->queryComponents = $queryComponents; - } - /** * Adds a tree walker to the chain. * * @param string $walkerClass The class of the walker to instantiate. * @psalm-param class-string $walkerClass - * - * @return void */ - public function addTreeWalker($walkerClass) + public function addTreeWalker(string $walkerClass): void { $this->walkers[] = $walkerClass; } - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSelectStatement(AST\SelectStatement $AST) + public function walkSelectStatement(AST\SelectStatement $selectStatement): void { foreach ($this->getWalkers() as $walker) { - $walker->walkSelectStatement($AST); + $walker->walkSelectStatement($selectStatement); $this->queryComponents = $walker->getQueryComponents(); } @@ -109,466 +69,10 @@ public function walkSelectStatement(AST\SelectStatement $AST) * * @return void */ - public function walkSelectClause($selectClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkSelectClause($selectClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkFromClause($fromClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkFromClause($fromClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkFunction($function) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkFunction($function); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkOrderByClause($orderByClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkOrderByClause($orderByClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkOrderByItem($orderByItem) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkOrderByItem($orderByItem); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkHavingClause($havingClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkHavingClause($havingClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkJoin($join) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkJoin($join); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSelectExpression($selectExpression) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkSelectExpression($selectExpression); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkQuantifiedExpression($qExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkQuantifiedExpression($qExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSubselect($subselect) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkSubselect($subselect); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSubselectFromClause($subselectFromClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkSubselectFromClause($subselectFromClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSimpleSelectClause($simpleSelectClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkSimpleSelectClause($simpleSelectClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSimpleSelectExpression($simpleSelectExpression) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkSimpleSelectExpression($simpleSelectExpression); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkAggregateExpression($aggExpression) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkAggregateExpression($aggExpression); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkGroupByClause($groupByClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkGroupByClause($groupByClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkGroupByItem($groupByItem) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkGroupByItem($groupByItem); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkUpdateStatement(AST\UpdateStatement $AST) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkUpdateStatement($AST); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkDeleteStatement(AST\DeleteStatement $AST) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkDeleteStatement($AST); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkDeleteClause(AST\DeleteClause $deleteClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkDeleteClause($deleteClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkUpdateClause($updateClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkUpdateClause($updateClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkUpdateItem($updateItem) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkUpdateItem($updateItem); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkWhereClause($whereClause) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkWhereClause($whereClause); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalExpression($condExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalExpression($condExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalTerm($condTerm) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalTerm($condTerm); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalFactor($factor) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalFactor($factor); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkConditionalPrimary($condPrimary) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalPrimary($condPrimary); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkExistsExpression($existsExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkExistsExpression($existsExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkCollectionMemberExpression($collMemberExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkCollectionMemberExpression($collMemberExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkEmptyCollectionComparisonExpression($emptyCollCompExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkNullComparisonExpression($nullCompExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkNullComparisonExpression($nullCompExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkInExpression($inExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkInExpression($inExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkInstanceOfExpression($instanceOfExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkInstanceOfExpression($instanceOfExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkLiteral($literal) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkLiteral($literal); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkBetweenExpression($betweenExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkBetweenExpression($betweenExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkLikeExpression($likeExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkLikeExpression($likeExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkStateFieldPathExpression($stateFieldPathExpression) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkStateFieldPathExpression($stateFieldPathExpression); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkComparisonExpression($compExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkComparisonExpression($compExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkInputParameter($inputParam) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkInputParameter($inputParam); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkArithmeticExpression($arithmeticExpr) + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void { foreach ($this->getWalkers() as $walker) { - $walker->walkArithmeticExpression($arithmeticExpr); + $walker->walkUpdateStatement($updateStatement); } } @@ -577,82 +81,13 @@ public function walkArithmeticExpression($arithmeticExpr) * * @return void */ - public function walkArithmeticTerm($term) + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void { foreach ($this->getWalkers() as $walker) { - $walker->walkArithmeticTerm($term); + $walker->walkDeleteStatement($deleteStatement); } } - /** - * {@inheritdoc} - * - * @return void - */ - public function walkStringPrimary($stringPrimary) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkStringPrimary($stringPrimary); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkArithmeticFactor($factor) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkArithmeticFactor($factor); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkSimpleArithmeticExpression($simpleArithmeticExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkPathExpression($pathExpr) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkPathExpression($pathExpr); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function walkResultVariable($resultVariable) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkResultVariable($resultVariable); - } - } - - /** - * {@inheritdoc} - * - * @return void - */ - public function getExecutor($AST) - { - } - /** * @psalm-return Generator */ diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index 22bea60510c..c2d0554a3f0 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -34,23 +34,13 @@ */ class CountOutputWalker extends SqlWalker { - /** @var AbstractPlatform */ - private $platform; - - /** @var ResultSetMapping */ - private $rsm; + private AbstractPlatform $platform; + private ResultSetMapping $rsm; /** - * Stores various parameters that are otherwise unavailable - * because Doctrine\ORM\Query\SqlWalker keeps everything private without - * accessors. - * - * @param Query $query - * @param ParserResult $parserResult - * @param mixed[] $queryComponents - * @psalm-param array $queryComponents + * {@inheritdoc} */ - public function __construct($query, $parserResult, array $queryComponents) + public function __construct(Query $query, ParserResult $parserResult, array $queryComponents) { $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform(); $this->rsm = $parserResult->getResultSetMapping(); @@ -65,11 +55,9 @@ public function __construct($query, $parserResult, array $queryComponents) * are able to cache subqueries. By keeping the ORDER BY clause intact, the limitSubQuery * that will most likely be executed next can be read from the native SQL cache. * - * @return string - * * @throws RuntimeException */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $AST): string { if ($this->platform instanceof SQLServerPlatform) { $AST->orderByClause = null; diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index 243d3c1e647..cc4c8a7d935 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -27,19 +27,16 @@ class CountWalker extends TreeWalkerAdapter /** * Walks down a SelectStatement AST node, modifying it to retrieve a COUNT. * - * @return void - * * @throws RuntimeException */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): void { - if ($AST->havingClause) { + if ($selectStatement->havingClause) { throw new RuntimeException('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); } - $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $selectStatement->fromClause->identificationVariableDeclarations; if (count($from) > 1) { throw new RuntimeException('Cannot count query which selects two FROM components, cannot make distinction'); @@ -47,7 +44,7 @@ public function walkSelectStatement(SelectStatement $AST) $fromRoot = reset($from); $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; - $rootClass = $queryComponents[$rootAlias]['metadata']; + $rootClass = $this->getMetadataForDqlAlias($rootAlias); $identifierFieldName = $rootClass->getSingleIdentifierFieldName(); $pathType = PathExpression::TYPE_STATE_FIELD; @@ -62,8 +59,8 @@ public function walkSelectStatement(SelectStatement $AST) ); $pathExpression->type = $pathType; - $distinct = $this->_getQuery()->getHint(self::HINT_DISTINCT); - $AST->selectClause->selectExpressions = [ + $distinct = $this->_getQuery()->getHint(self::HINT_DISTINCT); + $selectStatement->selectClause->selectExpressions = [ new SelectExpression( new AggregateExpression('count', $pathExpression, $distinct), null @@ -71,6 +68,6 @@ public function walkSelectStatement(SelectStatement $AST) ]; // ORDER BY is not needed, only increases query execution through unnecessary sorting. - $AST->orderByClause = null; + $selectStatement->orderByClause = null; } } diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 31c10f12a56..604b20b62bf 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\AST\SelectExpression; use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\AST\Subselect; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\ParserResult; use Doctrine\ORM\Query\QueryException; @@ -54,54 +55,39 @@ class LimitSubqueryOutputWalker extends SqlWalker { private const ORDER_BY_PATH_EXPRESSION = '/(? */ - private $orderByPathExpressions = []; + private array $orderByPathExpressions = []; /** - * @var bool We don't want to add path expressions from sub-selects into the select clause of the containing query. - * This state flag simply keeps track on whether we are walking on a subquery or not + * We don't want to add path expressions from sub-selects into the select clause of the containing query. + * This state flag simply keeps track on whether we are walking on a subquery or not */ - private $inSubSelect = false; + private bool $inSubSelect = false; /** * Stores various parameters that are otherwise unavailable * because Doctrine\ORM\Query\SqlWalker keeps everything private without * accessors. * - * @param Query $query - * @param ParserResult $parserResult - * @param mixed[] $queryComponents - * @psalm-param array $queryComponents + * {@inheritdoc} */ - public function __construct($query, $parserResult, array $queryComponents) - { + public function __construct( + Query $query, + ParserResult $parserResult, + array $queryComponents + ) { $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform(); $this->rsm = $parserResult->getResultSetMapping(); // Reset limit and offset - $this->firstResult = $query->getFirstResult(); + $this->firstResult = $query->getFirstResult() ?? 0; $this->maxResults = $query->getMaxResults(); $query->setFirstResult(null)->setMaxResults(null); @@ -155,11 +141,9 @@ private function rebuildOrderByForRowNumber(SelectStatement $AST): void /** * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT. * - * @return string - * * @throws RuntimeException */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $AST): string { if ($this->platformSupportsRowNumber()) { return $this->walkSelectStatementWithRowNumber($AST); @@ -172,11 +156,9 @@ public function walkSelectStatement(SelectStatement $AST) * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT. * This method is for use with platforms which support ROW_NUMBER. * - * @return string - * * @throws RuntimeException */ - public function walkSelectStatementWithRowNumber(SelectStatement $AST) + public function walkSelectStatementWithRowNumber(SelectStatement $AST): string { $hasOrderBy = false; $outerOrderBy = ' ORDER BY dctrn_minrownum ASC'; @@ -228,13 +210,9 @@ public function walkSelectStatementWithRowNumber(SelectStatement $AST) * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT. * This method is for platforms which DO NOT support ROW_NUMBER. * - * @param bool $addMissingItemsFromOrderByToSelect - * - * @return string - * * @throws RuntimeException */ - public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, $addMissingItemsFromOrderByToSelect = true) + public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, bool $addMissingItemsFromOrderByToSelect = true): string { // We don't want to call this recursively! if ($AST->orderByClause instanceof OrderByClause && $addMissingItemsFromOrderByToSelect) { @@ -463,7 +441,7 @@ private function generateSqlAliasReplacements(): array * * @return list */ - public function getOrderByPathExpressions() + public function getOrderByPathExpressions(): array { return $this->orderByPathExpressions; } @@ -551,10 +529,7 @@ private function getSQLIdentifier(SelectStatement $AST): array return $sqlIdentifier; } - /** - * {@inheritdoc} - */ - public function walkPathExpression($pathExpr) + public function walkPathExpression(PathExpression $pathExpr): string { if (! $this->inSubSelect && ! $this->platformSupportsRowNumber() && ! in_array($pathExpr, $this->orderByPathExpressions, true)) { $this->orderByPathExpressions[] = $pathExpr; @@ -563,10 +538,7 @@ public function walkPathExpression($pathExpr) return parent::walkPathExpression($pathExpr); } - /** - * {@inheritdoc} - */ - public function walkSubSelect($subselect) + public function walkSubSelect(Subselect $subselect): string { $this->inSubSelect = true; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index e7fb59bffb5..77a57bd1d10 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -30,29 +30,25 @@ class LimitSubqueryWalker extends TreeWalkerAdapter /** * Counter for generating unique order column aliases. - * - * @var int */ - private $_aliasCounter = 0; + private int $aliasCounter = 0; /** * Walks down a SelectStatement AST node, modifying it to retrieve DISTINCT ids * of the root Entity. * - * @return void - * * @throws RuntimeException */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): void { - $queryComponents = $this->_getQueryComponents(); + $queryComponents = $this->getQueryComponents(); // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $selectStatement->fromClause->identificationVariableDeclarations; $fromRoot = reset($from); $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; - $rootClass = $queryComponents[$rootAlias]['metadata']; + $rootClass = $this->getMetadataForDqlAlias($rootAlias); - $this->validate($AST); + $this->validate($selectStatement); $identifier = $rootClass->getSingleIdentifierFieldName(); if (isset($rootClass->associationMappings[$identifier])) { @@ -74,18 +70,18 @@ public function walkSelectStatement(SelectStatement $AST) $pathExpression->type = PathExpression::TYPE_STATE_FIELD; - $AST->selectClause->selectExpressions = [new SelectExpression($pathExpression, '_dctrn_id')]; - $AST->selectClause->isDistinct = true; + $selectStatement->selectClause->selectExpressions = [new SelectExpression($pathExpression, '_dctrn_id')]; + $selectStatement->selectClause->isDistinct = true; - if (! isset($AST->orderByClause)) { + if (! isset($selectStatement->orderByClause)) { return; } - foreach ($AST->orderByClause->orderByItems as $item) { + foreach ($selectStatement->orderByClause->orderByItems as $item) { if ($item->expression instanceof PathExpression) { - $AST->selectClause->selectExpressions[] = new SelectExpression( + $selectStatement->selectClause->selectExpressions[] = new SelectExpression( $this->createSelectExpressionItem($item->expression), - '_dctrn_ord' . $this->_aliasCounter++ + '_dctrn_ord' . $this->aliasCounter++ ); continue; @@ -95,7 +91,7 @@ public function walkSelectStatement(SelectStatement $AST) $qComp = $queryComponents[$item->expression]; if (isset($qComp['resultVariable'])) { - $AST->selectClause->selectExpressions[] = new SelectExpression( + $selectStatement->selectClause->selectExpressions[] = new SelectExpression( $qComp['resultVariable'], $item->expression ); diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index 4915774eee2..c53846c71fd 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Tools\Pagination; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\AST\ArithmeticExpression; use Doctrine\ORM\Query\AST\ConditionalExpression; use Doctrine\ORM\Query\AST\ConditionalFactor; @@ -51,24 +50,20 @@ class WhereInWalker extends TreeWalkerAdapter * The total number of parameters is retrieved from * the HINT_PAGINATOR_ID_COUNT query hint. * - * @return void - * * @throws RuntimeException */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): void { - $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $selectStatement->fromClause->identificationVariableDeclarations; if (count($from) > 1) { throw new RuntimeException('Cannot count query which selects two FROM components, cannot make distinction'); } - $fromRoot = reset($from); - $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; - $rootClass = $queryComponents[$rootAlias]['metadata']; - assert($rootClass instanceof ClassMetadata); + $fromRoot = reset($from); + $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; + $rootClass = $this->getMetadataForDqlAlias($rootAlias); $identifierFieldName = $rootClass->getSingleIdentifierFieldName(); $pathType = PathExpression::TYPE_STATE_FIELD; @@ -104,27 +99,27 @@ public function walkSelectStatement(SelectStatement $AST) $conditionalPrimary = new ConditionalPrimary(); $conditionalPrimary->simpleConditionalExpression = $expression; - if ($AST->whereClause) { - if ($AST->whereClause->conditionalExpression instanceof ConditionalTerm) { - $AST->whereClause->conditionalExpression->conditionalFactors[] = $conditionalPrimary; - } elseif ($AST->whereClause->conditionalExpression instanceof ConditionalPrimary) { - $AST->whereClause->conditionalExpression = new ConditionalExpression( + if ($selectStatement->whereClause) { + if ($selectStatement->whereClause->conditionalExpression instanceof ConditionalTerm) { + $selectStatement->whereClause->conditionalExpression->conditionalFactors[] = $conditionalPrimary; + } elseif ($selectStatement->whereClause->conditionalExpression instanceof ConditionalPrimary) { + $selectStatement->whereClause->conditionalExpression = new ConditionalExpression( [ new ConditionalTerm( [ - $AST->whereClause->conditionalExpression, + $selectStatement->whereClause->conditionalExpression, $conditionalPrimary, ] ), ] ); } elseif ( - $AST->whereClause->conditionalExpression instanceof ConditionalExpression - || $AST->whereClause->conditionalExpression instanceof ConditionalFactor + $selectStatement->whereClause->conditionalExpression instanceof ConditionalExpression + || $selectStatement->whereClause->conditionalExpression instanceof ConditionalFactor ) { - $tmpPrimary = new ConditionalPrimary(); - $tmpPrimary->conditionalExpression = $AST->whereClause->conditionalExpression; - $AST->whereClause->conditionalExpression = new ConditionalTerm( + $tmpPrimary = new ConditionalPrimary(); + $tmpPrimary->conditionalExpression = $selectStatement->whereClause->conditionalExpression; + $selectStatement->whereClause->conditionalExpression = new ConditionalTerm( [ $tmpPrimary, $conditionalPrimary, @@ -132,7 +127,7 @@ public function walkSelectStatement(SelectStatement $AST) ); } } else { - $AST->whereClause = new WhereClause( + $selectStatement->whereClause = new WhereClause( new ConditionalExpression( [new ConditionalTerm([$conditionalPrimary])] ) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 60481e3ec8b..4b7ec7ba369 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -570,21 +570,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php - - - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php - - - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\AST\\\\IndexBy\\:\\:dispatch\\(\\) should return string but returns void\\.$#" count: 1 @@ -700,11 +685,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php - - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Elseif branch is unreachable because previous condition is always true\\.$#" count: 2 @@ -721,7 +701,7 @@ parameters: path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkConditionalPrimary\\(\\) should return string but return statement is missing\\.$#" + message: "#^Match arm is unreachable because previous comparison is always true\\.$#" count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php @@ -736,479 +716,14 @@ parameters: path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Result of && is always false\\.$#" - count: 2 - path: lib/Doctrine/ORM/Query/SqlWalker.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:getExecutor\\(\\) should be compatible with return type \\(Doctrine\\\\ORM\\\\Query\\\\Exec\\\\AbstractSqlExecutor\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:getExecutor\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkAggregateExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkAggregateExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkArithmeticExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkArithmeticExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkArithmeticFactor\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkArithmeticFactor\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkArithmeticTerm\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkArithmeticTerm\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkBetweenExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkBetweenExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkCollectionMemberExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkCollectionMemberExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkComparisonExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkComparisonExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkConditionalExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkConditionalFactor\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalFactor\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkConditionalPrimary\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalPrimary\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkConditionalTerm\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalTerm\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkDeleteClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkDeleteClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkDeleteStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkDeleteStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkEmptyCollectionComparisonExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkEmptyCollectionComparisonExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkExistsExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkExistsExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkFromClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkFromClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkFunction\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkFunction\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkGroupByClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkGroupByClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkGroupByItem\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkGroupByItem\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkHavingClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkHavingClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkInExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkInExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkInputParameter\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkInputParameter\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkInstanceOfExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkInstanceOfExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkJoin\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkJoin\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkLikeExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkLikeExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkLiteral\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkLiteral\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkNullComparisonExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkNullComparisonExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkOrderByClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkOrderByClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkOrderByItem\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkOrderByItem\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkPathExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkPathExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkQuantifiedExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkQuantifiedExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkResultVariable\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkResultVariable\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSelectClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSelectExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSelectStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSimpleArithmeticExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSimpleArithmeticExpression\\(\\)$#" + message: "#^Parameter \\#3 \\$condExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkJoinAssociationDeclaration\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalPrimary\\|null, Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalExpression\\|null given\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSimpleSelectClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSimpleSelectClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSimpleSelectExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSimpleSelectExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkStateFieldPathExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkStateFieldPathExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkStringPrimary\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkStringPrimary\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSubselect\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSubselect\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkSubselectFromClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSubselectFromClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkUpdateClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkUpdateClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkUpdateItem\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkUpdateItem\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkUpdateStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkUpdateStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:walkWhereClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkWhereClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:getExecutor\\(\\) should be compatible with return type \\(Doctrine\\\\ORM\\\\Query\\\\Exec\\\\AbstractSqlExecutor\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:getExecutor\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkAggregateExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkAggregateExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkArithmeticExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkArithmeticExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkArithmeticFactor\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkArithmeticFactor\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkArithmeticTerm\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkArithmeticTerm\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkBetweenExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkBetweenExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkCollectionMemberExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkCollectionMemberExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkComparisonExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkComparisonExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkConditionalExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkConditionalFactor\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalFactor\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkConditionalPrimary\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalPrimary\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkConditionalTerm\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkConditionalTerm\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkDeleteClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkDeleteClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkDeleteStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkDeleteStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkEmptyCollectionComparisonExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkEmptyCollectionComparisonExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkExistsExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkExistsExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkFromClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkFromClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkFunction\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkFunction\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkGroupByClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkGroupByClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkGroupByItem\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkGroupByItem\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkHavingClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkHavingClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkInExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkInExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkInputParameter\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkInputParameter\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkInstanceOfExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkInstanceOfExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkJoin\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkJoin\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkLikeExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkLikeExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkLiteral\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkLiteral\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkNullComparisonExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkNullComparisonExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkOrderByClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkOrderByClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkOrderByItem\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkOrderByItem\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkPathExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkPathExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkQuantifiedExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkQuantifiedExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkResultVariable\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkResultVariable\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSelectClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSelectExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSelectStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSimpleArithmeticExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSimpleArithmeticExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSimpleSelectClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSimpleSelectClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSimpleSelectExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSimpleSelectExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkStateFieldPathExpression\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkStateFieldPathExpression\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkStringPrimary\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkStringPrimary\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSubselect\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSubselect\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkSubselectFromClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSubselectFromClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkUpdateClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkUpdateClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkUpdateItem\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkUpdateItem\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkUpdateStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkUpdateStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php + path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:walkWhereClause\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkWhereClause\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php + message: "#^Result of && is always false\\.$#" + count: 2 + path: lib/Doctrine/ORM/Query/SqlWalker.php - message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, non\\-empty\\-array\\ given\\.$#" @@ -1225,16 +740,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Tools\\\\Pagination\\\\CountWalker\\:\\:walkSelectStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Pagination/CountWalker.php - - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Tools\\\\Pagination\\\\LimitSubqueryWalker\\:\\:walkSelectStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php - - message: "#^Instanceof between \\*NEVER\\* and Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalFactor will always evaluate to false\\.$#" count: 1 @@ -1250,11 +755,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php - - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Tools\\\\Pagination\\\\WhereInWalker\\:\\:walkSelectStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectStatement\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" count: 1 @@ -1314,3 +814,4 @@ parameters: message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#" count: 1 path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9598b2193bd..63e38dbd7a3 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1394,9 +1394,6 @@ - - $this->stringPrimary - $stringPrimary @@ -1414,9 +1411,6 @@ - - $this->stringPrimary - $stringPrimary @@ -1490,9 +1484,6 @@ - - $this->stringPrimary - $stringPrimary @@ -2068,22 +2059,15 @@ $likeExpr->stringPattern instanceof AST\Functions\FunctionNode $likeExpr->stringPattern instanceof AST\PathExpression - '' + $this->conn->quote($newValue) is_string($expression) is_string($stringExpr) - - $expr - - - $condExpr - $condTerm - $factor + + $join->conditionalExpression + $likeExpr->stringPattern $selectedClass['class']->name - - walkConditionalPrimary - $this->scalarResultAliasMap $this->scalarResultAliasMap @@ -2092,245 +2076,38 @@ $this->scalarResultAliasMap $this->scalarResultAliasMap $this->scalarResultAliasMap + $this->scalarResultAliasMap - + $resultAlias $resultAlias $resultAlias $resultAlias + + + $expr $this->queryComponents[$expr]['token']['value'] $this->queryComponents[$factor]['token']['value'] $this->queryComponents[$term]['token']['value'] - - - $query - - - $aggExpression->pathExpression - $whereClause->conditionalExpression - - $AST->whereClause - $AST->whereClause - $AST->whereClause + $arithmeticExpr->simpleArithmeticExpression $arithmeticExpr->subselect $condExpr $identificationVariableDecl->rangeVariableDeclaration - $subselect->whereClause $this->scalarResultAliasMap $this->scalarResultAliasMap + $this->scalarResultAliasMap dispatch - + $likeExpr->stringPattern instanceof AST\InputParameter - $whereClause !== null - ($factor->not ? 'NOT ' : '') . $this->walkConditionalPrimary($factor->conditionalPrimary) - - - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - - - $AST - $aggExpression - $arithmeticExpr - $betweenExpr - $collMemberExpr - $compExpr - $condExpr - $condTerm - $emptyCollCompExpr - $existsExpr - $factor - $factor - $fromClause - $function - $groupByClause - $groupByItem - $havingClause - $inExpr - $inputParam - $instanceOfExpr - $join - $likeExpr - $literal - $nullCompExpr - $orderByClause - $orderByItem - $pathExpr - $primary - $qExpr - $resultVariable - $selectClause - $selectExpression - $simpleArithmeticExpr - $simpleSelectClause - $simpleSelectExpression - $stateFieldPathExpression - $stringPrimary - $subselect - $subselectFromClause - $term - $updateClause - $updateItem - $whereClause - - - _getQueryComponents - - - - - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - void - - - $AST - $aggExpression - $arithmeticExpr - $betweenExpr - $collMemberExpr - $compExpr - $condExpr - $condPrimary - $condTerm - $dqlAlias - $emptyCollCompExpr - $existsExpr - $factor - $factor - $fromClause - $function - $groupByClause - $groupByItem - $havingClause - $inExpr - $inputParam - $instanceOfExpr - $join - $likeExpr - $literal - $nullCompExpr - $orderByClause - $orderByItem - $pathExpr - $qExpr - $resultVariable - $selectClause - $selectExpression - $simpleArithmeticExpr - $simpleSelectClause - $simpleSelectExpression - $stateFieldPathExpression - $stringPrimary - $subselect - $subselectFromClause - $term - $updateClause - $updateItem - $whereClause - - - $condPrimary - - [$rootAlias => $join] @@ -2427,40 +2204,20 @@ $state === UnitOfWork::STATE_DETACHED - - - $query - - - - - void - - - - $query - strrpos($orderByItemString, ' ') $orderByClause->orderByItems - + $AST->orderByClause - $query->getFirstResult() - $query->getMaxResults() $orderByClause->orderByItems - - - void - - $parameters @@ -2482,17 +2239,14 @@ - $AST->whereClause->conditionalExpression instanceof ConditionalFactor - $AST->whereClause->conditionalExpression instanceof ConditionalPrimary + $selectStatement->whereClause->conditionalExpression instanceof ConditionalFactor + $selectStatement->whereClause->conditionalExpression instanceof ConditionalPrimary - - void - static function ($id) use ($connection, $type) { - $AST->whereClause->conditionalExpression + $selectStatement->whereClause->conditionalExpression diff --git a/tests/Doctrine/Tests/Mocks/MockSqlWalker.php b/tests/Doctrine/Tests/Mocks/MockSqlWalker.php new file mode 100644 index 00000000000..5d35a3acfa0 --- /dev/null +++ b/tests/Doctrine/Tests/Mocks/MockSqlWalker.php @@ -0,0 +1,19 @@ +walkSelectClause($AST->selectClause); - } + $selectClause = $selectStatement->selectClause; - /** - * {@inheritdoc} - */ - public function walkSelectClause($selectClause): void - { - assert($selectClause instanceof SelectClause); foreach ($selectClause->selectExpressions as $key => $selectExpr) { assert($selectExpr instanceof SelectExpression); if ($selectExpr->expression === 'c') { diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index 469e7724e71..71359c71577 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -112,11 +112,13 @@ public function testSupportsSeveralHintsQueries(): void class AddUnknownQueryComponentWalker extends Query\SqlWalker { - public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): void + public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): string { - parent::walkSelectStatement($selectStatement); + $sql = parent::walkSelectStatement($selectStatement); $this->setQueryComponent('x', []); + + return $sql; } } @@ -127,7 +129,7 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): // Get the DQL aliases of all the classes we want to modify $dqlAliases = []; - foreach ($this->_getQueryComponents() as $dqlAlias => $comp) { + foreach ($this->getQueryComponents() as $dqlAlias => $comp) { // Hard-coded check just for demonstration: We want to modify the query if // it involves the CmsUser class. if ($comp['metadata']->name === CmsUser::class) { diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 4a124c309b5..4a2b70b85d9 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Query; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -13,49 +12,29 @@ use Doctrine\ORM\Query; use Doctrine\ORM\Query\ParserResult; use Doctrine\ORM\Query\QueryException; -use Doctrine\Tests\Mocks\MockTreeWalker; +use Doctrine\Tests\Mocks\EntityManagerMock; +use Doctrine\Tests\Mocks\MockSqlWalker; use Doctrine\Tests\OrmTestCase; -use const PHP_EOL; - class LanguageRecognitionTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerMock $entityManager; protected function setUp(): void { $this->entityManager = $this->getTestEntityManager(); } - public function assertValidDQL($dql, $debug = false): void + public function assertValidDQL(string $dql): void { - try { - $parserResult = $this->parseDql($dql); - $this->addToAssertionCount(1); - } catch (QueryException $e) { - if ($debug) { - echo $e->getTraceAsString() . PHP_EOL; - } - - self::fail($e->getMessage()); - } + $this->parseDql($dql); + $this->addToAssertionCount(1); } - public function assertInvalidDQL($dql, $debug = false): void + public function assertInvalidDQL(string $dql): void { - try { - $parserResult = $this->parseDql($dql); - - self::fail('No syntax errors were detected, when syntax errors were expected'); - } catch (QueryException $e) { - if ($debug) { - echo $e->getMessage() . PHP_EOL; - echo $e->getTraceAsString() . PHP_EOL; - } - - $this->addToAssertionCount(1); - } + $this->expectException(QueryException::class); + $this->parseDql($dql); } /** @@ -74,7 +53,7 @@ public function parseDql(string $dql, array $hints = []): ParserResult $parser = new Query\Parser($query); // We do NOT test SQL output here. That only unnecessarily slows down the tests! - $parser->setCustomOutputTreeWalker(MockTreeWalker::class); + $parser->setCustomOutputTreeWalker(MockSqlWalker::class); return $parser->parse(); } diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index c649c133ee1..00a4a0fd72a 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -10,7 +10,6 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Types\Type as DBALType; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -23,6 +22,7 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; use Doctrine\Tests\DbalTypes\NegativeToPositiveType; +use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\Company\CompanyEmployee; @@ -35,8 +35,7 @@ class SelectSqlGenerationTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerMock $entityManager; protected function setUp(): void {