maxValue === null || $this->nextValue === $this->maxValue) { // Allocate new values $connection = $em->getConnection(); $sql = $connection->getDatabasePlatform()->getSequenceNextValSQL($this->sequenceName); if ($connection instanceof PrimaryReadReplicaConnection) { $connection->ensureConnectedToPrimary(); } $this->nextValue = (int) $connection->fetchOne($sql); $this->maxValue = $this->nextValue + $this->allocationSize; } return $this->nextValue++; } /** * Gets the maximum value of the currently allocated bag of values. */ public function getCurrentMaxValue(): int|null { return $this->maxValue; } /** * Gets the next value that will be returned by generate(). */ 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, ); return serialize($this->__serialize()); } /** @return array */ public function __serialize(): array { return [ 'allocationSize' => $this->allocationSize, 'sequenceName' => $this->sequenceName, ]; } /** @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, ); $this->__unserialize(unserialize($serialized)); } /** @param array $data */ public function __unserialize(array $data): void { $this->sequenceName = $data['sequenceName']; $this->allocationSize = $data['allocationSize']; } }