diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php index 9e4b7ad2a5c..0930faf2616 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php @@ -19,16 +19,14 @@ class AbsFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $simpleArithmeticExpression; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression( $this->simpleArithmeticExpression, ) . ')'; } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php index a0b0ca5e527..ba7b7f35055 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php @@ -13,8 +13,7 @@ */ final class AvgFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php index a0988bb1b30..1f67866c536 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php @@ -16,14 +16,10 @@ */ class BitAndFunction extends FunctionNode { - /** @var Node */ - public $firstArithmetic; + public Node $firstArithmetic; + public Node $secondArithmetic; - /** @var Node */ - public $secondArithmetic; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -33,8 +29,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php index 08bca26e707..49d29a982cf 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php @@ -16,14 +16,10 @@ */ class BitOrFunction extends FunctionNode { - /** @var Node */ - public $firstArithmetic; + public Node $firstArithmetic; + public Node $secondArithmetic; - /** @var Node */ - public $secondArithmetic; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -33,8 +29,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php index b2101650be0..4c530bbda9f 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -16,17 +16,13 @@ */ class ConcatFunction extends FunctionNode { - /** @var Node */ - public $firstStringPrimary; - - /** @var Node */ - public $secondStringPrimary; + public Node $firstStringPrimary; + public Node $secondStringPrimary; /** @psalm-var list */ public $concatExpressions = []; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -39,8 +35,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getConcatExpression(...$args); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php index a7e0c18c9d6..dc926a52a2b 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php @@ -16,8 +16,7 @@ */ final class CountFunction extends FunctionNode implements TypedExpression { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php index a1dc659a217..4c585d40c23 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php @@ -15,14 +15,12 @@ */ class CurrentDateFunction extends FunctionNode { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSQL(); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php index a27b6732af8..7cf2841129a 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php @@ -15,14 +15,12 @@ */ class CurrentTimeFunction extends FunctionNode { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSQL(); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php index 74a9883168c..96d564be452 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php @@ -15,14 +15,12 @@ */ class CurrentTimestampFunction extends FunctionNode { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSQL(); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php index 2c21fdf1097..aaed131184e 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -22,66 +22,45 @@ */ class DateAddFunction extends FunctionNode { - /** @var Node */ - public $firstDateExpression = null; + public Node $firstDateExpression; + public Node $intervalExpression; + public Node $unit; - /** @var Node */ - public $intervalExpression = null; - - /** @var Node */ - public $unit = null; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { - switch (strtolower($this->unit->value)) { - case 'second': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddSecondsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'minute': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMinutesExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'hour': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'day': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'week': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddWeeksExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'month': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'year': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddYearsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - default: - throw QueryException::semanticalError( - 'DATE_ADD() only supports units of type second, minute, hour, day, week, month and year.', - ); - } + return match (strtolower((string) $this->unit->value)) { + 'second' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddSecondsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'minute' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMinutesExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'hour' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'day' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'week' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddWeeksExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'month' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'year' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddYearsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + default => throw QueryException::semanticalError( + 'DATE_ADD() only supports units of type second, minute, hour, day, week, month and year.', + ), + }; } /** @@ -97,8 +76,7 @@ private function dispatchIntervalExpression(SqlWalker $sqlWalker) return $sql; } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php index c082ab9cc4e..bbd73c47df6 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php @@ -16,14 +16,10 @@ */ class DateDiffFunction extends FunctionNode { - /** @var Node */ - public $date1; + public Node $date1; + public Node $date2; - /** @var Node */ - public $date2; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getDateDiffExpression( $this->date1->dispatch($sqlWalker), @@ -31,8 +27,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php index 45830268ebb..254f1219277 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php @@ -19,57 +19,41 @@ */ class DateSubFunction extends DateAddFunction { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { - switch (strtolower($this->unit->value)) { - case 'second': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubSecondsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'minute': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMinutesExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'hour': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'day': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'week': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubWeeksExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'month': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMonthExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'year': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubYearsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - default: - throw QueryException::semanticalError( - 'DATE_SUB() only supports units of type second, minute, hour, day, week, month and year.', - ); - } + return match (strtolower((string) $this->unit->value)) { + 'second' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubSecondsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'minute' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMinutesExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'hour' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'day' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'week' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubWeeksExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'month' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMonthExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'year' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubYearsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + default => throw QueryException::semanticalError( + 'DATE_SUB() only supports units of type second, minute, hour, day, week, month and year.', + ), + }; } /** @@ -77,7 +61,7 @@ public function getSql(SqlWalker $sqlWalker) * * @throws ASTException */ - private function dispatchIntervalExpression(SqlWalker $sqlWalker) + private function dispatchIntervalExpression(SqlWalker $sqlWalker): string { $sql = $this->intervalExpression->dispatch($sqlWalker); assert(is_numeric($sql)); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php index 6318d539d03..4cc549e7cd4 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php @@ -17,19 +17,16 @@ */ abstract class FunctionNode extends Node { - /** @param string $name */ - public function __construct(public $name) + public function __construct(public string $name) { } - /** @return string */ - abstract public function getSql(SqlWalker $sqlWalker); + abstract public function getSql(SqlWalker $sqlWalker): string; public function dispatch(SqlWalker $sqlWalker): string { return $sqlWalker->walkFunction($this); } - /** @return void */ - abstract public function parse(Parser $parser); + abstract public function parse(Parser $parser): void; } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index be00521ee26..74726e17b49 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -27,10 +27,7 @@ class IdentityFunction extends FunctionNode /** @var string|null */ public $fieldMapping; - /** - * {@inheritdoc} - */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { assert($this->pathExpression->field !== null); $entityManager = $sqlWalker->getEntityManager(); @@ -72,10 +69,7 @@ public function getSql(SqlWalker $sqlWalker) return $tableAlias . '.' . $columnName; } - /** - * {@inheritdoc} - */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php index fa0cb502fe5..ad9dcf8d4c3 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php @@ -19,19 +19,16 @@ */ class LengthFunction extends FunctionNode implements TypedExpression { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getLengthExpression( $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php index b62587917ba..b9fe10d6ea9 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php @@ -17,17 +17,13 @@ */ class LocateFunction extends FunctionNode { - /** @var Node */ - public $firstStringPrimary; - - /** @var Node */ - public $secondStringPrimary; + public Node $firstStringPrimary; + public Node $secondStringPrimary; /** @var SimpleArithmeticExpression|bool */ public $simpleArithmeticExpression = false; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -45,8 +41,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getLocateExpression($secondString, $firstString); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php index e548d843ee3..65afff783cf 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php @@ -18,11 +18,9 @@ */ class LowerFunction extends FunctionNode { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return sprintf( 'LOWER(%s)', @@ -30,8 +28,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php index a08e33413e0..8a6eecf3031 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php @@ -13,8 +13,7 @@ */ final class MaxFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php index 83cc3ac27e9..98d73a2825e 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php @@ -13,8 +13,7 @@ */ final class MinFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php index af5aa535889..d4529aeffee 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -22,8 +22,7 @@ class ModFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $secondSimpleArithmeticExpression; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getModExpression( $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), @@ -31,8 +30,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 5ecc2486a68..e59818ad2ce 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -26,7 +26,7 @@ class SizeFunction extends FunctionNode * @inheritdoc * @todo If the collection being counted is already joined, the SQL can be simpler (more efficient). */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { assert($this->collectionPathExpression->field !== null); $entityManager = $sqlWalker->getEntityManager(); @@ -102,8 +102,7 @@ public function getSql(SqlWalker $sqlWalker) return '(' . $sql . ')'; } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php index b5e04ad1201..1f74392f5bc 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php @@ -21,8 +21,7 @@ class SqrtFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $simpleArithmeticExpression; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return sprintf( 'SQRT(%s)', @@ -30,8 +29,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php index 6b758e4b6fc..89e45ebe111 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php @@ -17,8 +17,7 @@ */ class SubstringFunction extends FunctionNode { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; /** @var SimpleArithmeticExpression */ public $firstSimpleArithmeticExpression; @@ -26,8 +25,7 @@ class SubstringFunction extends FunctionNode /** @var SimpleArithmeticExpression|null */ public $secondSimpleArithmeticExpression = null; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $optionalSecondSimpleArithmeticExpression = null; if ($this->secondSimpleArithmeticExpression !== null) { @@ -41,8 +39,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php index c317c018e90..588dce9775a 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php @@ -13,8 +13,7 @@ */ final class SumFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index 370b225ab2e..b0436e00a40 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -19,25 +19,13 @@ */ class TrimFunction extends FunctionNode { - /** @var bool */ - public $leading; + public bool $leading = false; + public bool $trailing = false; + public bool $both = false; + public string|false $trimChar = false; + public Node $stringPrimary; - /** @var bool */ - public $trailing; - - /** @var bool */ - public $both; - - /** @var string|false */ - public $trimChar = false; - - /** @var Node */ - public $stringPrimary; - - /** - * {@inheritdoc} - */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $stringPrimary = $sqlWalker->walkStringPrimary($this->stringPrimary); $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -54,10 +42,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getTrimExpression($stringPrimary, $trimMode); } - /** - * {@inheritdoc} - */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $lexer = $parser->getLexer(); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php index 65a30b2ecf7..3f1cd6b3333 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php @@ -18,11 +18,9 @@ */ class UpperFunction extends FunctionNode { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return sprintf( 'UPPER(%s)', @@ -30,8 +28,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php b/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php index 44c0cb8fc1c..a0fdd012dbc 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php +++ b/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php @@ -19,11 +19,9 @@ */ class RowNumberOverFunction extends FunctionNode { - /** @var OrderByClause */ - public $orderByClause; + public OrderByClause $orderByClause; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return 'ROW_NUMBER() OVER(' . trim($sqlWalker->walkOrderByClause( $this->orderByClause, @@ -35,7 +33,7 @@ public function getSql(SqlWalker $sqlWalker) * * @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { throw RowNumberOverFunctionNotEnabled::create(); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d70c499cdc1..ad2f5c49ab0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -65,9 +65,6 @@ $cacheKeys->identifiers[$index] $cacheKeys->identifiers[$index] - - $id - $assocEntry->class $assocEntry->class @@ -316,6 +313,7 @@ ClassMetadata + ClassMetadata @@ -1039,11 +1037,11 @@ $parser->ArithmeticPrimary() $parser->ArithmeticPrimary() - - null - null - null - + + $firstDateExpression + $intervalExpression + $unit + $this->unit->value @@ -1059,6 +1057,11 @@ + + DateSubFunction + DateSubFunction + DateSubFunction + $this->unit->value @@ -1173,11 +1176,8 @@ $lexer->lookahead['value'] $lexer->token['value'] - - $both - $leading + $stringPrimary - $trailing