File tree Expand file tree Collapse file tree 3 files changed +26
-8
lines changed
Doctrine/ORM/Query/AST/Functions Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5+ use Rector \CodeQuality \Rector \Identical \FlipTypeControlToUseExclusiveTypeRector ;
56use Rector \Config \RectorConfig ;
67use Rector \Doctrine \Set \DoctrineSetList ;
78use Rector \Naming \Rector \Class_ \RenamePropertyToMatchTypeRector ;
4041
4142 $ rectorConfig ->skip ([
4243 RenamePropertyToMatchTypeRector::class,
44+ FlipTypeControlToUseExclusiveTypeRector::class => [
45+ $ basePath .'src/MartinGeorgiev/Utils/DoctrineLexer.php ' ,
46+ ],
4347 ]);
4448
4549 $ rectorConfig ->importShortClasses (false );
Original file line number Diff line number Diff line change 44
55namespace MartinGeorgiev \Doctrine \ORM \Query \AST \Functions ;
66
7- use Doctrine \Common \Lexer \Token ;
87use Doctrine \ORM \Query \AST \Functions \FunctionNode ;
98use Doctrine \ORM \Query \AST \Node ;
109use Doctrine \ORM \Query \Lexer ;
1110use Doctrine \ORM \Query \Parser ;
1211use Doctrine \ORM \Query \SqlWalker ;
1312use Doctrine \ORM \Query \TokenType ;
13+ use MartinGeorgiev \Utils \DoctrineLexer ;
1414use 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 ($ type === null ) {
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 ();
Original file line number Diff line number Diff line change @@ -36,4 +36,23 @@ public static function getLookaheadType(Lexer $lexer)
3636 // @phpstan-ignore-next-line
3737 return $ lexer ->lookahead ?->type;
3838 }
39+
40+ /**
41+ * @return mixed|null
42+ */
43+ public static function getTokenValue (Lexer $ lexer )
44+ {
45+ if (self ::isPre200 ($ lexer )) {
46+ // @phpstan-ignore-next-line
47+ if ($ lexer ->token === null ) {
48+ return null ;
49+ }
50+
51+ // @phpstan-ignore-next-line
52+ return $ lexer ->token ['value ' ];
53+ }
54+
55+ // @phpstan-ignore-next-line
56+ return $ lexer ->token ?->value;
57+ }
3958}
You can’t perform that action at this time.
0 commit comments