Skip to content

Commit

Permalink
inline DbalExpressionResult properties into constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Mar 20, 2024
1 parent 76f7355 commit 48f1127
Showing 1 changed file with 18 additions and 64 deletions.
82 changes: 18 additions & 64 deletions src/Collection/Functions/Result/DbalExpressionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,87 +24,41 @@
class DbalExpressionResult
{
/**
* Holds expression separately from its arguments.
* @var literal-string
*/
public readonly string $expression;

/**
* Expression's arguments.
* @var list<mixed>
*/
public readonly mixed $args;

/**
* @var DbalTableJoin[]
*/
public readonly array $joins;

/**
* Result aggregator.
* @var Aggregator<mixed>|null
*/
public readonly ?Aggregator $aggregator;

/**
* Bool if the expression will be incorporated into WHERE or HAVING clause.
*/
public readonly bool $isHavingClause;

/**
* Reference to backing property of the expression.
* If null, the expression is no more a simple property expression.
*/
public readonly ?PropertyMetadata $propertyMetadata;

/**
* Dbal modifier for particular column. Null if expression is a general expression.
* @var literal-string|null
* Normalizes the value for better PHP comparison, it considers the backing property type.
* @var (callable(mixed): mixed)|null
*/
public readonly ?string $dbalModifier;
public readonly mixed $valueNormalizer;


/**
* @param literal-string $expression
* @param list<mixed> $args
* @param DbalTableJoin[] $joins
* @param literal-string $expression Holds expression separately from its arguments. Put Dbal's modifiers into the expression and arguments separately.
* @param list<mixed> $args Expression's arguments.
* @param list<DbalTableJoin> $joins
* @param list<Fqn> $groupBy List of columns used for grouping.
* @param list<Fqn> $columns List of columns used in the expression. If needed, this is later used to properly reference in GROUP BY clause.
* @param Aggregator<mixed>|null $aggregator
* @param bool $isHavingClause
* @param literal-string|null $dbalModifier
* @param Aggregator<mixed>|null $aggregator Result aggregator that is applied later.
* @param bool $isHavingClause True if the expression represents HAVING clause instead of WHERE clause.
* @param PropertyMetadata|null $propertyMetadata Reference to backing property of the expression. If null, the expression is no more a simple property expression.
* @param (callable(mixed): mixed)|null $valueNormalizer Normalizes the value for better PHP comparison, it considers the backing property type.
* @param literal-string|null $dbalModifier Dbal modifier for particular column. Null if expression is a general expression.
*/
public function __construct(
string $expression,
array $args,
array $joins = [],
public readonly string $expression,
public readonly array $args,
public readonly array $joins = [],
public readonly array $groupBy = [],
public readonly array $columns = [],
?Aggregator $aggregator = null,
bool $isHavingClause = false,
?PropertyMetadata $propertyMetadata = null,
public readonly ?Aggregator $aggregator = null,
public readonly bool $isHavingClause = false,
public readonly ?PropertyMetadata $propertyMetadata = null,
?callable $valueNormalizer = null,
?string $dbalModifier = null,
public readonly ?string $dbalModifier = null,
)
{
$this->expression = $expression;
$this->args = $args;
$this->aggregator = $aggregator;
$this->joins = $joins;
$this->isHavingClause = $isHavingClause;
$this->propertyMetadata = $propertyMetadata;
$this->valueNormalizer = $valueNormalizer;
$this->dbalModifier = $dbalModifier;
}


/**
* Value normalizer callback for proper matching backing property type.
* @var (callable(mixed): mixed)|null
*/
public readonly mixed $valueNormalizer;


/**
* Appends SQL expression to the original expression.
* If you need prepend or other complex expression, create new instance of DbalExpressionResult.
Expand Down

0 comments on commit 48f1127

Please sign in to comment.