Bonjour à tous,
Je reçois cette erreur seulement depuis hier, auriez vous une idée de ce qu'il faut faire ? (ligne 102 fonction getSQL()...)
Compile Error: Declaration of App\Extensions\Doctrine\MatchAgainst::getSql(Doctrine\ORM\Query\SqlWalker $walker) must be compatible with Doctrine\ORM\Query\AST\Functions\FunctionNode::getSql(Doctrine\ORM\Query\SqlWalker $sqlWalker): string
Merci d'avance pour votre réponse
MatchAgainst.php :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| <?php
namespace DoctrineExtensions\Query\Mysql;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\AST\PathExpression;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;
use function implode;
use function sprintf;
use function strtolower;
class MatchAgainst extends FunctionNode
{
/** @var array<int, PathExpression> */
protected $pathExp = null;
/** @var string */
protected $against = null;
/** @var bool */
protected $booleanMode = false;
/** @var bool */
protected $queryExpansion = false;
public function parse(Parser $parser): void
{
// match
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
// first Path Expression is mandatory
$this->pathExp = [];
$this->pathExp[] = $parser->StateFieldPathExpression();
// Subsequent Path Expressions are optional
$lexer = $parser->getLexer();
while ($lexer->isNextToken(TokenType::T_COMMA)) {
$parser->match(TokenType::T_COMMA);
$this->pathExp[] = $parser->StateFieldPathExpression();
}
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
// against
if (strtolower($lexer->lookahead->value) !== 'against') {
$parser->syntaxError('against');
}
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->against = $parser->StringPrimary();
if (strtolower($lexer->lookahead->value) === 'boolean') {
$parser->match(TokenType::T_IDENTIFIER);
$this->booleanMode = true;
} elseif (strtolower($lexer->lookahead->value) === 'in') {
$parser->match(TokenType::T_IDENTIFIER);
if (strtolower($lexer->lookahead->value) !== 'boolean') {
$parser->syntaxError('boolean');
}
$parser->match(TokenType::T_IDENTIFIER);
if (strtolower($lexer->lookahead->value) !== 'mode') {
$parser->syntaxError('mode');
}
$parser->match(TokenType::T_IDENTIFIER);
$this->booleanMode = true;
}
if (strtolower($lexer->lookahead->value) === 'expand') {
$parser->match(TokenType::T_IDENTIFIER);
$this->queryExpansion = true;
} elseif (strtolower($lexer->lookahead->value) === 'with') {
$parser->match(TokenType::T_IDENTIFIER);
if (strtolower($lexer->lookahead->value) !== 'query') {
$parser->syntaxError('query');
}
$parser->match(TokenType::T_IDENTIFIER);
if (strtolower($lexer->lookahead->value) !== 'expansion') {
$parser->syntaxError('expansion');
}
$parser->match(TokenType::T_IDENTIFIER);
$this->queryExpansion = true;
}
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
public function getSql(SqlWalker $walker): string
{
$fields = [];
foreach ($this->pathExp as $pathExp) {
$fields[] = $pathExp->dispatch($walker);
}
$against = $walker->walkStringPrimary($this->against)
. ($this->booleanMode ? ' IN BOOLEAN MODE' : '')
. ($this->queryExpansion ? ' WITH QUERY EXPANSION' : '');
return sprintf('MATCH (%s) AGAINST (%s)', implode(', ', $fields), $against);
}
} |
Partager