Skip to content
New issue

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

Address Type deprecation messages #8915

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
Expand Down Expand Up @@ -189,24 +190,24 @@ class EntityGenerator
/**
* Hash-map for handle types.
*
* @psalm-var array<Type::*, string>
* @psalm-var array<Types::*|Type::*, string>
*/
protected $typeAlias = [
Type::DATETIMETZ => '\DateTime',
Type::DATETIME => '\DateTime',
Type::DATE => '\DateTime',
Type::TIME => '\DateTime',
Type::OBJECT => '\stdClass',
Type::INTEGER => 'int',
Type::BIGINT => 'int',
Type::SMALLINT => 'int',
Type::TEXT => 'string',
Type::BLOB => 'string',
Type::DECIMAL => 'string',
Type::GUID => 'string',
Type::JSON_ARRAY => 'array',
Type::SIMPLE_ARRAY => 'array',
Type::BOOLEAN => 'bool',
Types::DATETIMETZ_MUTABLE => '\DateTime',
Types::DATETIME_MUTABLE => '\DateTime',
Types::DATE_MUTABLE => '\DateTime',
Types::TIME_MUTABLE => '\DateTime',
Types::OBJECT => '\stdClass',
Types::INTEGER => 'int',
Types::BIGINT => 'int',
Types::SMALLINT => 'int',
Types::TEXT => 'string',
Types::BLOB => 'string',
Types::DECIMAL => 'string',
Types::GUID => 'string',
Type::JSON_ARRAY => 'array',
Types::SIMPLE_ARRAY => 'array',
Types::BOOLEAN => 'bool',
];

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Doctrine\Tests\ORM\Functional\Ticket;

use DateTime;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
Expand All @@ -32,7 +32,7 @@ public function testIssue(): void
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);

$num = $this->_em->createQuery('DELETE ' . __NAMESPACE__ . '\DDC425Entity e WHERE e.someDatetimeField > ?1')
->setParameter(1, new DateTime(), Type::DATETIME)
->setParameter(1, new DateTime(), Types::DATETIME_MUTABLE)
->getResult();
self::assertEquals(0, $num);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use DateTimeImmutable;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query\ParameterTypeInferer;
use Doctrine\Tests\OrmTestCase;

Expand All @@ -19,17 +19,17 @@ class ParameterTypeInfererTest extends OrmTestCase
public function providerParameterTypeInferer(): array
{
return [
[1, Type::INTEGER],
[1, Types::INTEGER],
['bar', ParameterType::STRING],
['1', ParameterType::STRING],
[new DateTime(), Type::DATETIME],
[new DateTimeImmutable(), Type::DATETIME_IMMUTABLE],
[new DateInterval('P1D'), Type::DATEINTERVAL],
[new DateTime(), Types::DATETIME_MUTABLE],
[new DateTimeImmutable(), Types::DATETIME_IMMUTABLE],
[new DateInterval('P1D'), Types::DATEINTERVAL],
[[2], Connection::PARAM_INT_ARRAY],
[['foo'], Connection::PARAM_STR_ARRAY],
[['1','2'], Connection::PARAM_STR_ARRAY],
[[], Connection::PARAM_STR_ARRAY],
[true, Type::BOOLEAN],
[true, Types::BOOLEAN],
];
}

Expand Down