diff --git a/core/.deprecation-ignore.txt b/core/.deprecation-ignore.txt index 1650f6f8a8b..6198b95d4e5 100644 --- a/core/.deprecation-ignore.txt +++ b/core/.deprecation-ignore.txt @@ -19,6 +19,10 @@ %Method "Twig\\TokenParser\\TokenParserInterface::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message% %Method "WebDriver\\Service\\CurlServiceInterface::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in implementation "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message% +# Skip root namespace native DebugClassLoader forward compatibility warnings. +# These mostly refer to PHP native classes, could be fixed for PHP 8.1. +%Method "[^\\]+::\w+\(\)" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message% + # The following deprecation is listed for Twig 2 compatibility when unit # testing using \Symfony\Component\ErrorHandler\DebugClassLoader. %The "Twig\\Environment::getTemplateClass\(\)" method is considered internal\. It may change without further notice\. You should not extend it from "Drupal\\Core\\Template\\TwigEnvironment"\.% diff --git a/core/lib/Drupal/Component/Annotation/Doctrine/StaticReflectionClass.php b/core/lib/Drupal/Component/Annotation/Doctrine/StaticReflectionClass.php index 87acb3dd400..b0e60706962 100644 --- a/core/lib/Drupal/Component/Annotation/Doctrine/StaticReflectionClass.php +++ b/core/lib/Drupal/Component/Annotation/Doctrine/StaticReflectionClass.php @@ -47,7 +47,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getName(): string + #[\ReturnTypeWillChange] + public function getName() { return $this->staticReflectionParser->getClassName(); } @@ -55,7 +56,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getDocComment(): string|FALSE + #[\ReturnTypeWillChange] + public function getDocComment() { return $this->staticReflectionParser->getDocComment(); } @@ -63,7 +65,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getNamespaceName(): string + #[\ReturnTypeWillChange] + public function getNamespaceName() { return $this->staticReflectionParser->getNamespaceName(); } @@ -91,7 +94,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getMethod($name): \ReflectionMethod + #[\ReturnTypeWillChange] + public function getMethod($name) { throw new ReflectionException('Method not implemented'); } @@ -99,7 +103,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getProperty($name): \ReflectionProperty + #[\ReturnTypeWillChange] + public function getProperty($name) { throw new ReflectionException('Method not implemented'); } @@ -115,7 +120,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getConstant($name): mixed + #[\ReturnTypeWillChange] + public function getConstant($name) { throw new ReflectionException('Method not implemented'); } @@ -123,7 +129,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getConstructor(): ?\ReflectionMethod + #[\ReturnTypeWillChange] + public function getConstructor() { throw new ReflectionException('Method not implemented'); } @@ -131,7 +138,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getDefaultProperties(): array + #[\ReturnTypeWillChange] + public function getDefaultProperties() { throw new ReflectionException('Method not implemented'); } @@ -139,7 +147,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getEndLine(): int|FALSE + #[\ReturnTypeWillChange] + public function getEndLine() { throw new ReflectionException('Method not implemented'); } @@ -147,7 +156,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getExtension(): ?\ReflectionExtension + #[\ReturnTypeWillChange] + public function getExtension() { throw new ReflectionException('Method not implemented'); } @@ -155,7 +165,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getExtensionName(): string|FALSE + #[\ReturnTypeWillChange] + public function getExtensionName() { throw new ReflectionException('Method not implemented'); } @@ -163,7 +174,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getFileName(): string|FALSE + #[\ReturnTypeWillChange] + public function getFileName() { throw new ReflectionException('Method not implemented'); } @@ -171,7 +183,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getInterfaceNames(): array + #[\ReturnTypeWillChange] + public function getInterfaceNames() { throw new ReflectionException('Method not implemented'); } @@ -179,7 +192,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getInterfaces(): array + #[\ReturnTypeWillChange] + public function getInterfaces() { throw new ReflectionException('Method not implemented'); } @@ -187,7 +201,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getMethods($filter = null): array + #[\ReturnTypeWillChange] + public function getMethods($filter = null) { throw new ReflectionException('Method not implemented'); } @@ -195,7 +210,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getModifiers(): int + #[\ReturnTypeWillChange] + public function getModifiers() { throw new ReflectionException('Method not implemented'); } @@ -203,7 +219,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getParentClass(): \ReflectionClass|FALSE + #[\ReturnTypeWillChange] + public function getParentClass() { throw new ReflectionException('Method not implemented'); } @@ -211,7 +228,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getProperties($filter = null): array + #[\ReturnTypeWillChange] + public function getProperties($filter = null) { throw new ReflectionException('Method not implemented'); } @@ -219,7 +237,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getShortName(): string + #[\ReturnTypeWillChange] + public function getShortName() { throw new ReflectionException('Method not implemented'); } @@ -227,7 +246,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getStartLine(): int|FALSE + #[\ReturnTypeWillChange] + public function getStartLine() { throw new ReflectionException('Method not implemented'); } @@ -235,7 +255,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getStaticProperties(): ?array + #[\ReturnTypeWillChange] + public function getStaticProperties() { throw new ReflectionException('Method not implemented'); } @@ -243,7 +264,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getStaticPropertyValue($name, $default = ''): mixed + #[\ReturnTypeWillChange] + public function getStaticPropertyValue($name, $default = '') { throw new ReflectionException('Method not implemented'); } @@ -251,7 +273,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getTraitAliases(): array + #[\ReturnTypeWillChange] + public function getTraitAliases() { throw new ReflectionException('Method not implemented'); } @@ -259,7 +282,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getTraitNames(): array + #[\ReturnTypeWillChange] + public function getTraitNames() { throw new ReflectionException('Method not implemented'); } @@ -267,7 +291,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getTraits(): array + #[\ReturnTypeWillChange] + public function getTraits() { throw new ReflectionException('Method not implemented'); } @@ -275,7 +300,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function hasConstant($name): bool + #[\ReturnTypeWillChange] + public function hasConstant($name) { throw new ReflectionException('Method not implemented'); } @@ -283,7 +309,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function hasMethod($name): bool + #[\ReturnTypeWillChange] + public function hasMethod($name) { throw new ReflectionException('Method not implemented'); } @@ -291,7 +318,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function hasProperty($name): bool + #[\ReturnTypeWillChange] + public function hasProperty($name) { throw new ReflectionException('Method not implemented'); } @@ -299,7 +327,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function implementsInterface($interface): bool + #[\ReturnTypeWillChange] + public function implementsInterface($interface) { throw new ReflectionException('Method not implemented'); } @@ -307,7 +336,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function inNamespace(): bool + #[\ReturnTypeWillChange] + public function inNamespace() { throw new ReflectionException('Method not implemented'); } @@ -315,7 +345,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isAbstract(): bool + #[\ReturnTypeWillChange] + public function isAbstract() { throw new ReflectionException('Method not implemented'); } @@ -323,7 +354,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isCloneable(): bool + #[\ReturnTypeWillChange] + public function isCloneable() { throw new ReflectionException('Method not implemented'); } @@ -331,7 +363,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isFinal(): bool + #[\ReturnTypeWillChange] + public function isFinal() { throw new ReflectionException('Method not implemented'); } @@ -339,7 +372,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isInstance($object): bool + #[\ReturnTypeWillChange] + public function isInstance($object) { throw new ReflectionException('Method not implemented'); } @@ -347,7 +381,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isInstantiable(): bool + #[\ReturnTypeWillChange] + public function isInstantiable() { throw new ReflectionException('Method not implemented'); } @@ -355,7 +390,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isInterface(): bool + #[\ReturnTypeWillChange] + public function isInterface() { throw new ReflectionException('Method not implemented'); } @@ -363,7 +399,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isInternal(): bool + #[\ReturnTypeWillChange] + public function isInternal() { throw new ReflectionException('Method not implemented'); } @@ -371,7 +408,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isIterateable(): bool + #[\ReturnTypeWillChange] + public function isIterateable() { throw new ReflectionException('Method not implemented'); } @@ -379,7 +417,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isSubclassOf($class): bool + #[\ReturnTypeWillChange] + public function isSubclassOf($class) { throw new ReflectionException('Method not implemented'); } @@ -387,7 +426,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isTrait(): bool + #[\ReturnTypeWillChange] + public function isTrait() { throw new ReflectionException('Method not implemented'); } @@ -395,7 +435,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function isUserDefined(): bool + #[\ReturnTypeWillChange] + public function isUserDefined() { throw new ReflectionException('Method not implemented'); } @@ -403,7 +444,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function newInstanceArgs(array $args = []): ?object + #[\ReturnTypeWillChange] + public function newInstanceArgs(array $args = []) { throw new ReflectionException('Method not implemented'); } @@ -411,7 +453,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function newInstanceWithoutConstructor(): object + #[\ReturnTypeWillChange] + public function newInstanceWithoutConstructor() { throw new ReflectionException('Method not implemented'); } @@ -419,7 +462,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function setStaticPropertyValue($name, $value): void + #[\ReturnTypeWillChange] + public function setStaticPropertyValue($name, $value) { throw new ReflectionException('Method not implemented'); } @@ -427,7 +471,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function getConstants(?int $filter = null): array + #[\ReturnTypeWillChange] + public function getConstants(?int $filter = null) { throw new ReflectionException('Method not implemented'); } @@ -435,7 +480,8 @@ class StaticReflectionClass extends ReflectionClass /** * {@inheritDoc} */ - public function newInstance(mixed ...$args): object + #[\ReturnTypeWillChange] + public function newInstance(mixed ...$args) { throw new ReflectionException('Method not implemented'); } diff --git a/core/lib/Drupal/Component/FileSystem/RegexDirectoryIterator.php b/core/lib/Drupal/Component/FileSystem/RegexDirectoryIterator.php index cc17aa643c5..cfa616ae1bf 100644 --- a/core/lib/Drupal/Component/FileSystem/RegexDirectoryIterator.php +++ b/core/lib/Drupal/Component/FileSystem/RegexDirectoryIterator.php @@ -23,7 +23,8 @@ class RegexDirectoryIterator extends \RegexIterator { /** * Implements \RegexIterator::accept(). */ - public function accept(): bool { + #[\ReturnTypeWillChange] + public function accept() { /** @var \SplFileInfo $file_info */ $file_info = $this->getInnerIterator()->current(); return $file_info->isFile() && preg_match($this->getRegex(), $file_info->getFilename()); diff --git a/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php b/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php index db5b8755051..6574c5b3dae 100644 --- a/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php +++ b/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php @@ -142,7 +142,8 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable { $this->remove($instance_id); } - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { $instances = []; foreach ($this->getInstanceIds() as $instance_id) { $instances[$instance_id] = $this->get($instance_id); @@ -153,7 +154,8 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable { /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return count($this->instanceIds); } diff --git a/core/lib/Drupal/Component/Render/HtmlEscapedText.php b/core/lib/Drupal/Component/Render/HtmlEscapedText.php index 6ca9538089e..d5121bfb9f2 100644 --- a/core/lib/Drupal/Component/Render/HtmlEscapedText.php +++ b/core/lib/Drupal/Component/Render/HtmlEscapedText.php @@ -41,14 +41,16 @@ class HtmlEscapedText implements MarkupInterface, \Countable { /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return mb_strlen($this->string); } /** * {@inheritdoc} */ - public function jsonSerialize(): string { + #[\ReturnTypeWillChange] + public function jsonSerialize() { return $this->__toString(); } diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php index 11fc9aca241..e9e4998010b 100644 --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -114,7 +114,8 @@ abstract class ArrayElement extends Element implements \IteratorAggregate, Typed /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->getElements()); } diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php index 377d45cb59d..fcd0b5dfba3 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -90,7 +90,8 @@ class Condition implements ConditionInterface, \Countable { * size of its conditional array minus one, because one element is the * conjunction. */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return count($this->conditions) - 1; } diff --git a/core/lib/Drupal/Core/Database/Query/InsertTrait.php b/core/lib/Drupal/Core/Database/Query/InsertTrait.php index 808c9f53a11..a429c88eead 100644 --- a/core/lib/Drupal/Core/Database/Query/InsertTrait.php +++ b/core/lib/Drupal/Core/Database/Query/InsertTrait.php @@ -179,7 +179,8 @@ trait InsertTrait { /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return count($this->insertValues); } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 5371bdfd165..52b96742567 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -687,7 +687,8 @@ abstract class ContentEntityBase extends EntityBase implements \IteratorAggregat /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->getFields()); } diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php index 46c15afc72a..a30106029fc 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php @@ -69,7 +69,8 @@ class ConfigEntityAdapter extends EntityAdapter { /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { if (isset($this->entity)) { return $this->getConfigTypedData()->getIterator(); } diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php index 154c1c4e083..602278487e4 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php @@ -162,7 +162,8 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return $this->entity instanceof \IteratorAggregate ? $this->entity->getIterator() : new \ArrayIterator([]); } diff --git a/core/lib/Drupal/Core/GeneratedLink.php b/core/lib/Drupal/Core/GeneratedLink.php index 7bebcbaf31d..0c484836f11 100644 --- a/core/lib/Drupal/Core/GeneratedLink.php +++ b/core/lib/Drupal/Core/GeneratedLink.php @@ -58,14 +58,16 @@ class GeneratedLink extends BubbleableMetadata implements MarkupInterface, \Coun /** * {@inheritdoc} */ - public function jsonSerialize(): string { + #[\ReturnTypeWillChange] + public function jsonSerialize() { return $this->__toString(); } /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return mb_strlen($this->__toString()); } diff --git a/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php b/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php index 3c1f61ece10..d18340d754b 100644 --- a/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php +++ b/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php @@ -43,35 +43,40 @@ class WriteSafeSessionHandler implements \SessionHandlerInterface, WriteSafeSess /** * {@inheritdoc} */ - public function close(): bool { + #[\ReturnTypeWillChange] + public function close() { return $this->wrappedSessionHandler->close(); } /** * {@inheritdoc} */ - public function destroy($session_id): bool { + #[\ReturnTypeWillChange] + public function destroy($session_id) { return $this->wrappedSessionHandler->destroy($session_id); } /** * {@inheritdoc} */ - public function gc($max_lifetime): int|FALSE { + #[\ReturnTypeWillChange] + public function gc($max_lifetime) { return $this->wrappedSessionHandler->gc($max_lifetime); } /** * {@inheritdoc} */ - public function open($save_path, $session_id): bool { + #[\ReturnTypeWillChange] + public function open($save_path, $session_id) { return $this->wrappedSessionHandler->open($save_path, $session_id); } /** * {@inheritdoc} */ - public function read($session_id): string|FALSE { + #[\ReturnTypeWillChange] + public function read($session_id) { $value = $this->wrappedSessionHandler->read($session_id); $this->readSessions[$session_id] = $value; return $value; @@ -80,7 +85,8 @@ class WriteSafeSessionHandler implements \SessionHandlerInterface, WriteSafeSess /** * {@inheritdoc} */ - public function write($session_id, $session_data): bool { + #[\ReturnTypeWillChange] + public function write($session_id, $session_data) { // Only write the session when it has been modified. if (isset($this->readSessions[$session_id]) && $this->readSessions[$session_id] === $session_data) { return TRUE; diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index a08fdafd17c..6a6759d1dba 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -90,17 +90,18 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { /** * {@inheritdoc} */ - public function offsetGet($name): mixed { + #[\ReturnTypeWillChange] + public function offsetGet($name) { if (isset($this->storage[$name])) { return $this->storage[$name]; } - return NULL; } /** * {@inheritdoc} */ - public function offsetSet($name, $value): void { + #[\ReturnTypeWillChange] + public function offsetSet($name, $value) { $this->storage[$name] = $this->createAttributeValue($name, $value); } @@ -153,14 +154,16 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { /** * {@inheritdoc} */ - public function offsetUnset($name): void { + #[\ReturnTypeWillChange] + public function offsetUnset($name) { unset($this->storage[$name]); } /** * {@inheritdoc} */ - public function offsetExists($name): bool { + #[\ReturnTypeWillChange] + public function offsetExists($name) { return isset($this->storage[$name]); } @@ -355,7 +358,8 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->storage); } @@ -372,7 +376,8 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { * @return string * The safe string content. */ - public function jsonSerialize(): string { + #[\ReturnTypeWillChange] + public function jsonSerialize() { return (string) $this; } diff --git a/core/lib/Drupal/Core/Template/AttributeArray.php b/core/lib/Drupal/Core/Template/AttributeArray.php index 2f003f2de6e..71127f00471 100644 --- a/core/lib/Drupal/Core/Template/AttributeArray.php +++ b/core/lib/Drupal/Core/Template/AttributeArray.php @@ -35,14 +35,16 @@ class AttributeArray extends AttributeValueBase implements \ArrayAccess, \Iterat /** * {@inheritdoc} */ - public function offsetGet($offset): mixed { + #[\ReturnTypeWillChange] + public function offsetGet($offset) { return $this->value[$offset]; } /** * {@inheritdoc} */ - public function offsetSet($offset, $value): void { + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) { if (isset($offset)) { $this->value[$offset] = $value; } @@ -54,14 +56,16 @@ class AttributeArray extends AttributeValueBase implements \ArrayAccess, \Iterat /** * {@inheritdoc} */ - public function offsetUnset($offset): void { + #[\ReturnTypeWillChange] + public function offsetUnset($offset) { unset($this->value[$offset]); } /** * {@inheritdoc} */ - public function offsetExists($offset): bool { + #[\ReturnTypeWillChange] + public function offsetExists($offset) { return isset($this->value[$offset]); } @@ -77,7 +81,8 @@ class AttributeArray extends AttributeValueBase implements \ArrayAccess, \Iterat /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->value); } diff --git a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php index 8e31e3d1c62..f1d4d4236b2 100644 --- a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php +++ b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php @@ -118,7 +118,8 @@ trait ComputedItemListTrait { /** * {@inheritdoc} */ - public function offsetExists($offset): bool { + #[\ReturnTypeWillChange] + public function offsetExists($offset) { $this->ensureComputedValue(); return parent::offsetExists($offset); } @@ -126,7 +127,8 @@ trait ComputedItemListTrait { /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { $this->ensureComputedValue(); return parent::getIterator(); } @@ -134,7 +136,8 @@ trait ComputedItemListTrait { /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { $this->ensureComputedValue(); return parent::count(); } diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index a00adefe1c4..a82f819b4cd 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -314,7 +314,8 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - public function offsetExists($offset): bool { + #[\ReturnTypeWillChange] + public function offsetExists($offset) { // PHP's array access does not work correctly with isset(), so we have to // bake isset() in here. See https://bugs.php.net/bug.php?id=41727. return array_key_exists($offset, $this->definition) && isset($this->definition[$offset]); @@ -326,7 +327,8 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - public function &offsetGet($offset): mixed { + #[\ReturnTypeWillChange] + public function &offsetGet($offset) { if (!isset($this->definition[$offset])) { $this->definition[$offset] = NULL; } @@ -339,7 +341,8 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - public function offsetSet($offset, $value): void { + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) { $this->definition[$offset] = $value; } @@ -349,7 +352,8 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - public function offsetUnset($offset): void { + #[\ReturnTypeWillChange] + public function offsetUnset($offset) { unset($this->definition[$offset]); } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php index ee648a50f86..0e6a377bc67 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php @@ -170,7 +170,8 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface { /** * {@inheritdoc} */ - public function offsetExists($offset): bool { + #[\ReturnTypeWillChange] + public function offsetExists($offset) { // We do not want to throw exceptions here, so we do not use get(). return isset($this->list[$offset]); } @@ -178,21 +179,24 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface { /** * {@inheritdoc} */ - public function offsetUnset($offset): void { + #[\ReturnTypeWillChange] + public function offsetUnset($offset) { $this->removeItem($offset); } /** * {@inheritdoc} */ - public function offsetGet($offset): mixed { + #[\ReturnTypeWillChange] + public function offsetGet($offset) { return $this->get($offset); } /** * {@inheritdoc} */ - public function offsetSet($offset, $value): void { + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) { if (!isset($offset)) { // The [] operator has been used. $this->appendItem($value); @@ -231,14 +235,16 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface { /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->list); } /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return count($this->list); } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php index e08e9312e0c..e216ceb7757 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php @@ -183,7 +183,8 @@ class Map extends TypedData implements \IteratorAggregate, ComplexDataInterface /** * {@inheritdoc} */ - public function getIterator(): \ArrayIterator { + #[\ReturnTypeWillChange] + public function getIterator() { return new \ArrayIterator($this->getProperties()); } diff --git a/core/modules/comment/src/CommentFieldItemList.php b/core/modules/comment/src/CommentFieldItemList.php index 53420df3e78..985f8652250 100644 --- a/core/modules/comment/src/CommentFieldItemList.php +++ b/core/modules/comment/src/CommentFieldItemList.php @@ -30,7 +30,8 @@ class CommentFieldItemList extends FieldItemList { /** * {@inheritdoc} */ - public function offsetExists($offset): bool { + #[\ReturnTypeWillChange] + public function offsetExists($offset) { // For consistency with what happens in get(), we force offsetExists() to // be TRUE for delta 0. if ($offset === 0) { diff --git a/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php b/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php index 3f9d07c860d..93f8637a564 100644 --- a/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php @@ -38,7 +38,8 @@ abstract class SectionStorageBase extends PluginBase implements SectionStorageIn /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { return $this->getSectionList()->count(); } diff --git a/core/modules/layout_builder/src/SectionListTrait.php b/core/modules/layout_builder/src/SectionListTrait.php index 7a049dec6c4..3a2947b99e1 100644 --- a/core/modules/layout_builder/src/SectionListTrait.php +++ b/core/modules/layout_builder/src/SectionListTrait.php @@ -25,7 +25,8 @@ trait SectionListTrait { /** * {@inheritdoc} */ - public function count(): int { + #[\ReturnTypeWillChange] + public function count() { if ($this->hasBlankSection()) { return 0; } diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php index b9261d09894..54d55cfb033 100644 --- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -913,7 +913,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP * * This is called before beginning a foreach loop. */ - public function rewind(): void { + #[\ReturnTypeWillChange] + public function rewind() { $this->currentRow = NULL; $fields = []; foreach ($this->sourceIdFields() as $field) { @@ -934,7 +935,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP * * This is called when entering a loop iteration, returning the current row. */ - public function current(): mixed { + #[\ReturnTypeWillChange] + public function current() { return $this->currentRow; } @@ -945,7 +947,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP * current row. It must be a scalar - we will serialize to fulfill the * requirement, but using getCurrentKey() is preferable. */ - public function key(): mixed { + #[\ReturnTypeWillChange] + public function key() { return serialize($this->currentKey); } @@ -989,7 +992,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP * This is called at the bottom of the loop implicitly, as well as explicitly * from rewind(). */ - public function next(): void { + #[\ReturnTypeWillChange] + public function next() { $this->currentRow = $this->result->fetchAssoc(); $this->currentKey = []; if ($this->currentRow) { @@ -1007,7 +1011,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP * This is called at the top of the loop, returning TRUE to process the loop * and FALSE to terminate it. */ - public function valid(): bool { + #[\ReturnTypeWillChange] + public function valid() { return $this->currentRow !== FALSE; } diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php index 90a66e45ed8..3191c7256d4 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php @@ -343,7 +343,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter /** * {@inheritdoc} */ - public function current(): mixed { + #[\ReturnTypeWillChange] + public function current() { return $this->currentRow; } @@ -355,7 +356,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter * serialize to fulfill the requirement, but using getCurrentIds() is * preferable. */ - public function key(): mixed { + #[\ReturnTypeWillChange] + public function key() { return serialize($this->currentSourceIds); } @@ -365,7 +367,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter * Implementation of \Iterator::valid() - called at the top of the loop, * returning TRUE to process the loop and FALSE to terminate it. */ - public function valid(): bool { + #[\ReturnTypeWillChange] + public function valid() { return isset($this->currentRow); } @@ -376,7 +379,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter * should implement initializeIterator() to do any class-specific setup for * iterating source records. */ - public function rewind(): void { + #[\ReturnTypeWillChange] + public function rewind() { $this->getIterator()->rewind(); $this->next(); } @@ -384,7 +388,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter /** * {@inheritdoc} */ - public function next(): void { + #[\ReturnTypeWillChange] + public function next() { $this->currentSourceIds = NULL; $this->currentRow = NULL; diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php index f6ce4a00b11..773919205fa 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -448,7 +448,8 @@ class MigrateExecutableTest extends MigrateTestCase { ->onlyMethods(get_class_methods($class)) ->getMockForAbstractClass(); $source->expects($this->once()) - ->method('rewind'); + ->method('rewind') + ->willReturn(TRUE); $source->expects($this->any()) ->method('initializeIterator') ->willReturn([]); diff --git a/core/tests/Drupal/Tests/StreamCapturer.php b/core/tests/Drupal/Tests/StreamCapturer.php index 2be2ef60f4f..eb7d54aa9b7 100644 --- a/core/tests/Drupal/Tests/StreamCapturer.php +++ b/core/tests/Drupal/Tests/StreamCapturer.php @@ -11,7 +11,8 @@ class StreamCapturer extends \php_user_filter { public static $cache = ''; - public function filter($in, $out, &$consumed, $closing): int { + #[\ReturnTypeWillChange] + public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { self::$cache .= $bucket->data; // cSpell:disable-next-line