Skip to content

Commit 7adfd74

Browse files
Merge branch 'main' into more-tests
2 parents 470b491 + 2dd1f2f commit 7adfd74

File tree

11 files changed

+136
-23
lines changed

11 files changed

+136
-23
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.10.1"
2+
".": "2.10.2"
33
}

.github/workflows/ci.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,26 @@ permissions:
1111

1212
jobs:
1313
tests:
14-
name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }}"
14+
name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }} + Doctrine Lexer ${{ matrix.doctrine-lexer }}"
1515
runs-on: ubuntu-latest
1616

1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
php: ['8.1', '8.2', '8.3', '8.4']
21-
doctrine-orm: ['2.14', '3.0', 'latest']
21+
doctrine-lexer: ['2.1', '3.0', 'latest']
22+
doctrine-orm: ['2.14', '2.18', '3.0', 'latest']
2223
include:
24+
- php: '8.1'
25+
doctrine-orm: '2.14'
26+
doctrine-lexer: '1.2'
2327
- php: '8.4'
2428
calculate-code-coverage: true
29+
exclude:
30+
- doctrine-orm: '2.14'
31+
doctrine-lexer: '3.0'
32+
- doctrine-orm: '3.0'
33+
doctrine-lexer: '2.1'
2534

2635
steps:
2736
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -39,19 +48,33 @@ jobs:
3948

4049
- name: Cache Composer packages
4150
id: composer-cache
42-
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
51+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
4352
with:
4453
path: vendor
4554
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
4655
restore-keys: |
4756
${{ runner.os }}-php-
4857
49-
- name: Install composer dependencies
58+
- name: Install Doctrine Lexer dependency
59+
run: |
60+
if [ "${{ matrix.doctrine-lexer }}" == "1.2" ]; then
61+
composer require doctrine/lexer "~1.2" --dev --prefer-dist --no-interaction --no-progress
62+
elif [ "${{ matrix.doctrine-lexer }}" == "2.1" ]; then
63+
composer require doctrine/lexer "~2.1" --dev --prefer-dist --no-interaction --no-progress
64+
elif [ "${{ matrix.doctrine-lexer }}" == "3.0" ]; then
65+
composer require doctrine/lexer "~3.0" --dev --prefer-dist --no-interaction --no-progress
66+
else
67+
composer update --prefer-dist --no-interaction --no-progress
68+
fi
69+
70+
- name: Install Doctrine ORM dependency
5071
run: |
5172
if [ "${{ matrix.doctrine-orm }}" == "2.14" ]; then
52-
composer require doctrine/orm "~2.14" --prefer-dist --no-interaction --no-progress
73+
composer require doctrine/orm "~2.14" --prefer-dist --no-interaction --no-progress --with-all-dependencies
74+
elif [ "${{ matrix.doctrine-orm }}" == "2.18" ]; then
75+
composer require doctrine/orm "~2.18" --prefer-dist --no-interaction --no-progress --with-all-dependencies
5376
elif [ "${{ matrix.doctrine-orm }}" == "3.0" ]; then
54-
composer require doctrine/orm "~3.0" --prefer-dist --no-interaction --no-progress
77+
composer require doctrine/orm "~3.0" --prefer-dist --no-interaction --no-progress --with-all-dependencies
5578
else
5679
composer update --prefer-dist --no-interaction --no-progress
5780
fi

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [2.10.2](https://github.com/martin-georgiev/postgresql-for-doctrine/compare/v2.10.1...v2.10.2) (2025-03-20)
4+
5+
6+
### Bug Fixes
7+
8+
* Improve BC by deprecating `customiseFunction` instead of renaming it straight away ([#294](https://github.com/martin-georgiev/postgresql-for-doctrine/issues/294)) ([910d328](https://github.com/martin-georgiev/postgresql-for-doctrine/commit/910d3289fe9cb0e605765cf301ae4e86c5845e63))
9+
310
## [2.10.1](https://github.com/martin-georgiev/postgresql-for-doctrine/compare/v2.10.0...v2.10.1) (2025-03-14)
411

512

ci/phpstan/baselines/lexer-constants.neon renamed to ci/phpstan/baselines/lexer-variations.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ parameters:
1111
- '#Fetching deprecated class constant T_DISTINCT of class Doctrine\\ORM\\Query\\Lexer#'
1212
- '#Parameter \#1 \$token of method Doctrine\\ORM\\Query\\Parser::match\(\) expects Doctrine\\ORM\\Query\\TokenType, mixed given.#'
1313
- '#Parameter \#1 \$type of method Doctrine\\Common\\Lexer\\AbstractLexer<Doctrine\\ORM\\Query\\TokenType,string>::isNextToken\(\) expects Doctrine\\ORM\\Query\\TokenType, mixed given.#'
14+
- '#Parameter \#1 \$token of method Doctrine\\ORM\\Query\\Parser::match\(\) expects int\|string, mixed given.#'
15+
- '#Parameter \#1 \$type of method Doctrine\\Common\\Lexer\\AbstractLexer<int\|string,string>::isNextToken\(\) expects int\|string, mixed given.#'
16+
- '#Parameter \#1 \$token of method Doctrine\\ORM\\Query\\Parser::match\(\) expects 1\|2\|3\|4\|5\|6\|7\|8\|9\|10\|11\|12\|13\|14\|15\|16\|17\|18\|19\|100\|101\|102\|200\|201\|202\|203\|204\|205\|206\|207\|208\|209\|210\|211\|212\|213\|214\|215\|216\|217\|218\|219\|220\|221\|222\|223\|224\|225\|226\|227\|228\|229\|230\|231\|232\|233\|234\|235\|236\|237\|238\|239\|240\|241\|242\|243\|244\|245\|246\|247\|248\|249\|250\|251\|252\|253\|254\|255\|256, mixed given.#'
17+
- '#Parameter \#1 \$type of method Doctrine\\Common\\Lexer\\AbstractLexer::isNextToken\(\) expects int\|string, mixed given.#'

ci/phpstan/config.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ includes:
44
- ../../vendor/phpstan/phpstan-doctrine/extension.neon
55
- ../../vendor/phpstan/phpstan-phpunit/extension.neon
66
- ./baselines/deprecated-methods.neon
7-
- ./baselines/lexer-constants.neon
7+
- ./baselines/lexer-variations.neon
88
- ./baselines/phpstan-identifiers.neon
99
- ./baselines/type-mismatches.neon
1010

ci/rector/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
56
use Rector\Config\RectorConfig;
67
use Rector\Doctrine\Set\DoctrineSetList;
78
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
@@ -40,6 +41,9 @@
4041

4142
$rectorConfig->skip([
4243
RenamePropertyToMatchTypeRector::class,
44+
FlipTypeControlToUseExclusiveTypeRector::class => [
45+
$basePath.'src/MartinGeorgiev/Utils/DoctrineLexer.php',
46+
],
4347
]);
4448

4549
$rectorConfig->importShortClasses(false);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"deptrac/deptrac": "^3.0",
4747
"doctrine/orm": "~2.14||~3.0",
4848
"ekino/phpstan-banned-code": "^3.0",
49-
"friendsofphp/php-cs-fixer": "^3.72.0",
49+
"friendsofphp/php-cs-fixer": "^3.73.1",
5050
"phpstan/phpstan": "^2.1.8",
5151
"phpstan/phpstan-deprecation-rules": "^2.0.1",
5252
"phpstan/phpstan-doctrine": "^2.0.2",

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseFunction.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,28 @@ abstract class BaseFunction extends FunctionNode
3131
*/
3232
protected array $nodes = [];
3333

34-
abstract protected function customizeFunction(): void;
34+
/**
35+
* This method is meant for internal use only, and it is not suggested that the forks of the library depend on it.
36+
* It will be made abstract from version 3.0.
37+
*
38+
* @internal
39+
*
40+
* @see customiseFunction()
41+
*/
42+
/* abstract */
43+
protected function customizeFunction(): void
44+
{
45+
// Void
46+
}
47+
48+
/**
49+
* @deprecated
50+
*/
51+
protected function customiseFunction(): void
52+
{
53+
\trigger_error('The internal-use method of `customiseFunction()` is deprecated and is now renamed to `customizeFunction()`. `customiseFunction()` will be removed from version 3.0 onwards.', E_USER_DEPRECATED);
54+
$this->customizeFunction();
55+
}
3556

3657
protected function setFunctionPrototype(string $functionPrototype): void
3758
{

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Doctrine\ORM\Query\TokenType;
1212
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
1313
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\ParserException;
14+
use MartinGeorgiev\Utils\DoctrineLexer;
1415
use MartinGeorgiev\Utils\DoctrineOrm;
1516

1617
/**
@@ -30,24 +31,24 @@ protected function feedParserWithNodes(Parser $parser): void
3031
try {
3132
// @phpstan-ignore-next-line
3233
$this->nodes[] = $parser->{$this->commonNodeMapping}();
33-
if ($lexer->lookahead?->type === null) {
34+
$lookaheadType = DoctrineLexer::getLookaheadType($lexer);
35+
if ($lookaheadType === null) {
3436
throw ParserException::missingLookaheadType();
3537
}
3638
} catch (\Throwable $throwable) {
3739
throw ParserException::withThrowable($throwable);
3840
}
3941

40-
$aheadType = $lexer->lookahead->type;
4142
$shouldUseLexer = DoctrineOrm::isPre219();
4243

43-
while (($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS) !== $aheadType) {
44-
if (($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA) === $aheadType) {
44+
while (($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS) !== $lookaheadType) {
45+
if (($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA) === $lookaheadType) {
4546
$parser->match($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA);
4647
// @phpstan-ignore-next-line
4748
$this->nodes[] = $parser->{$this->commonNodeMapping}();
4849
}
4950

50-
$aheadType = $lexer->lookahead->type;
51+
$lookaheadType = DoctrineLexer::getLookaheadType($lexer);
5152
}
5253

5354
$this->validateArguments($this->nodes);

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Cast.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;
66

7-
use Doctrine\Common\Lexer\Token;
87
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
98
use Doctrine\ORM\Query\AST\Node;
109
use Doctrine\ORM\Query\Lexer;
1110
use Doctrine\ORM\Query\Parser;
1211
use Doctrine\ORM\Query\SqlWalker;
1312
use Doctrine\ORM\Query\TokenType;
13+
use MartinGeorgiev\Utils\DoctrineLexer;
1414
use MartinGeorgiev\Utils\DoctrineOrm;
1515

1616
/**
@@ -40,16 +40,11 @@ public function parse(Parser $parser): void
4040
$parser->match($shouldUseLexer ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER);
4141

4242
$lexer = $parser->getLexer();
43-
$token = $lexer->token;
44-
if (!$token instanceof Token) {
43+
$type = DoctrineLexer::getTokenValue($lexer);
44+
if (!\is_string($type)) {
4545
return;
4646
}
4747

48-
if (!\is_string($token->value)) {
49-
return;
50-
}
51-
52-
$type = $token->value;
5348
if ($lexer->isNextToken($shouldUseLexer ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS)) {
5449
$parser->match($shouldUseLexer ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS);
5550
$parameter = $parser->Literal();

0 commit comments

Comments
 (0)