Skip to content

Commit

Permalink
Merge pull request #108 from alexander-schranz/feature/lexer-3-for-2.x
Browse files Browse the repository at this point in the history
Add lexer 3 support to 2.x branch
  • Loading branch information
x86demon authored Nov 20, 2024
2 parents e1af14c + 5599f67 commit 98dea7a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ phpunit.xml
vendor/
composer.lock
.idea/
.phpunit.cache/
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
],
"require": {
"php": ">=8.0",
"doctrine/orm": ">=2.6, <3.0",
"doctrine/dbal": ">=2.6, <3.0",
"doctrine/lexer": "^2, <3"
"doctrine/orm": "^2.6",
"doctrine/dbal": "^2.6|^3",
"doctrine/lexer": "^2|^3"
},
"require-dev": {
"phpunit/phpunit": "9.*",
"doctrine/data-fixtures": "^1.3",
"symfony/yaml": "5.*",
"symfony/cache": "5.*",
"squizlabs/php_codesniffer": "3.5.*",
"doctrine/annotations": ">1.0, <2.0"
"doctrine/annotations": "^1.0|^2.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/ORM/Query/AST/Functions/Cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function parse(Parser $parser)

$parser->match(Lexer::T_IDENTIFIER);
$lexer = $parser->getLexer();
$type = $lexer->token['value'];
$type = $lexer->token->value;

if ($lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
$parser->match(Lexer::T_OPEN_PARENTHESIS);
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/ORM/Query/AST/Functions/Numeric/Round.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function parse(Parser $parser)
$this->parameters[self::VALUE] = $parser->SimpleArithmeticExpression();

// parse second parameter if available
if (Lexer::T_COMMA === $lexer->lookahead['type']) {
if (Lexer::T_COMMA === $lexer->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->parameters[self::PRECISION] = $parser->ArithmeticPrimary();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/ORM/Query/AST/Functions/Numeric/TimestampDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function parse(Parser $parser)
$parser->match(Lexer::T_IDENTIFIER);

$lexer = $parser->getLexer();
$unit = strtoupper(trim($lexer->token['value']));
$unit = strtoupper(trim($lexer->token->value));
if (!$this->isSupportedUnit($unit)) {
$parser->syntaxError(
\sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function parse(Parser $parser)
}

if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) {
if (\strtolower($lexer->lookahead['value']) !== 'separator') {
if (\strtolower($lexer->lookahead->value) !== 'separator') {
$parser->syntaxError('separator');
}
$parser->match(Lexer::T_IDENTIFIER);
Expand Down
20 changes: 11 additions & 9 deletions tests/Oro/Entities/Foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,48 @@

namespace Oro\Entities;

use Doctrine\ORM\Mapping as ORM;

/**
* @Entity
* @Table(name="test_foo")
* @ORM\Entity
* @ORM\Table(name="test_foo")
*/
class Foo
{
/**
* @var int
*
* @Id
* @Column(type="integer", name="id")
* @GeneratedValue(strategy="AUTO")
* @ORM\Id
* @ORM\Column(type="integer", name="id")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;

/**
* @var string
*
* @Column(name="name", type="string", length=255)
* @ORM\Column(name="name", type="string", length=255)
*/
protected $name;

/**
* @var \DateTime $createdAt
*
* @Column(name="created_at", type="datetime", nullable=true)
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
protected $createdAt;

/**
* @var float
*
* @Column(name="budget", type="float", nullable=true)
* @ORM\Column(name="budget", type="float", nullable=true)
*/
protected $budget;

/**
* @var string
*
* @Column(name="code", type="string", length=255)
* @ORM\Column(name="code", type="string", length=255)
*/
protected $code;

Expand Down
2 changes: 1 addition & 1 deletion tests/Oro/Tests/Connection/TestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function getEntityManager(): EntityManager
$dbParams = self::getConnectionParams();
$entitiesPath = \realpath(__DIR__ . '/../../Entities');

$config = Setup::createAnnotationMetadataConfiguration([$entitiesPath], true);
$config = Setup::createAnnotationMetadataConfiguration([$entitiesPath], true, null, null, false);
self::$entityManager = EntityManager::create($dbParams, $config);
}

Expand Down

0 comments on commit 98dea7a

Please sign in to comment.