forked from lexik/LexikFormFilterBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow array values for expression parameters
Fixes the problem described in lexik#364 where array values for parameters of filter expressions are misinterpreted as [value, type] pairs, throwing strange errors within Doctrine. When the value (with an optional type) is wrapped inside a `ExpressionParameterValue` value object, the `DoctrineApplyFilterListener` detects and used that explicit declaration. When the value is an array, it is checked if it contains a valid DBAL-type string on the second element, before it is assumed that it contains an implicit type decleration in that old array form. That branch can be deprecated in favor of the explicit declaration using the new `ExpressionParameterValue` class.
- Loading branch information
Showing
5 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace Lexik\Bundle\FormFilterBundle\Filter\Doctrine\Expression; | ||
|
||
/** | ||
* Holds the value and optionally the type of an expression parameter | ||
* used to distinguish an array of values from the former array holding a single value and a type string | ||
* | ||
* @author Gregor Meyer https://github.com/spackmat | ||
*/ | ||
final class ExpressionParameterValue | ||
{ | ||
/** | ||
* should be a public readonly mixed promoted property when PHP level is raised to PHP 8.1 | ||
* @var mixed | ||
*/ | ||
public $value; | ||
|
||
/** | ||
* should be a public readonly ?string promoted property when PHP level is raised to PHP 8.1 | ||
* @var ?string $type | ||
*/ | ||
public $type; | ||
|
||
public function __construct($value, ?string $type = null) | ||
{ | ||
$this->value = $value; | ||
$this->type = $type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters