Skip to content

Commit f7e5410

Browse files
peter-gribanovPeter Gribanov
authored and
Peter Gribanov
committed
context in DQLContextResolver::resolveAlias() should not be empty
1 parent a98d6b4 commit f7e5410

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/DQLContextResolver.php

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public static function resolveAlias(QueryBuilder $qb, string $context): string
4949
{
5050
$dqlAliasParts = explode('.', $context);
5151

52+
if (!$dqlAliasParts) {
53+
throw new \InvalidArgumentException('You must provide context.');
54+
}
55+
5256
// any given alias can be used
5357
if (!self::$deadJoinsProtection) {
5458
return array_pop($dqlAliasParts);

src/Operand/PlatformFunction.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class PlatformFunction implements Operand
7171
/**
7272
* @var PlatformFunctionExecutorRegistry|null
7373
*/
74-
private static $executorRegistry = null;
74+
private static $executorRegistry;
7575

7676
/**
7777
* @var string
@@ -138,7 +138,7 @@ public function execute($candidate, ?string $context = null)
138138
*/
139139
public static function getExecutorRegistry(): PlatformFunctionExecutorRegistry
140140
{
141-
if (null === self::$executorRegistry) {
141+
if (!self::$executorRegistry instanceof PlatformFunctionExecutorRegistry) {
142142
$instances = [];
143143

144144
foreach (self::DOCTRINE_FUNCTIONS as $functionName => $class) {

tests/Operand/ValueSpec.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
namespace tests\Happyr\DoctrineSpecification\Operand;
1616

1717
use Doctrine\Common\Collections\ArrayCollection;
18-
use Doctrine\DBAL\Types\Type;
1918
use Doctrine\ORM\QueryBuilder;
2019
use Happyr\DoctrineSpecification\Operand\Operand;
2120
use Happyr\DoctrineSpecification\Operand\Value;
@@ -59,7 +58,7 @@ public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameter
5958

6059
public function it_is_transformable_dbal_type(QueryBuilder $qb, ArrayCollection $parameters): void
6160
{
62-
$valueType = Type::DATE;
61+
$valueType = 'date';
6362
$this->beConstructedWith($this->value, $valueType);
6463

6564
$qb->getParameters()->willReturn($parameters);

tests/Operand/ValuesSpec.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
namespace tests\Happyr\DoctrineSpecification\Operand;
1616

1717
use Doctrine\Common\Collections\ArrayCollection;
18-
use Doctrine\DBAL\Types\Type;
1918
use Doctrine\ORM\QueryBuilder;
2019
use Happyr\DoctrineSpecification\Operand\Operand;
2120
use Happyr\DoctrineSpecification\Operand\Values;
@@ -59,7 +58,7 @@ public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameter
5958

6059
public function it_is_transformable_dbal_type(QueryBuilder $qb, ArrayCollection $parameters): void
6160
{
62-
$valueType = Type::DATE;
61+
$valueType = 'date';
6362
$this->beConstructedWith($this->values, $valueType);
6463

6564
$qb->getParameters()->willReturn($parameters);

0 commit comments

Comments
 (0)