Skip to content

Commit

Permalink
Validate more variadic parameters (#11261)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Feb 13, 2024
1 parent b6f4220 commit 6290747
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Mapping/ChainTypedFieldMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\ORM\Internal\NoUnknownNamedArguments;
use ReflectionProperty;

final class ChainTypedFieldMapper implements TypedFieldMapper
{
/**
* @readonly
* @var TypedFieldMapper[] $typedFieldMappers
*/
use NoUnknownNamedArguments;

/** @var list<TypedFieldMapper> $typedFieldMappers */
private readonly array $typedFieldMappers;

public function __construct(TypedFieldMapper ...$typedFieldMappers)
{
self::validateVariadicParameter($typedFieldMappers);

$this->typedFieldMappers = $typedFieldMappers;
}

Expand Down
11 changes: 11 additions & 0 deletions src/Query/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\ORM\Query;

use Doctrine\ORM\Internal\NoUnknownNamedArguments;
use Traversable;

use function implode;
Expand All @@ -23,6 +24,8 @@
*/
class Expr
{
use NoUnknownNamedArguments;

/**
* Creates a conjunction of the given boolean expressions.
*
Expand All @@ -38,6 +41,8 @@ class Expr
*/
public function andX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x): Expr\Andx
{
self::validateVariadicParameter($x);

return new Expr\Andx($x);
}

Expand All @@ -56,6 +61,8 @@ public function andX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x):
*/
public function orX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x): Expr\Orx
{
self::validateVariadicParameter($x);

return new Expr\Orx($x);
}

Expand Down Expand Up @@ -225,6 +232,8 @@ public function count(mixed $x): Expr\Func
*/
public function countDistinct(mixed ...$x): string
{
self::validateVariadicParameter($x);

return 'COUNT(DISTINCT ' . implode(', ', $x) . ')';
}

Expand Down Expand Up @@ -470,6 +479,8 @@ public function notLike(string $x, mixed $y): Expr\Comparison
*/
public function concat(mixed ...$x): Expr\Func
{
self::validateVariadicParameter($x);

return new Expr\Func('CONCAT', $x);
}

Expand Down

0 comments on commit 6290747

Please sign in to comment.