Skip to content

Commit

Permalink
Deprecate Type::addType
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Jan 16, 2025
1 parent 2331fd2 commit 355887c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ awareness about deprecated code.

# Upgrade to 4.3

## Deprecated Type::addType

Use Type::getTypeRegistry()->register() instead.

## Deprecated `Table::columnsAreIndexed()`

The `Table::columnsAreIndexed()` method has been deprecated.
Expand Down
2 changes: 2 additions & 0 deletions src/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public static function lookupName(self $type): string
* @param class-string<Type> $className The class name of the custom type.
*
* @throws Exception
*
* @deprecated Use Type::getTypeRegistry()->register() instead.
*/
public static function addType(string $name, string $className): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Schema/CustomIntrospectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function setUpBeforeClass(): void
self::markTestSkipped('Skip on Oracle');
}

Type::addType(MoneyType::NAME, MoneyType::class);
Type::getTypeRegistry()->register(MoneyType::NAME, new MoneyType);

Check failure on line 32 in tests/Functional/Schema/CustomIntrospectionTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.4)

Parentheses must be used when instantiating a new class
}

public function testCustomColumnIntrospection(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Schema/MySQLSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MySQLSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public static function setUpBeforeClass(): void
{
Type::addType('point', PointType::class);
Type::getTypeRegistry()->register('point', new PointType);

Check failure on line 30 in tests/Functional/Schema/MySQLSchemaManagerTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.4)

Parentheses must be used when instantiating a new class
}

protected function supportsPlatform(AbstractPlatform $platform): bool
Expand Down Expand Up @@ -591,7 +591,7 @@ public function testListTableColumnsThrowsDatabaseRequired(): void

public function testSchemaDiffWithCustomColumnTypeWhileDatabaseTypeDiffers(): void
{
Type::addType('custom_type', CustomType::class);
Type::getTypeRegistry()->register('custom_type', new CustomType);

Check failure on line 594 in tests/Functional/Schema/MySQLSchemaManagerTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.4)

Parentheses must be used when instantiating a new class

$metadataTable = new Table('table_with_custom_type');
$metadataTable->addColumn('col1', 'custom_type');
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Schema/PostgreSQLSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testSupportDomainTypeFallback(): void
$table = $this->connection->createSchemaManager()->introspectTable('domain_type_test');
self::assertInstanceOf(DecimalType::class, $table->getColumn('value')->getType());

Type::addType('MyMoney', MoneyType::class);
Type::getTypeRegistry()->register('MyMoney', new MoneyType);

Check failure on line 56 in tests/Functional/Schema/PostgreSQLSchemaManagerTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.4)

Parentheses must be used when instantiating a new class
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'MyMoney');

$table = $this->connection->createSchemaManager()->introspectTable('domain_type_test');
Expand Down
2 changes: 1 addition & 1 deletion tests/Platforms/AbstractPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
if (Type::hasType($type->getName())) {
Type::overrideType($type->getName(), $type::class);
} else {
Type::addType($type->getName(), $type::class);
Type::getTypeRegistry()->register($type->getName(), new $type);
}

self::assertSame($type->getName(), $this->platform->getDoctrineTypeMapping('TeStTyPe'));
Expand Down

0 comments on commit 355887c

Please sign in to comment.