From 3e8edacc2bdce269535d1bdbe6f5dc13f031e7c1 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Mon, 1 Apr 2024 08:27:38 +0100 Subject: [PATCH] Revert "Issue #3425537 by mondrake: Fix remaining methods with #[\ReturnTypeWillChange] attribute" This reverts commit aca587777ae9bdebdbaa454af831b88ca7a3c79b. --- .../Component/Render/FormattableMarkup.php | 6 +++-- .../Drupal/Component/Render/MarkupTrait.php | 6 +++-- .../Component/Utility/DeprecatedArray.php | 24 ++++++++++++------- core/lib/Drupal/Core/Cache/MemoryBackend.php | 2 +- .../Core/Config/Entity/ConfigEntityBase.php | 2 +- core/lib/Drupal/Core/Database/Connection.php | 2 +- core/lib/Drupal/Core/Database/Query/Query.php | 4 ++-- .../Core/DependencyInjection/Container.php | 2 +- .../DependencyInjection/ContainerBuilder.php | 2 +- .../DependencySerializationTrait.php | 5 ++-- .../Drupal/Core/Entity/ContentEntityBase.php | 2 +- core/lib/Drupal/Core/Entity/EntityBase.php | 2 +- .../Drupal/Core/Entity/EntityDisplayBase.php | 4 ++-- .../Entity/Query/ConditionFundamentals.php | 3 ++- core/lib/Drupal/Core/Extension/Dependency.php | 2 +- core/lib/Drupal/Core/Extension/Extension.php | 4 ++-- .../Drupal/Core/Field/BaseFieldDefinition.php | 2 +- .../Core/Field/Entity/BaseFieldOverride.php | 2 +- .../lib/Drupal/Core/Field/FieldConfigBase.php | 2 +- .../RegexRecursiveFilterIterator.php | 6 +++-- core/lib/Drupal/Core/Site/Settings.php | 2 +- .../PluralTranslatableMarkup.php | 2 +- .../StringTranslation/TranslatableMarkup.php | 5 ++-- .../TypedData/ComplexDataDefinitionBase.php | 2 +- .../Drupal/Core/TypedData/DataDefinition.php | 2 +- .../field/src/Entity/FieldStorageConfig.php | 2 +- core/modules/forum/src/ForumManager.php | 4 ++-- .../jsonapi/src/JsonApiResource/Data.php | 6 +++-- .../src/JsonApiResource/ErrorCollection.php | 3 ++- .../src/JsonApiResource/LinkCollection.php | 3 ++- ...TemporaryArrayObjectThrowingExceptions.php | 21 ++++++++++------ .../src/TraversableObject.php | 3 ++- .../modules/migrate/src/Audit/AuditResult.php | 6 +++-- .../src/Plugin/migrate/id_map/NullIdMap.php | 17 +++++++++---- .../migrate/source/EmbeddedDataSource.php | 3 ++- .../migrate/source/SourcePluginBase.php | 3 ++- .../src/Plugin/migrate/source/SqlBase.php | 2 +- .../source/CacheableEmbeddedDataSource.php | 3 ++- .../Plugin/migrate/source/ContentEntity.php | 3 ++- .../src/Session/TestSessionHandlerProxy.php | 18 +++++++++----- core/modules/taxonomy/src/TermStorage.php | 4 ++-- core/modules/views/src/Entity/View.php | 2 +- core/modules/views/src/ViewExecutable.php | 4 ++-- .../Drupal/KernelTests/KernelTestBase.php | 2 +- core/tests/Drupal/Tests/BrowserTestBase.php | 2 +- 45 files changed, 128 insertions(+), 80 deletions(-) diff --git a/core/lib/Drupal/Component/Render/FormattableMarkup.php b/core/lib/Drupal/Component/Render/FormattableMarkup.php index 6cebd3e3a1ac..63c4892ce3c4 100644 --- a/core/lib/Drupal/Component/Render/FormattableMarkup.php +++ b/core/lib/Drupal/Component/Render/FormattableMarkup.php @@ -105,7 +105,8 @@ public function __toString() { * @return int * The length of the string. */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return mb_strlen($this->string); } @@ -115,7 +116,8 @@ public function count(): int { * @return string * The safe string content. */ - public function jsonSerialize(): string { + #[\ReturnTypeWillChange] + public function jsonSerialize() { return $this->__toString(); } diff --git a/core/lib/Drupal/Component/Render/MarkupTrait.php b/core/lib/Drupal/Component/Render/MarkupTrait.php index 8b569696d623..93ed4d2eb0da 100644 --- a/core/lib/Drupal/Component/Render/MarkupTrait.php +++ b/core/lib/Drupal/Component/Render/MarkupTrait.php @@ -58,7 +58,8 @@ public function __toString() { * @return int * The length of the string. */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return mb_strlen($this->string); } @@ -68,7 +69,8 @@ public function count(): int { * @return string * The safe string content. */ - public function jsonSerialize(): string { + #[\ReturnTypeWillChange] + public function jsonSerialize() { return $this->__toString(); } diff --git a/core/lib/Drupal/Component/Utility/DeprecatedArray.php b/core/lib/Drupal/Component/Utility/DeprecatedArray.php index 6f93c7c68d08..f3ef310ce43c 100644 --- a/core/lib/Drupal/Component/Utility/DeprecatedArray.php +++ b/core/lib/Drupal/Component/Utility/DeprecatedArray.php @@ -30,7 +30,8 @@ public function __construct(array $values, $message) { /** * {@inheritdoc} */ - public function offsetExists($offset): bool { + #[\ReturnTypeWillChange] + public function offsetExists($offset) { @trigger_error($this->message, E_USER_DEPRECATED); return parent::offsetExists($offset); } @@ -38,7 +39,8 @@ public function offsetExists($offset): bool { /** * {@inheritdoc} */ - public function offsetGet($offset): mixed { + #[\ReturnTypeWillChange] + public function offsetGet($offset) { @trigger_error($this->message, E_USER_DEPRECATED); return parent::offsetGet($offset); } @@ -46,7 +48,8 @@ public function offsetGet($offset): mixed { /** * {@inheritdoc} */ - public function offsetSet($offset, $value): void { + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) { @trigger_error($this->message, E_USER_DEPRECATED); parent::offsetSet($offset, $value); } @@ -54,7 +57,8 @@ public function offsetSet($offset, $value): void { /** * {@inheritdoc} */ - public function offsetUnset($offset): void { + #[\ReturnTypeWillChange] + public function offsetUnset($offset) { @trigger_error($this->message, E_USER_DEPRECATED); parent::offsetUnset($offset); } @@ -62,7 +66,8 @@ public function offsetUnset($offset): void { /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { @trigger_error($this->message, E_USER_DEPRECATED); return parent::getIterator(); } @@ -70,7 +75,8 @@ public function getIterator(): \ArrayIterator { /** * {@inheritdoc} */ - public function unserialize($serialized): void { + #[\ReturnTypeWillChange] + public function unserialize($serialized) { @trigger_error($this->message, E_USER_DEPRECATED); parent::unserialize($serialized); } @@ -78,7 +84,8 @@ public function unserialize($serialized): void { /** * {@inheritdoc} */ - public function serialize(): string { + #[\ReturnTypeWillChange] + public function serialize() { @trigger_error($this->message, E_USER_DEPRECATED); return parent::serialize(); } @@ -86,7 +93,8 @@ public function serialize(): string { /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { @trigger_error($this->message, E_USER_DEPRECATED); return parent::count(); } diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 0f1ec5de1371..267ccd1b6b12 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -222,7 +222,7 @@ protected function getRequestTime() { /** * Prevents data stored in memory backends from being serialized. */ - public function __sleep(): array { + public function __sleep() { return ['time']; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index c82bcddfbb78..ad50387947ff 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -340,7 +340,7 @@ public function preSave(EntityStorageInterface $storage) { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { $keys_to_unset = []; if ($this instanceof EntityWithPluginCollectionInterface) { // Get the plugin collections first, so that the properties are diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index e4c11093d3b8..a5fad5489404 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -1916,7 +1916,7 @@ protected static function getSQLState(\Exception $e) { /** * Prevents the database connection from being serialized. */ - public function __sleep(): array { + public function __sleep() { throw new \LogicException('The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution.'); } diff --git a/core/lib/Drupal/Core/Database/Query/Query.php b/core/lib/Drupal/Core/Database/Query/Query.php index 98dc1e06ea2a..37bce1a8f914 100644 --- a/core/lib/Drupal/Core/Database/Query/Query.php +++ b/core/lib/Drupal/Core/Database/Query/Query.php @@ -83,7 +83,7 @@ public function __construct(Connection $connection, $options) { /** * Implements the magic __sleep function to disconnect from the database. */ - public function __sleep(): array { + public function __sleep() { $keys = get_object_vars($this); unset($keys['connection']); return array_keys($keys); @@ -92,7 +92,7 @@ public function __sleep(): array { /** * Implements the magic __wakeup function to reconnect to the database. */ - public function __wakeup(): void { + public function __wakeup() { $this->connection = Database::getConnection($this->connectionTarget, $this->connectionKey); } diff --git a/core/lib/Drupal/Core/DependencyInjection/Container.php b/core/lib/Drupal/Core/DependencyInjection/Container.php index c40fc533ba12..125f593adb3c 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Container.php +++ b/core/lib/Drupal/Core/DependencyInjection/Container.php @@ -12,7 +12,7 @@ class Container extends DrupalContainer { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { assert(FALSE, 'The container was serialized.'); return array_keys(get_object_vars($this)); } diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index 10e1814c1f3b..84c529b4dfc3 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -84,7 +84,7 @@ public function setParameter($name, $value) { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { assert(FALSE, 'The container was serialized.'); return array_keys(get_object_vars($this)); } diff --git a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php index c3cc3e34b8b6..edb080e94ebc 100644 --- a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php +++ b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php @@ -30,7 +30,7 @@ trait DependencySerializationTrait { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { $vars = get_object_vars($this); try { $container = \Drupal::getContainer(); @@ -70,7 +70,8 @@ public function __sleep(): array { /** * {@inheritdoc} */ - public function __wakeup(): void { + #[\ReturnTypeWillChange] + public function __wakeup() { // Avoid trying to wakeup if there's nothing to do. if (empty($this->_serviceIds) && empty($this->_entityStorages)) { return; diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index e701667ec5fd..52b967425676 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -546,7 +546,7 @@ protected function clearTranslationCache() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { // Get the values of instantiated field objects, only serialize the values. foreach ($this->fields as $name => $fields) { foreach ($fields as $langcode => $field) { diff --git a/core/lib/Drupal/Core/Entity/EntityBase.php b/core/lib/Drupal/Core/Entity/EntityBase.php index 8a32728bf2b5..781417760ce6 100644 --- a/core/lib/Drupal/Core/Entity/EntityBase.php +++ b/core/lib/Drupal/Core/Entity/EntityBase.php @@ -637,7 +637,7 @@ private function getTypedDataClass(): string { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { $this->typedData = NULL; return $this->traitSleep(); } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index 48d70f818ed3..768835903f62 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -544,7 +544,7 @@ protected function getDefaultRegion() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { // Only store the definition, not external objects or derived data. $keys = array_keys($this->toArray()); // In addition, we need to keep the entity type and the "is new" status. @@ -563,7 +563,7 @@ public function __sleep(): array { /** * {@inheritdoc} */ - public function __wakeup(): void { + public function __wakeup() { // Determine what were the properties from toArray() that were saved in // __sleep(). $keys = $this->_serializedKeys; diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php index 36ea69861d87..e176b68588b6 100644 --- a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php +++ b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php @@ -65,7 +65,8 @@ public function getConjunction() { /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return count($this->conditions); } diff --git a/core/lib/Drupal/Core/Extension/Dependency.php b/core/lib/Drupal/Core/Extension/Dependency.php index 622be6b7959c..0f305df89017 100644 --- a/core/lib/Drupal/Core/Extension/Dependency.php +++ b/core/lib/Drupal/Core/Extension/Dependency.php @@ -141,7 +141,7 @@ public static function createFromString($dependency) { * @return array * The properties to serialize. */ - public function __sleep(): array { + public function __sleep() { return ['name', 'project', 'constraintString']; } diff --git a/core/lib/Drupal/Core/Extension/Extension.php b/core/lib/Drupal/Core/Extension/Extension.php index f0c46666613a..3ef96ffbd3cd 100644 --- a/core/lib/Drupal/Core/Extension/Extension.php +++ b/core/lib/Drupal/Core/Extension/Extension.php @@ -192,7 +192,7 @@ public function getFileInfo(): \SplFileInfo { * @return array * The names of all variables that should be serialized. */ - public function __sleep(): array { + public function __sleep() { // @todo \Drupal\Core\Extension\ThemeExtensionList is adding custom // properties to the Extension object. $properties = get_object_vars($this); @@ -205,7 +205,7 @@ public function __sleep(): array { /** * Magic method implementation to unserialize the extension object. */ - public function __wakeup(): void { + public function __wakeup() { // Get the app root from the container. While compiling the container we // have to discover all the extension service files in // \Drupal\Core\DrupalKernel::initializeServiceProviders(). This results in diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php index 811c81edb19f..520ff8a70977 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php +++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php @@ -610,7 +610,7 @@ public function getMainPropertyName() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { // Do not serialize the statically cached property definitions. $vars = get_object_vars($this); unset($vars['propertyDefinitions'], $vars['typedDataManager']); diff --git a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php index 1e3cdf81f111..3f16fdad9891 100644 --- a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php +++ b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php @@ -259,7 +259,7 @@ public static function loadByName($entity_type_id, $bundle, $field_name) { /** * Implements the magic __sleep() method. */ - public function __sleep(): array { + public function __sleep() { // Only serialize necessary properties, excluding those that can be // recalculated. unset($this->baseFieldDefinition); diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index 5b21717d9ead..ca9a5b5285ea 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -467,7 +467,7 @@ public function setDefaultValueCallback($callback) { * breaks entity forms in PHP 5.4. * @todo Investigate in https://www.drupal.org/node/1977206. */ - public function __sleep(): array { + public function __sleep() { $properties = get_object_vars($this); // Only serialize necessary properties, excluding those that can be diff --git a/core/lib/Drupal/Core/Plugin/Discovery/RegexRecursiveFilterIterator.php b/core/lib/Drupal/Core/Plugin/Discovery/RegexRecursiveFilterIterator.php index 3a4bd05ac6d1..1d86e1bba026 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/RegexRecursiveFilterIterator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/RegexRecursiveFilterIterator.php @@ -23,7 +23,8 @@ public function __construct(\RecursiveIterator $iterator, protected string $rege /** * {@inheritdoc} */ - public function accept(): bool { + #[\ReturnTypeWillChange] + public function accept() { /** @var \SplFileInfo $file_info */ $file_info = $this->getInnerIterator()->current(); if ($file_info->isDir()) { @@ -37,7 +38,8 @@ public function accept(): bool { /** * {@inheritdoc} */ - public function getChildren(): ?\RecursiveFilterIterator { + #[\ReturnTypeWillChange] + public function getChildren() { $children = parent::getChildren(); if ($children instanceof self && empty($children->regex)) { $children->regex = $this->regex; diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index 7516e64b7c73..bc94826079c0 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -86,7 +86,7 @@ private function __clone() { /** * Prevents settings from being serialized. */ - public function __sleep(): array { + public function __sleep() { throw new \LogicException('Settings can not be serialized. This probably means you are serializing an object that has an indirect reference to the Settings object. Adjust your code so that is not necessary.'); } diff --git a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php index b1583e12d0ab..d6410b2e5910 100644 --- a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php +++ b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php @@ -140,7 +140,7 @@ protected function getPluralIndex() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { return array_merge(parent::__sleep(), ['count']); } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php index dce967cfcf0c..8f24cf3cb09c 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php @@ -200,7 +200,7 @@ public function render() { /** * Magic __sleep() method to avoid serializing the string translator. */ - public function __sleep(): array { + public function __sleep() { return ['string', 'arguments', 'options']; } @@ -224,7 +224,8 @@ protected function getStringTranslation() { * @return int * The length of the string. */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return mb_strlen($this->render()); } diff --git a/core/lib/Drupal/Core/TypedData/ComplexDataDefinitionBase.php b/core/lib/Drupal/Core/TypedData/ComplexDataDefinitionBase.php index 3b22d5fe5839..0002497e9480 100644 --- a/core/lib/Drupal/Core/TypedData/ComplexDataDefinitionBase.php +++ b/core/lib/Drupal/Core/TypedData/ComplexDataDefinitionBase.php @@ -39,7 +39,7 @@ public function getMainPropertyName() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { // Do not serialize the cached property definitions. $vars = get_object_vars($this); unset($vars['propertyDefinitions'], $vars['typedDataManager']); diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index 0aaa02abcca8..a82f819b4cde 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -369,7 +369,7 @@ public function toArray() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { // Never serialize the typed data manager. $vars = get_object_vars($this); unset($vars['typedDataManager']); diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index bbd9a0737141..b966e763ec50 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -751,7 +751,7 @@ public function hasData() { * breaks entity forms in PHP 5.4. * @todo Investigate in https://www.drupal.org/node/1977206. */ - public function __sleep(): array { + public function __sleep() { // Only serialize necessary properties, excluding those that can be // recalculated. $properties = get_object_vars($this); diff --git a/core/modules/forum/src/ForumManager.php b/core/modules/forum/src/ForumManager.php index aee4409d2423..79b91b1db39f 100644 --- a/core/modules/forum/src/ForumManager.php +++ b/core/modules/forum/src/ForumManager.php @@ -502,7 +502,7 @@ public function unreadTopics($term, $uid) { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { $vars = $this->defaultSleep(); // Do not serialize static cache. unset($vars['history'], $vars['index'], $vars['lastPostData'], $vars['forumChildren'], $vars['forumStatistics']); @@ -512,7 +512,7 @@ public function __sleep(): array { /** * {@inheritdoc} */ - public function __wakeup(): void { + public function __wakeup() { $this->defaultWakeup(); // Initialize static cache. $this->history = []; diff --git a/core/modules/jsonapi/src/JsonApiResource/Data.php b/core/modules/jsonapi/src/JsonApiResource/Data.php index bac3a7fc5f39..113e3bf559d3 100644 --- a/core/modules/jsonapi/src/JsonApiResource/Data.php +++ b/core/modules/jsonapi/src/JsonApiResource/Data.php @@ -69,7 +69,8 @@ public function __construct(array $data, $cardinality = -1) { * @return \ArrayIterator * An \ArrayIterator instance */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->data); } @@ -79,7 +80,8 @@ public function getIterator(): \ArrayIterator { * @return int * The number of parameters */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return count($this->data); } diff --git a/core/modules/jsonapi/src/JsonApiResource/ErrorCollection.php b/core/modules/jsonapi/src/JsonApiResource/ErrorCollection.php index 7a352307c99f..018f19209401 100644 --- a/core/modules/jsonapi/src/JsonApiResource/ErrorCollection.php +++ b/core/modules/jsonapi/src/JsonApiResource/ErrorCollection.php @@ -47,7 +47,8 @@ public function __construct(array $errors) { * @return \ArrayIterator * An \ArrayIterator instance */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->errors); } diff --git a/core/modules/jsonapi/src/JsonApiResource/LinkCollection.php b/core/modules/jsonapi/src/JsonApiResource/LinkCollection.php index 7a465e2cb0c0..6381dfce5c6a 100644 --- a/core/modules/jsonapi/src/JsonApiResource/LinkCollection.php +++ b/core/modules/jsonapi/src/JsonApiResource/LinkCollection.php @@ -62,7 +62,8 @@ public function __construct(array $links, $context = NULL) { /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { assert(!is_null($this->context), 'A LinkCollection is invalid unless a context has been established.'); return new \ArrayIterator($this->links); } diff --git a/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php b/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php index d6e766416b0b..397dd2c624e7 100644 --- a/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php +++ b/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php @@ -34,7 +34,8 @@ public function append($value): void { * This class does not support this action but it must implement it, because * it is extending \ArrayObject. */ - public function asort($flags = SORT_REGULAR): TRUE { + #[\ReturnTypeWillChange] + public function asort($flags = SORT_REGULAR): bool { throw new \Exception('This ' . __CLASS__ . ' does not support this action but it must implement it, because it is extending \ArrayObject.'); } @@ -117,7 +118,8 @@ public function getIteratorClass(): string { * This class does not support this action but it must implement it, because * it is extending \ArrayObject. */ - public function ksort($flags = SORT_REGULAR): TRUE { + #[\ReturnTypeWillChange] + public function ksort($flags = SORT_REGULAR): bool { throw new \Exception('This ' . __CLASS__ . ' does not support this action but it must implement it, because it is extending \ArrayObject.'); } @@ -128,7 +130,8 @@ public function ksort($flags = SORT_REGULAR): TRUE { * This class does not support this action but it must implement it, because * it is extending \ArrayObject. */ - public function natcasesort(): TRUE { + #[\ReturnTypeWillChange] + public function natcasesort(): bool { throw new \Exception('This ' . __CLASS__ . ' does not support this action but it must implement it, because it is extending \ArrayObject.'); } @@ -139,7 +142,8 @@ public function natcasesort(): TRUE { * This class does not support this action but it must implement it, because * it is extending \ArrayObject. */ - public function natsort(): TRUE { + #[\ReturnTypeWillChange] + public function natsort(): bool { throw new \Exception('This ' . __CLASS__ . ' does not support this action but it must implement it, because it is extending \ArrayObject.'); } @@ -170,7 +174,8 @@ public function offsetExists($key): bool { * This class does not support this action but it must implement it, because * it is extending \ArrayObject. */ - public function offsetGet($key): mixed { + #[\ReturnTypeWillChange] + public function offsetGet($key) { throw new \Exception('This ' . __CLASS__ . ' does not support this action but it must implement it, because it is extending \ArrayObject.'); } @@ -245,7 +250,8 @@ public function setIteratorClass($iteratorClass): void { * This class does not support this action but it must implement it, because * it is extending \ArrayObject. */ - public function uasort($callback): TRUE { + #[\ReturnTypeWillChange] + public function uasort($callback): bool { throw new \Exception('This ' . __CLASS__ . ' does not support this action but it must implement it, because it is extending \ArrayObject.'); } @@ -261,7 +267,8 @@ public function uasort($callback): TRUE { * This class does not support this action but it must implement it, because * it is extending \ArrayObject. */ - public function uksort($callback): TRUE { + #[\ReturnTypeWillChange] + public function uksort($callback): bool { throw new \Exception('This ' . __CLASS__ . ' does not support this action but it must implement it, because it is extending \ArrayObject.'); } diff --git a/core/modules/jsonapi/tests/modules/jsonapi_test_data_type/src/TraversableObject.php b/core/modules/jsonapi/tests/modules/jsonapi_test_data_type/src/TraversableObject.php index afd79a9df4fa..9b4cc275d1bc 100644 --- a/core/modules/jsonapi/tests/modules/jsonapi_test_data_type/src/TraversableObject.php +++ b/core/modules/jsonapi/tests/modules/jsonapi_test_data_type/src/TraversableObject.php @@ -12,7 +12,8 @@ class TraversableObject implements \IteratorAggregate { /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator(); } diff --git a/core/modules/migrate/src/Audit/AuditResult.php b/core/modules/migrate/src/Audit/AuditResult.php index fd77dafe436f..af0f0961c28a 100644 --- a/core/modules/migrate/src/Audit/AuditResult.php +++ b/core/modules/migrate/src/Audit/AuditResult.php @@ -119,7 +119,8 @@ public static function fail(MigrationInterface $migration, array $reasons = []) * * @see \Drupal\Component\Render\MarkupInterface */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return count($this->reasons); } @@ -139,7 +140,8 @@ public function __toString() { * * @return string[] */ - public function jsonSerialize(): string { + #[\ReturnTypeWillChange] + public function jsonSerialize() { return $this->reasons; } diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php b/core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php index 80c5da68a5a1..1415373eab10 100644 --- a/core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php @@ -181,33 +181,40 @@ public function getQualifiedMapTableName() { /** * {@inheritdoc} */ - public function rewind(): void { + #[\ReturnTypeWillChange] + public function rewind() { + return NULL; } /** * {@inheritdoc} */ - public function current(): mixed { + #[\ReturnTypeWillChange] + public function current() { return NULL; } /** * {@inheritdoc} */ - public function key(): mixed { + #[\ReturnTypeWillChange] + public function key() { return ''; } /** * {@inheritdoc} */ - public function next(): void { + #[\ReturnTypeWillChange] + public function next() { + return NULL; } /** * {@inheritdoc} */ - public function valid(): bool { + #[\ReturnTypeWillChange] + public function valid() { return FALSE; } diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php index a61a951f3e05..158b3a8914d1 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php +++ b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php @@ -113,7 +113,8 @@ public function getIds() { /** * {@inheritdoc} */ - public function count($refresh = FALSE): int { + #[\ReturnTypeWillChange] + public function count($refresh = FALSE) { // We do not want this source plugin to have a cacheable count. // @see \Drupal\migrate_cache_counts_test\Plugin\migrate\source\CacheableEmbeddedDataSource return count($this->dataRows); diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php index 6dc65aa8f202..3191c7256d4a 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php @@ -492,7 +492,8 @@ public function getCurrentIds() { * @return int * The count. */ - public function count($refresh = FALSE): int { + #[\ReturnTypeWillChange] + public function count($refresh = FALSE) { if ($this->skipCount) { return MigrateSourceInterface::NOT_COUNTABLE; } diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php index 57f483e8407f..e5c2b075916f 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php @@ -469,7 +469,7 @@ protected function mapJoinable() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { return array_diff(parent::__sleep(), ['database']); } diff --git a/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php b/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php index 64f473682214..47dd1b733092 100644 --- a/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php +++ b/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php @@ -18,7 +18,8 @@ class CacheableEmbeddedDataSource extends EmbeddedDataSource { /** * {@inheritdoc} */ - public function count($refresh = FALSE): int { + #[\ReturnTypeWillChange] + public function count($refresh = FALSE) { return SourcePluginBase::count($refresh); } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php index 5d80f6160a77..798b1eda6b45 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php @@ -242,7 +242,8 @@ public function query() { /** * {@inheritdoc} */ - public function count($refresh = FALSE): int { + #[\ReturnTypeWillChange] + public function count($refresh = FALSE) { // If no translations are included, then a simple query is possible. if (!$this->configuration['include_translations']) { return parent::count($refresh); diff --git a/core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php b/core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php index 7d89096f8d4e..a4e28b640a2a 100644 --- a/core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php +++ b/core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php @@ -37,7 +37,8 @@ public function __construct(\SessionHandlerInterface $session_handler, $optional /** * {@inheritdoc} */ - public function open($save_path, $name): bool { + #[\ReturnTypeWillChange] + public function open($save_path, $name) { $trace = \Drupal::service('session_test.session_handler_proxy_trace'); $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__]; $result = $this->sessionHandler->open($save_path, $name); @@ -48,7 +49,8 @@ public function open($save_path, $name): bool { /** * {@inheritdoc} */ - public function close(): bool { + #[\ReturnTypeWillChange] + public function close() { $trace = \Drupal::service('session_test.session_handler_proxy_trace'); $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__]; $result = $this->sessionHandler->close(); @@ -59,7 +61,8 @@ public function close(): bool { /** * {@inheritdoc} */ - public function read($session_id): string|FALSE { + #[\ReturnTypeWillChange] + public function read($session_id) { $trace = \Drupal::service('session_test.session_handler_proxy_trace'); $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__, $session_id]; $result = $this->sessionHandler->read($session_id); @@ -70,7 +73,8 @@ public function read($session_id): string|FALSE { /** * {@inheritdoc} */ - public function write($session_id, $session_data): bool { + #[\ReturnTypeWillChange] + public function write($session_id, $session_data) { $trace = \Drupal::service('session_test.session_handler_proxy_trace'); $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__, $session_id]; $result = $this->sessionHandler->write($session_id, $session_data); @@ -81,14 +85,16 @@ public function write($session_id, $session_data): bool { /** * {@inheritdoc} */ - public function destroy($session_id): bool { + #[\ReturnTypeWillChange] + public function destroy($session_id) { return $this->sessionHandler->destroy($session_id); } /** * {@inheritdoc} */ - public function gc($max_lifetime): int|FALSE { + #[\ReturnTypeWillChange] + public function gc($max_lifetime) { return $this->sessionHandler->gc($max_lifetime); } diff --git a/core/modules/taxonomy/src/TermStorage.php b/core/modules/taxonomy/src/TermStorage.php index 25f6fa9b38dc..e121a1744a3a 100644 --- a/core/modules/taxonomy/src/TermStorage.php +++ b/core/modules/taxonomy/src/TermStorage.php @@ -448,7 +448,7 @@ public function getVocabularyHierarchyType($vid) { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { /** @var string[] $vars */ $vars = parent::__sleep(); // Do not serialize static cache. @@ -459,7 +459,7 @@ public function __sleep(): array { /** * {@inheritdoc} */ - public function __wakeup(): void { + public function __wakeup() { parent::__wakeup(); // Initialize static caches. $this->ancestors = []; diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 9c57451d58a9..8fb42eadf47e 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -462,7 +462,7 @@ public function isInstallable() { /** * {@inheritdoc} */ - public function __sleep(): array { + public function __sleep() { $keys = parent::__sleep(); unset($keys[array_search('executable', $keys)]); return $keys; diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 58c18fc51b20..7d73d7f21264 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -2499,7 +2499,7 @@ public function getDependencies() { * @return array * The names of all variables that should be serialized. */ - public function __sleep(): array { + public function __sleep() { // Limit to only the required data which is needed to properly restore the // state during unserialization. $this->serializationData = [ @@ -2519,7 +2519,7 @@ public function __sleep(): array { /** * Magic method implementation to unserialize the view executable. */ - public function __wakeup(): void { + public function __wakeup() { // There are cases, like in testing where we don't have a container // available. if (\Drupal::hasContainer() && !empty($this->serializationData)) { diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 236ddf89a43c..7e3fc2d995f4 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -1039,7 +1039,7 @@ private static function getModulesToEnable($class) { * * @see vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseMethod.tpl.dist */ - public function __sleep(): array { + public function __sleep() { return []; } diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index f27fa37a40bd..fc6173bfc143 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -603,7 +603,7 @@ public function installDrupal() { * * @see vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseMethod.tpl.dist */ - public function __sleep(): array { + public function __sleep() { return []; } -- GitLab