Skip to content

Commit

Permalink
Deprecate SequenceGenerator implementing Serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed May 21, 2024
1 parent 0a177d5 commit e7665c8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Upgrade to 3.2

## Deprecate remaining `Serializable` implementation

Relying on `SequenceGenerator` implementing the `Serializable` is deprecated
because that interface won't be implemented in ORM 4 anymore.

The following methods are deprecated:

* `SequenceGenerator::serialize()`
* `SequenceGenerator::unserialize()`

## `orm:schema-tool:update` option `--complete` is deprecated

That option behaves as a no-op, and is deprecated. It will be removed in 4.0.
Expand Down
19 changes: 19 additions & 0 deletions src/Id/SequenceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Id;

use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Serializable;

Expand Down Expand Up @@ -65,8 +66,17 @@ public function getNextValue(): int
return $this->nextValue;
}

/** @deprecated without replacement. */
final public function serialize(): string
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/11468',
'%s() is deprecated, use __serialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.',
__METHOD__,
self::class,

Check warning on line 77 in src/Id/SequenceGenerator.php

View check run for this annotation

Codecov / codecov/patch

src/Id/SequenceGenerator.php#L72-L77

Added lines #L72 - L77 were not covered by tests
);

return serialize($this->__serialize());
}

Expand All @@ -79,8 +89,17 @@ public function __serialize(): array
];
}

/** @deprecated without replacement. */
final public function unserialize(string $serialized): void
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/11468',
'%s() is deprecated, use __unserialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.',
__METHOD__,
self::class,

Check warning on line 100 in src/Id/SequenceGenerator.php

View check run for this annotation

Codecov / codecov/patch

src/Id/SequenceGenerator.php#L95-L100

Added lines #L95 - L100 were not covered by tests
);

$this->__unserialize(unserialize($serialized));
}

Expand Down

0 comments on commit e7665c8

Please sign in to comment.