Skip to content

Commit

Permalink
Merge pull request #107 from oroinc/pr99_master
Browse files Browse the repository at this point in the history
Pr99 master
  • Loading branch information
x86demon authored Jul 1, 2024
2 parents cf002e0 + 0e33201 commit b681c1d
Show file tree
Hide file tree
Showing 28 changed files with 152 additions and 351 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Add the following dependency to your composer.json:
```json
{
"require": {
"oro/doctrine-extensions": "^2.0"
"oro/doctrine-extensions": "^3.0"
}
}
```
Expand Down Expand Up @@ -240,7 +240,3 @@ This library also provides the following field types:

* `MoneyType`
* `PercentType`
* `ObjectType`
* `ArrayType`

`ObjectType` and `ArrayType` use Base64 encoded strings to store values in the database instead of storing serialized strings. For backward compatibility the values that are already stored in the database will be unserialized without Base64 encoding. The new values will be Base64 encoded before saving to the database and Base64 decoded before unserialization.
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Upgrade to 3.0
Version 3.0 requires PHP 8.1 or newer and works with Doctrine/ORM 3.0 or newer.

The following types are no longer supported :
* `ObjectType`
* `ArrayType`

# Upgrade to 2.0

Version 2.0 requires PHP 7.3 or newer and works with Doctrine/ORM 2.6 or newer.
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
],
"require": {
"php": ">=8.1",
"doctrine/lexer": "~1.0|~2.0",
"doctrine/orm": "~2.8",
"doctrine/dbal": "~2.10|~3.0"
"doctrine/lexer": "~3.0",
"doctrine/orm": "~3.0",
"doctrine/dbal": "~3.0|~4.0"
},
"require-dev": {
"phpunit/phpunit": "~10",
"doctrine/data-fixtures": "^1.3",
"symfony/yaml": "5.*",
"symfony/cache": "5.*",
"squizlabs/php_codesniffer": "3.5.*",
"doctrine/annotations": ">1.0, <2.0"
"squizlabs/php_codesniffer": "3.9.*",
"doctrine/annotations": "~2.0"
},
"autoload": {
"psr-4": {
Expand Down
31 changes: 0 additions & 31 deletions src/Oro/DBAL/Types/ArrayType.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Oro/DBAL/Types/MoneyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getName()
* @noinspection PhpMissingReturnTypeInspection
* @noinspection ReturnTypeCanBeDeclaredInspection
*/
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
$column['precision'] = self::TYPE_PRECISION;
$column['scale'] = self::TYPE_SCALE;
Expand All @@ -38,7 +38,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform)
* @noinspection PhpMissingParentCallCommonInspection
* @noinspection PhpDocSignatureInspection
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
public function convertToPHPValue($value, AbstractPlatform $platform): mixed
{
return $value;
}
Expand Down
31 changes: 0 additions & 31 deletions src/Oro/DBAL/Types/ObjectType.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Oro/DBAL/Types/PercentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getName()
* @noinspection PhpMissingReturnTypeInspection
* @noinspection ReturnTypeCanBeDeclaredInspection
*/
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return $platform->getFloatDeclarationSQL($column);
}
Expand All @@ -35,7 +35,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform)
* @noinspection ReturnTypeCanBeDeclaredInspection
* @noinspection PhpDocSignatureInspection
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
public function convertToPHPValue($value, AbstractPlatform $platform): mixed
{
return (null === $value) ? null : (double) $value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class AbstractPlatformAwareFunctionNode extends FunctionNode
* @noinspection ReturnTypeCanBeDeclaredInspection
* {@inheritdoc}
*/
public function getSql(SqlWalker $sqlWalker)
public function getSql(SqlWalker $sqlWalker): string
{
$function = FunctionFactory::create(
$sqlWalker->getConnection()->getDatabasePlatform(),
Expand Down
26 changes: 13 additions & 13 deletions src/Oro/ORM/Query/AST/Functions/Cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Oro\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\TokenType;

class Cast extends AbstractPlatformAwareFunctionNode
{
Expand Down Expand Up @@ -33,32 +33,32 @@ class Cast extends AbstractPlatformAwareFunctionNode
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->parameters[self::PARAMETER_KEY] = $parser->ArithmeticExpression();

$parser->match(Lexer::T_AS);
$parser->match(TokenType::T_AS);

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

if ($lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
$parser->match(Lexer::T_OPEN_PARENTHESIS);
if ($lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS)) {
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$parameter = $parser->Literal();
$parameters = [
$parameter->value
];
if ($lexer->isNextToken(Lexer::T_COMMA)) {
while ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
if ($lexer->isNextToken(TokenType::T_COMMA)) {
while ($lexer->isNextToken(TokenType::T_COMMA)) {
$parser->match(TokenType::T_COMMA);
$parameter = $parser->Literal();
$parameters[] = $parameter->value;
}
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
$type .= '(' . \implode(', ', $parameters) . ')';
}

Expand All @@ -75,7 +75,7 @@ public function parse(Parser $parser)

$this->parameters[self::TYPE_KEY] = $type;

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}

protected function isSupportedType(string $type): bool
Expand Down
14 changes: 7 additions & 7 deletions src/Oro/ORM/Query/AST/Functions/DateTime/ConvertTz.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Oro\ORM\Query\AST\Functions\DateTime;

use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\TokenType;
use Oro\ORM\Query\AST\Functions\AbstractPlatformAwareFunctionNode;

class ConvertTz extends AbstractPlatformAwareFunctionNode
Expand All @@ -16,15 +16,15 @@ class ConvertTz extends AbstractPlatformAwareFunctionNode
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->parameters[self::VALUE_KEY] = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$parser->match(TokenType::T_COMMA);
$this->parameters[self::FROM_TZ_KEY] = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$parser->match(TokenType::T_COMMA);
$this->parameters[self::TO_TZ_KEY] = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
12 changes: 6 additions & 6 deletions src/Oro/ORM/Query/AST/Functions/Numeric/Pow.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Oro\ORM\Query\AST\Functions\Numeric;

use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\TokenType;
use Oro\ORM\Query\AST\Functions\AbstractPlatformAwareFunctionNode;

class Pow extends AbstractPlatformAwareFunctionNode
Expand All @@ -15,13 +15,13 @@ class Pow extends AbstractPlatformAwareFunctionNode
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->parameters[self::VALUE_KEY] = $parser->SimpleArithmeticExpression();
$parser->match(Lexer::T_COMMA);
$parser->match(TokenType::T_COMMA);
$this->parameters[self::POWER_KEY] = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
14 changes: 7 additions & 7 deletions src/Oro/ORM/Query/AST/Functions/Numeric/Round.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Oro\ORM\Query\AST\Functions\Numeric;

use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\TokenType;
use Oro\ORM\Query\AST\Functions\AbstractPlatformAwareFunctionNode;

class Round extends AbstractPlatformAwareFunctionNode
Expand All @@ -15,19 +15,19 @@ class Round extends AbstractPlatformAwareFunctionNode
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
public function parse(Parser $parser): void
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->parameters[self::VALUE] = $parser->SimpleArithmeticExpression();

// parse second parameter if available
if (Lexer::T_COMMA === $lexer->lookahead['type']) {
$parser->match(Lexer::T_COMMA);
if (TokenType::T_COMMA === $lexer->lookahead->type) {
$parser->match(TokenType::T_COMMA);
$this->parameters[self::PRECISION] = $parser->ArithmeticPrimary();
}

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
10 changes: 5 additions & 5 deletions src/Oro/ORM/Query/AST/Functions/Numeric/Sign.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Oro\ORM\Query\AST\Functions\Numeric;

use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\TokenType;
use Oro\ORM\Query\AST\Functions\AbstractPlatformAwareFunctionNode;

class Sign extends AbstractPlatformAwareFunctionNode
Expand All @@ -14,11 +14,11 @@ class Sign extends AbstractPlatformAwareFunctionNode
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->parameters[self::PARAMETER_KEY] = $parser->SimpleArithmeticExpression();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
18 changes: 9 additions & 9 deletions src/Oro/ORM/Query/AST/Functions/Numeric/TimestampDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Oro\ORM\Query\AST\Functions\Numeric;

use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\TokenType;
use Oro\ORM\Query\AST\Functions\AbstractPlatformAwareFunctionNode;

class TimestampDiff extends AbstractPlatformAwareFunctionNode
Expand All @@ -31,14 +31,14 @@ class TimestampDiff extends AbstractPlatformAwareFunctionNode
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$parser->match(TokenType::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 All @@ -51,11 +51,11 @@ public function parse(Parser $parser)
}

$this->parameters[self::UNIT_KEY] = $unit;
$parser->match(Lexer::T_COMMA);
$parser->match(TokenType::T_COMMA);
$this->parameters[self::VAL1_KEY] = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$parser->match(TokenType::T_COMMA);
$this->parameters[self::VAL2_KEY] = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}

protected function isSupportedUnit(string $unit): bool
Expand Down
Loading

0 comments on commit b681c1d

Please sign in to comment.