We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getCatchablePattern
Today, getCatchablePattern should return an array, and the matching value are passed into getType.
getType
It could be really handy to have and indexed array and passed the matching index into the getType function like this:
In this example, I used the documented DQL lexer (not sure if the code is 100% right, but it's for the example)
protected function getCatchablePatterns() { return [ - '[a-z_][a-z0-9_]*\:[a-z_][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // aliased name - '[a-z_\\\][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // identifier or qualified name - '(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?', // numbers - "'(?:[^']|'')*'", // quoted strings - '\?[0-9]*|:[a-z_][a-z0-9_]*', // parameters + 'aliasedName' => '[a-z_][a-z0-9_]*\:[a-z_][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // aliased name + 'idOrQualifiedName' => '[a-z_\\\][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // identifier or qualified name + 'numbers' => '(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?', // numbers + 'quotedString' => "'(?:[^']|'')*'", // quoted strings + 'parameters' => '\?[0-9]*|:[a-z_][a-z0-9_]*', // parameters ]; } protected function getType(&$value, $patternIndex) { $type = self::T_NONE; switch (true) { // Recognize numeric values - case (is_numeric($value)): + case ('numbers' === $patternIndex): if (strpos($value, '.') !== false || stripos($value, 'e') !== false) { return self::T_FLOAT; } return self::T_INTEGER; // Recognize quoted strings - case ($value[0] === "'"): + case ('quotedString' === $patternIndex): $value = str_replace("''", "'", substr($value, 1, strlen($value) - 2)); return self::T_STRING; // Recognize identifiers, aliased or qualified names - case (ctype_alpha($value[0]) || $value[0] === '_' || $value[0] === '\\'): + case ('idOrQualifiedName' === $patternIndex || 'aliasedName' === $patternIndex): $name = 'Doctrine\ORM\Query\Lexer::T_' . strtoupper($value); if (defined($name)) { $type = constant($name); if ($type > 100) { return $type; } } if (strpos($value, ':') !== false) { return self::T_ALIASED_NAME; } if (strpos($value, '\\') !== false) { return self::T_FULLY_QUALIFIED_NAME; } return self::T_IDENTIFIER; // Recognize input parameters - case ($value[0] === '?' || $value[0] === ':'): + case ('parameters' === $patternIndex): return self::T_INPUT_PARAMETER; // Recognize symbols case ($value === '.'): return self::T_DOT; case ($value === ','): return self::T_COMMA; case ($value === '('): return self::T_OPEN_PARENTHESIS; case ($value === ')'): return self::T_CLOSE_PARENTHESIS; case ($value === '='): return self::T_EQUALS; case ($value === '>'): return self::T_GREATER_THAN; case ($value === '<'): return self::T_LOWER_THAN; case ($value === '+'): return self::T_PLUS; case ($value === '-'): return self::T_MINUS; case ($value === '*'): return self::T_MULTIPLY; case ($value === '/'): return self::T_DIVIDE; case ($value === '!'): return self::T_NEGATE; case ($value === '{'): return self::T_OPEN_CURLY_BRACE; case ($value === '}'): return self::T_CLOSE_CURLY_BRACE; // Default default: // Do nothing } return $type; }
I can of course open a PR on that if you are OK with the idea.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Today,
getCatchablePattern
should return an array, and the matching value are passed intogetType
.It could be really handy to have and indexed array and passed the matching index into the
getType
function like this:In this example, I used the documented DQL lexer (not sure if the code is 100% right, but it's for the example)
I can of course open a PR on that if you are OK with the idea.
The text was updated successfully, but these errors were encountered: