Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions ci/phpstan/config.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
includes:
- ../../vendor/ekino/phpstan-banned-code/extension.neon
- ../../vendor/phpstan/phpstan-deprecation-rules/rules.neon
- ../../vendor/phpstan/phpstan-doctrine/extension.neon
- ../../vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
Expand All @@ -9,6 +11,13 @@ parameters:
- ../../src
- ../../tests

tmpDir: ../../var/cache/phpstan

parallel:
maximumNumberOfProcesses: 4

errorFormat: table

reportUnmatchedIgnoredErrors: false

ignoreErrors:
Expand Down
38 changes: 27 additions & 11 deletions ci/phpunit/config.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" stopOnFailure="false" bootstrap="../../vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="PostgreSQL-for-Doctrine Test Suite">
<directory>../../tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">../../src</directory>
</include>
</source>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
stopOnFailure="false"
bootstrap="../../vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory="../../var/cache/phpunit/"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true">
<testsuites>
<testsuite name="PostgreSQL-for-Doctrine Test Suite">
<directory>../../tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="../../var/coverage/html"/>
<clover outputFile="../../var/coverage/clover.xml"/>
</report>
</coverage>
<source>
<include>
<directory suffix=".php">../../src</directory>
</include>
</source>
</phpunit>
35 changes: 21 additions & 14 deletions ci/rector/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,36 @@
$basePath = __DIR__.'/../../';
$paths = [
$basePath.'ci',
$basePath.'fixtures',
$basePath.'src',
$basePath.'tests',
];
$rectorConfig->paths($paths);

$rectorConfig->cacheDirectory($basePath.'var/cache/rector/');

$rectorConfig->parallel();
$rectorConfig->phpstanConfig($basePath.'ci/phpstan/config.neon');

$rectorConfig->sets([
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::NAMING,
SetList::PHP_80,
SetList::PHP_81,
SetList::TYPE_DECLARATION,
SetList::PRIVATIZATION,
SetList::CODING_STYLE,
DoctrineSetList::DOCTRINE_ORM_25,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
RenamePropertyToMatchTypeRector::class,
]);
$rectorConfig->importShortClasses(false);
$rectorConfig->importNames(false, false); // @todo Enable once Rector introduces better support for function imports.

$rectorConfig->import(SetList::CODE_QUALITY);
$rectorConfig->import(SetList::DEAD_CODE);
$rectorConfig->import(SetList::EARLY_RETURN);
$rectorConfig->import(SetList::NAMING);
$rectorConfig->import(SetList::PHP_80);
$rectorConfig->import(SetList::PHP_81);
$rectorConfig->import(SetList::TYPE_DECLARATION);

$rectorConfig->import(DoctrineSetList::DOCTRINE_ORM_25);
$rectorConfig->import(DoctrineSetList::DOCTRINE_CODE_QUALITY);

$rectorConfig->import(LevelSetList::UP_TO_PHP_81);
$rectorConfig->importShortClasses(false);
$rectorConfig->importNames(false, false);
};
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@
"ekino/phpstan-banned-code": "^1.0",
"friendsofphp/php-cs-fixer": "^3.72.0",
"phpstan/phpstan": "^1.12.21",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-doctrine": "^1.5",
"phpstan/phpstan-phpunit": "^1.4.2",
"phpunit/phpunit": "^10.5.45",
"rector/rector": "^1.2.10",
"rector/rector": "^1.2",
"symfony/cache": "^6.4||^7.0"
},
"suggest": {
Expand Down
5 changes: 3 additions & 2 deletions fixtures/MartinGeorgiev/Doctrine/Entity/ContainsArrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace Fixtures\MartinGeorgiev\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
class ContainsArrays extends Entity
{
#[ORM\Column(type: 'json')]
#[ORM\Column(type: Types::JSON)]
public array $array1;

#[ORM\Column(type: 'json')]
#[ORM\Column(type: Types::JSON)]
public array $array2;
}
13 changes: 7 additions & 6 deletions fixtures/MartinGeorgiev/Doctrine/Entity/ContainsDates.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@

namespace Fixtures\MartinGeorgiev\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
class ContainsDates extends Entity
{
#[ORM\Column(type: 'date_immutable')]
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
public \DateTimeImmutable $date1;

#[ORM\Column(type: 'date_immutable')]
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
public \DateTimeImmutable $date2;

#[ORM\Column(type: 'datetime_immutable')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
public \DateTimeImmutable $datetime1;

#[ORM\Column(type: 'datetime_immutable')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
public \DateTimeImmutable $datetime2;

#[ORM\Column(type: 'datetimetz_immutable')]
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
public \DateTimeImmutable $datetimetz1;

#[ORM\Column(type: 'datetimetz_immutable')]
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
public \DateTimeImmutable $datetimetz2;
}
7 changes: 4 additions & 3 deletions fixtures/MartinGeorgiev/Doctrine/Entity/ContainsDecimals.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

namespace Fixtures\MartinGeorgiev\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
class ContainsDecimals extends Entity
{
#[ORM\Column(type: 'decimal')]
#[ORM\Column(type: Types::DECIMAL)]
public float $decimal1;

#[ORM\Column(type: 'decimal')]
#[ORM\Column(type: Types::DECIMAL)]
public float $decimal2;

#[ORM\Column(type: 'decimal')]
#[ORM\Column(type: Types::DECIMAL)]
public float $decimal3;
}
7 changes: 4 additions & 3 deletions fixtures/MartinGeorgiev/Doctrine/Entity/ContainsIntegers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

namespace Fixtures\MartinGeorgiev\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
class ContainsIntegers extends Entity
{
#[ORM\Column(type: 'integer')]
#[ORM\Column(type: Types::INTEGER)]
public int $integer1;

#[ORM\Column(type: 'integer')]
#[ORM\Column(type: Types::INTEGER)]
public int $integer2;

#[ORM\Column(type: 'integer')]
#[ORM\Column(type: Types::INTEGER)]
public int $integer3;
}
5 changes: 3 additions & 2 deletions fixtures/MartinGeorgiev/Doctrine/Entity/ContainsJsons.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace Fixtures\MartinGeorgiev\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
class ContainsJsons extends Entity
{
#[ORM\Column(type: 'json')]
#[ORM\Column(type: Types::JSON)]
public array $object1;

#[ORM\Column(type: 'json')]
#[ORM\Column(type: Types::JSON)]
public array $object2;
}
5 changes: 3 additions & 2 deletions fixtures/MartinGeorgiev/Doctrine/Entity/ContainsTexts.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace Fixtures\MartinGeorgiev\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
class ContainsTexts extends Entity
{
#[ORM\Column(type: 'text')]
#[ORM\Column(type: Types::TEXT)]
public string $text1;

#[ORM\Column(type: 'text')]
#[ORM\Column(type: Types::TEXT)]
public string $text2;
}
10 changes: 2 additions & 8 deletions fixtures/MartinGeorgiev/Doctrine/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@

namespace Fixtures\MartinGeorgiev\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

abstract class Entity
{
/**
* @ORM\Id
*
* @ORM\Column(type="string")
*
* @ORM\GeneratedValue
*/
#[ORM\Id()]
#[ORM\Column(type: 'string')]
#[ORM\Column(type: Types::STRING)]
#[ORM\GeneratedValue()]
public string $id;
}
2 changes: 2 additions & 0 deletions src/MartinGeorgiev/Doctrine/DBAL/Types/BaseIntegerArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public function isValidArrayItemForDatabase($item): bool
if (!\is_int($item) && !\is_string($item)) {
return false;
}

if (!(bool) \preg_match('/^-?\d+$/', (string) $item)) {
return false;
}

if ((string) $item < $this->getMinValue()) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function transformToPostgresJson(mixed $phpValue): string
try {
$postgresValue = \json_encode($phpValue, JSON_THROW_ON_ERROR);
} catch (\JsonException) {
throw new ConversionException(\sprintf('Value %s can\'t be resolved to valid JSON', \var_export($phpValue, true)));
throw new ConversionException(\sprintf("Value %s can't be resolved to valid JSON", \var_export($phpValue, true)));
}

return $postgresValue;
Expand Down
1 change: 1 addition & 0 deletions src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected function transformPostgresArrayToPHPArray(string $postgresArray): arra
if ($postgresArray === '{}') {
return [];
}

$trimmedPostgresArray = \mb_substr($postgresArray, 2, -2);
$phpArray = \explode('},{', $trimmedPostgresArray);
foreach ($phpArray as &$item) {
Expand Down
1 change: 1 addition & 0 deletions src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function transformToPostgresTextArray(array $phpTextArray): string
if (!\is_array($phpTextArray)) {
throw new \InvalidArgumentException(\sprintf('Value %s is not an array', \var_export($phpTextArray, true)));
}

if ($phpTextArray === []) {
return '{}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
abstract class BaseOrderableFunction extends BaseFunction
{
protected Node $expression;

protected ?OrderByClause $orderByClause = null;

public function parse(Parser $parser): void
Expand All @@ -23,17 +24,17 @@

$this->customizeFunction();

$parser->match($shouldUseLexer ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER);

Check failure on line 27 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Fetching deprecated class constant T_IDENTIFIER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_IDENTIFIER}

Check failure on line 27 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Fetching deprecated class constant T_IDENTIFIER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_IDENTIFIER}

Check failure on line 27 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Fetching deprecated class constant T_IDENTIFIER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_IDENTIFIER}

Check failure on line 27 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Fetching deprecated class constant T_IDENTIFIER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_IDENTIFIER}
$parser->match($shouldUseLexer ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS);

Check failure on line 28 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Fetching deprecated class constant T_OPEN_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_OPEN_PARENTHESIS}

Check failure on line 28 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Fetching deprecated class constant T_OPEN_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_OPEN_PARENTHESIS}

Check failure on line 28 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Fetching deprecated class constant T_OPEN_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_OPEN_PARENTHESIS}

Check failure on line 28 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Fetching deprecated class constant T_OPEN_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_OPEN_PARENTHESIS}

$this->parseFunction($parser);

$lexer = $parser->getLexer();
if ($lexer->isNextToken($shouldUseLexer ? Lexer::T_ORDER : TokenType::T_ORDER)) {

Check failure on line 33 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Fetching deprecated class constant T_ORDER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_ORDER}

Check failure on line 33 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Fetching deprecated class constant T_ORDER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_ORDER}

Check failure on line 33 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Fetching deprecated class constant T_ORDER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_ORDER}

Check failure on line 33 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Fetching deprecated class constant T_ORDER of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_ORDER}
$this->orderByClause = $parser->OrderByClause();
}

$parser->match($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS);

Check failure on line 37 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}

Check failure on line 37 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}

Check failure on line 37 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}

Check failure on line 37 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseOrderableFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}
}

abstract protected function parseFunction(Parser $parser): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @throws ParserException
*/
public function feedParserWithNodes(Parser $parser): void
protected function feedParserWithNodes(Parser $parser): void
{
$lexer = $parser->getLexer();

Expand All @@ -35,11 +35,12 @@
$aheadType = $lexer->lookahead->type;
$shouldUseLexer = DoctrineOrm::isPre219();

while (($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS) !== $aheadType) {

Check failure on line 38 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}

Check failure on line 38 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}

Check failure on line 38 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}

Check failure on line 38 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_CLOSE_PARENTHESIS}
if (($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA) === $aheadType) {

Check failure on line 39 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Fetching deprecated class constant T_COMMA of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_COMMA}

Check failure on line 39 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Fetching deprecated class constant T_COMMA of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_COMMA}

Check failure on line 39 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Fetching deprecated class constant T_COMMA of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_COMMA}

Check failure on line 39 in src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Fetching deprecated class constant T_COMMA of class Doctrine\ORM\Query\Lexer: use {@see TokenType::T_COMMA}
$parser->match($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA);
$this->nodes[] = $parser->{$this->commonNodeMapping}();
}

$aheadType = $lexer->lookahead->type;
}

Expand Down
3 changes: 3 additions & 0 deletions src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function parse(Parser $parser): void

$parser->match($shouldUseLexer ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER);
$parser->match($shouldUseLexer ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS);

$this->sourceType = $parser->SimpleArithmeticExpression();
$parser->match($shouldUseLexer ? Lexer::T_AS : TokenType::T_AS);
$parser->match($shouldUseLexer ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER);
Expand All @@ -43,6 +44,7 @@ public function parse(Parser $parser): void
if (!$token instanceof Token) {
return;
}

if (!\is_string($token->value)) {
return;
}
Expand All @@ -59,6 +61,7 @@ public function parse(Parser $parser): void
$parameters[] = $parameter->value;
}
}

$parser->match($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS);
$type .= '('.\implode(', ', $parameters).')';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
class StringAgg extends BaseOrderableFunction
{
private bool $isDistinct = false;

private Node $delimiter;

protected function customizeFunction(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/MartinGeorgiev/Doctrine/DBAL/Types/BaseArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function throws_conversion_exception_when_invalid_array_item_value(): voi
$this->expectExceptionMessage("One or more of the items given doesn't look valid.");

$this->fixture
->expects($this->once())
->expects(self::once())
->method('isValidArrayItemForDatabase')
->willReturn(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function throws_an_exception_when_lexer_is_not_populated_with_a_lookahead
$parser = new Parser($query);
$parser->getLexer()->moveNext();

$this->createFixture()->feedParserWithNodes($parser);
$baseComparisonFunction = $this->createFixture();

$reflectionMethod = new \ReflectionMethod($baseComparisonFunction::class, 'feedParserWithNodes');
$reflectionMethod->setAccessible(true);
$reflectionMethod->invoke($baseComparisonFunction, $parser);
}
}
Loading
Loading