Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -23,7 +24,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('ARRAY[%s]');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function feedParserWithNodes(Parser $parser): void
$lookaheadType = DoctrineLexer::getLookaheadType($lexer);
}

$this->validateArguments($this->nodes);
$this->validateArguments(...$this->nodes); // @phpstan-ignore-line
}

public function getSql(SqlWalker $sqlWalker): string
Expand All @@ -67,9 +67,7 @@ public function getSql(SqlWalker $sqlWalker): string
/**
* Validates the arguments passed to the function.
*
* @param mixed[] $arguments The array of arguments to validate
*
* @throws InvalidArgumentForVariadicFunctionException
*/
abstract protected function validateArguments(array $arguments): void;
abstract protected function validateArguments(Node ...$arguments): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -21,7 +22,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('greatest(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount < 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -21,7 +22,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('json_build_object(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount === 0 || $argumentCount % 2 !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -21,7 +22,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('jsonb_build_object(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount === 0 || $argumentCount % 2 !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -21,7 +22,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('least(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount < 2) {
Expand Down
3 changes: 2 additions & 1 deletion src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -20,7 +21,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('ROW(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -21,7 +22,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('to_tsquery(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount < 1 || $argumentCount > 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -23,7 +24,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('to_tsvector(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount < 1 || $argumentCount > 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;

/**
Expand All @@ -22,7 +23,7 @@ protected function customizeFunction(): void
$this->setFunctionPrototype('unaccent(%s)');
}

protected function validateArguments(array $arguments): void
protected function validateArguments(Node ...$arguments): void
{
$argumentCount = \count($arguments);
if ($argumentCount < 1 || $argumentCount > 2) {
Expand Down
Loading