diff --git a/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php b/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php index a1bacf597d77e4e099524d4df2e4070b93216e29..c6e89ef4c79190d12f8d15f713c67de3315b5b3f 100644 --- a/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php +++ b/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php @@ -115,8 +115,7 @@ protected function checkListHasItemWithContent(array $scaffold_files) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->scaffoldFilesByProject); } diff --git a/core/.deprecation-ignore.txt b/core/.deprecation-ignore.txt index 6198b95d4e57ca94db8ff049d511587b62b792d1..1650f6f8a8b6999316cadb68f0e6a224c10d77bd 100644 --- a/core/.deprecation-ignore.txt +++ b/core/.deprecation-ignore.txt @@ -19,10 +19,6 @@ %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 b0e60706962a962d3d8b71de23a4084595b6c0b0..87acb3dd4002ad42d125f1855fcacbb51b7a928c 100644 --- a/core/lib/Drupal/Component/Annotation/Doctrine/StaticReflectionClass.php +++ b/core/lib/Drupal/Component/Annotation/Doctrine/StaticReflectionClass.php @@ -47,8 +47,7 @@ public function __construct(StaticReflectionParser $staticReflectionParser) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getName() + public function getName(): string { return $this->staticReflectionParser->getClassName(); } @@ -56,8 +55,7 @@ public function getName() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getDocComment() + public function getDocComment(): string|FALSE { return $this->staticReflectionParser->getDocComment(); } @@ -65,8 +63,7 @@ public function getDocComment() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getNamespaceName() + public function getNamespaceName(): string { return $this->staticReflectionParser->getNamespaceName(); } @@ -94,8 +91,7 @@ public function hasClassAttribute(string $attribute) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getMethod($name) + public function getMethod($name): \ReflectionMethod { throw new ReflectionException('Method not implemented'); } @@ -103,8 +99,7 @@ public function getMethod($name) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getProperty($name) + public function getProperty($name): \ReflectionProperty { throw new ReflectionException('Method not implemented'); } @@ -120,8 +115,7 @@ public static function export($argument, $return = false) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getConstant($name) + public function getConstant($name): mixed { throw new ReflectionException('Method not implemented'); } @@ -129,8 +123,7 @@ public function getConstant($name) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getConstructor() + public function getConstructor(): ?\ReflectionMethod { throw new ReflectionException('Method not implemented'); } @@ -138,8 +131,7 @@ public function getConstructor() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getDefaultProperties() + public function getDefaultProperties(): array { throw new ReflectionException('Method not implemented'); } @@ -147,8 +139,7 @@ public function getDefaultProperties() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getEndLine() + public function getEndLine(): int|FALSE { throw new ReflectionException('Method not implemented'); } @@ -156,8 +147,7 @@ public function getEndLine() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getExtension() + public function getExtension(): ?\ReflectionExtension { throw new ReflectionException('Method not implemented'); } @@ -165,8 +155,7 @@ public function getExtension() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getExtensionName() + public function getExtensionName(): string|FALSE { throw new ReflectionException('Method not implemented'); } @@ -174,8 +163,7 @@ public function getExtensionName() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getFileName() + public function getFileName(): string|FALSE { throw new ReflectionException('Method not implemented'); } @@ -183,8 +171,7 @@ public function getFileName() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getInterfaceNames() + public function getInterfaceNames(): array { throw new ReflectionException('Method not implemented'); } @@ -192,8 +179,7 @@ public function getInterfaceNames() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getInterfaces() + public function getInterfaces(): array { throw new ReflectionException('Method not implemented'); } @@ -201,8 +187,7 @@ public function getInterfaces() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getMethods($filter = null) + public function getMethods($filter = null): array { throw new ReflectionException('Method not implemented'); } @@ -210,8 +195,7 @@ public function getMethods($filter = null) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getModifiers() + public function getModifiers(): int { throw new ReflectionException('Method not implemented'); } @@ -219,8 +203,7 @@ public function getModifiers() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getParentClass() + public function getParentClass(): \ReflectionClass|FALSE { throw new ReflectionException('Method not implemented'); } @@ -228,8 +211,7 @@ public function getParentClass() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getProperties($filter = null) + public function getProperties($filter = null): array { throw new ReflectionException('Method not implemented'); } @@ -237,8 +219,7 @@ public function getProperties($filter = null) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getShortName() + public function getShortName(): string { throw new ReflectionException('Method not implemented'); } @@ -246,8 +227,7 @@ public function getShortName() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getStartLine() + public function getStartLine(): int|FALSE { throw new ReflectionException('Method not implemented'); } @@ -255,8 +235,7 @@ public function getStartLine() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getStaticProperties() + public function getStaticProperties(): ?array { throw new ReflectionException('Method not implemented'); } @@ -264,8 +243,7 @@ public function getStaticProperties() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getStaticPropertyValue($name, $default = '') + public function getStaticPropertyValue($name, $default = ''): mixed { throw new ReflectionException('Method not implemented'); } @@ -273,8 +251,7 @@ public function getStaticPropertyValue($name, $default = '') /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getTraitAliases() + public function getTraitAliases(): array { throw new ReflectionException('Method not implemented'); } @@ -282,8 +259,7 @@ public function getTraitAliases() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getTraitNames() + public function getTraitNames(): array { throw new ReflectionException('Method not implemented'); } @@ -291,8 +267,7 @@ public function getTraitNames() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getTraits() + public function getTraits(): array { throw new ReflectionException('Method not implemented'); } @@ -300,8 +275,7 @@ public function getTraits() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function hasConstant($name) + public function hasConstant($name): bool { throw new ReflectionException('Method not implemented'); } @@ -309,8 +283,7 @@ public function hasConstant($name) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function hasMethod($name) + public function hasMethod($name): bool { throw new ReflectionException('Method not implemented'); } @@ -318,8 +291,7 @@ public function hasMethod($name) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function hasProperty($name) + public function hasProperty($name): bool { throw new ReflectionException('Method not implemented'); } @@ -327,8 +299,7 @@ public function hasProperty($name) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function implementsInterface($interface) + public function implementsInterface($interface): bool { throw new ReflectionException('Method not implemented'); } @@ -336,8 +307,7 @@ public function implementsInterface($interface) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function inNamespace() + public function inNamespace(): bool { throw new ReflectionException('Method not implemented'); } @@ -345,8 +315,7 @@ public function inNamespace() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isAbstract() + public function isAbstract(): bool { throw new ReflectionException('Method not implemented'); } @@ -354,8 +323,7 @@ public function isAbstract() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isCloneable() + public function isCloneable(): bool { throw new ReflectionException('Method not implemented'); } @@ -363,8 +331,7 @@ public function isCloneable() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isFinal() + public function isFinal(): bool { throw new ReflectionException('Method not implemented'); } @@ -372,8 +339,7 @@ public function isFinal() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isInstance($object) + public function isInstance($object): bool { throw new ReflectionException('Method not implemented'); } @@ -381,8 +347,7 @@ public function isInstance($object) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isInstantiable() + public function isInstantiable(): bool { throw new ReflectionException('Method not implemented'); } @@ -390,8 +355,7 @@ public function isInstantiable() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isInterface() + public function isInterface(): bool { throw new ReflectionException('Method not implemented'); } @@ -399,8 +363,7 @@ public function isInterface() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isInternal() + public function isInternal(): bool { throw new ReflectionException('Method not implemented'); } @@ -408,8 +371,7 @@ public function isInternal() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isIterateable() + public function isIterateable(): bool { throw new ReflectionException('Method not implemented'); } @@ -417,8 +379,7 @@ public function isIterateable() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isSubclassOf($class) + public function isSubclassOf($class): bool { throw new ReflectionException('Method not implemented'); } @@ -426,8 +387,7 @@ public function isSubclassOf($class) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isTrait() + public function isTrait(): bool { throw new ReflectionException('Method not implemented'); } @@ -435,8 +395,7 @@ public function isTrait() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function isUserDefined() + public function isUserDefined(): bool { throw new ReflectionException('Method not implemented'); } @@ -444,8 +403,7 @@ public function isUserDefined() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function newInstanceArgs(array $args = []) + public function newInstanceArgs(array $args = []): ?object { throw new ReflectionException('Method not implemented'); } @@ -453,8 +411,7 @@ public function newInstanceArgs(array $args = []) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function newInstanceWithoutConstructor() + public function newInstanceWithoutConstructor(): object { throw new ReflectionException('Method not implemented'); } @@ -462,8 +419,7 @@ public function newInstanceWithoutConstructor() /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function setStaticPropertyValue($name, $value) + public function setStaticPropertyValue($name, $value): void { throw new ReflectionException('Method not implemented'); } @@ -471,8 +427,7 @@ public function setStaticPropertyValue($name, $value) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getConstants(?int $filter = null) + public function getConstants(?int $filter = null): array { throw new ReflectionException('Method not implemented'); } @@ -480,8 +435,7 @@ public function getConstants(?int $filter = null) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function newInstance(mixed ...$args) + public function newInstance(mixed ...$args): object { 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 cfa616ae1bf5b65dad8d48f067677f926ff5cea9..cc17aa643c5ef8a3acf10e9b2c86d166be8e4cdb 100644 --- a/core/lib/Drupal/Component/FileSystem/RegexDirectoryIterator.php +++ b/core/lib/Drupal/Component/FileSystem/RegexDirectoryIterator.php @@ -23,8 +23,7 @@ public function __construct($path, $regex) { /** * Implements \RegexIterator::accept(). */ - #[\ReturnTypeWillChange] - public function accept() { + public function accept(): bool { /** @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 6574c5b3daec9224dcbcffd44990965ac6032c88..db5b8755051c1596d4eeca0a7c94e16301a709b5 100644 --- a/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php +++ b/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php @@ -142,8 +142,7 @@ public function removeInstanceId($instance_id) { $this->remove($instance_id); } - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { $instances = []; foreach ($this->getInstanceIds() as $instance_id) { $instances[$instance_id] = $this->get($instance_id); @@ -154,8 +153,7 @@ public function getIterator() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { return count($this->instanceIds); } diff --git a/core/lib/Drupal/Component/Render/HtmlEscapedText.php b/core/lib/Drupal/Component/Render/HtmlEscapedText.php index d5121bfb9f287608fbb6a24188e9c85f5d5e817a..6ca9538089e62d688429fb52ac618a2878e0a0a7 100644 --- a/core/lib/Drupal/Component/Render/HtmlEscapedText.php +++ b/core/lib/Drupal/Component/Render/HtmlEscapedText.php @@ -41,16 +41,14 @@ public function __toString() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { return mb_strlen($this->string); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function jsonSerialize() { + public function jsonSerialize(): string { return $this->__toString(); } diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php index e9e4998010bd9ee06e5bc60cdaa97ac1a91de008..11fc9aca2414d733946e58cd37e50423ed602342 100644 --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -114,8 +114,7 @@ public function onChange($name) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { 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 fcd0b5dfba3032d9b83486e78588582588a10fd7..377d45cb59d567e793045628cab02c9dec19a9d0 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -90,8 +90,7 @@ public function __construct($conjunction) { * size of its conditional array minus one, because one element is the * conjunction. */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { 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 a429c88eead602b8552d4a758db5a77c4ac50883..808c9f53a117773becf370d44d71fdc8266d6229 100644 --- a/core/lib/Drupal/Core/Database/Query/InsertTrait.php +++ b/core/lib/Drupal/Core/Database/Query/InsertTrait.php @@ -179,8 +179,7 @@ protected function getInsertPlaceholderFragment(array $nested_insert_values, arr /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { return count($this->insertValues); } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 52b96742567625b154cc1d7408c9db43c09fb14e..5371bdfd1655f933b51ab2b64aeeb7a6ef7d670c 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -687,8 +687,7 @@ public function getTranslatableFields($include_computed = TRUE) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { 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 a30106029fcb7a8d403f1da26e16b918a071758e..46c15afc72a8a385d11162b190ab9ef84576c9d2 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php @@ -69,8 +69,7 @@ public function onChange($property_name) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { 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 602278487e40e505d601b9b70069bbbbcb97fd77..154c1c4e083bebbeb5487d70548fee6bf59db87d 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php @@ -162,8 +162,7 @@ public function applyDefaultValue($notify = TRUE) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { 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 0c484836f11f94ea39c33c5c052ee9cfdb1aaa19..7bebcbaf31d800d775485fb2d1d7a98bedd4f084 100644 --- a/core/lib/Drupal/Core/GeneratedLink.php +++ b/core/lib/Drupal/Core/GeneratedLink.php @@ -58,16 +58,14 @@ public function __toString() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function jsonSerialize() { + public function jsonSerialize(): string { return $this->__toString(); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { return mb_strlen($this->__toString()); } diff --git a/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php b/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php index d18340d754b7792d8a1dabc97a97c2622f20d3d7..3c1f61ece10a9814b654c6df985019c326b3548c 100644 --- a/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php +++ b/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php @@ -43,40 +43,35 @@ public function __construct(\SessionHandlerInterface $wrapped_session_handler, $ /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function close() { + public function close(): bool { return $this->wrappedSessionHandler->close(); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function destroy($session_id) { + public function destroy($session_id): bool { return $this->wrappedSessionHandler->destroy($session_id); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function gc($max_lifetime) { + public function gc($max_lifetime): int|FALSE { return $this->wrappedSessionHandler->gc($max_lifetime); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function open($save_path, $session_id) { + public function open($save_path, $session_id): bool { return $this->wrappedSessionHandler->open($save_path, $session_id); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function read($session_id) { + public function read($session_id): string|FALSE { $value = $this->wrappedSessionHandler->read($session_id); $this->readSessions[$session_id] = $value; return $value; @@ -85,8 +80,7 @@ public function read($session_id) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function write($session_id, $session_data) { + public function write($session_id, $session_data): bool { // 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 6a6759d1dbadbe1c42f51467a45aae8fa6142b1e..a08fdafd17c23d17b51e5fa02ec188cb7b228f96 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -90,18 +90,17 @@ public function __construct($attributes = []) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetGet($name) { + public function offsetGet($name): mixed { if (isset($this->storage[$name])) { return $this->storage[$name]; } + return NULL; } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetSet($name, $value) { + public function offsetSet($name, $value): void { $this->storage[$name] = $this->createAttributeValue($name, $value); } @@ -154,16 +153,14 @@ protected function createAttributeValue($name, $value) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetUnset($name) { + public function offsetUnset($name): void { unset($this->storage[$name]); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetExists($name) { + public function offsetExists($name): bool { return isset($this->storage[$name]); } @@ -358,8 +355,7 @@ public function __clone() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->storage); } @@ -376,8 +372,7 @@ public function storage() { * @return string * The safe string content. */ - #[\ReturnTypeWillChange] - public function jsonSerialize() { + public function jsonSerialize(): string { return (string) $this; } diff --git a/core/lib/Drupal/Core/Template/AttributeArray.php b/core/lib/Drupal/Core/Template/AttributeArray.php index 71127f00471d4c32a47e147823a3ac811825bde1..2f003f2de6e4555571d3926228767a6bdf34969f 100644 --- a/core/lib/Drupal/Core/Template/AttributeArray.php +++ b/core/lib/Drupal/Core/Template/AttributeArray.php @@ -35,16 +35,14 @@ class AttributeArray extends AttributeValueBase implements \ArrayAccess, \Iterat /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) { + public function offsetGet($offset): mixed { return $this->value[$offset]; } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { if (isset($offset)) { $this->value[$offset] = $value; } @@ -56,16 +54,14 @@ public function offsetSet($offset, $value) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset) { + public function offsetUnset($offset): void { unset($this->value[$offset]); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->value[$offset]); } @@ -81,8 +77,7 @@ public function __toString() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->value); } diff --git a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php index f1d4d4236b2e2d62f23ae1b7afa449790acd6dd8..8e31e3d1c6296ce99b1ee57d38534c3df8862f4b 100644 --- a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php +++ b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php @@ -118,8 +118,7 @@ public function isEmpty() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetExists($offset) { + public function offsetExists($offset): bool { $this->ensureComputedValue(); return parent::offsetExists($offset); } @@ -127,8 +126,7 @@ public function offsetExists($offset) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { $this->ensureComputedValue(); return parent::getIterator(); } @@ -136,8 +134,7 @@ public function getIterator() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { $this->ensureComputedValue(); return parent::count(); } diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index a82f819b4cde82b7021259c442c92112de51064d..a00adefe1c48765db0a8b92f00ec405a3364d0e8 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -314,8 +314,7 @@ public function addConstraint($constraint_name, $options = NULL) { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - #[\ReturnTypeWillChange] - public function offsetExists($offset) { + public function offsetExists($offset): bool { // 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]); @@ -327,8 +326,7 @@ public function offsetExists($offset) { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - #[\ReturnTypeWillChange] - public function &offsetGet($offset) { + public function &offsetGet($offset): mixed { if (!isset($this->definition[$offset])) { $this->definition[$offset] = NULL; } @@ -341,8 +339,7 @@ public function &offsetGet($offset) { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->definition[$offset] = $value; } @@ -352,8 +349,7 @@ public function offsetSet($offset, $value) { * This is for BC support only. * @todo: Remove in https://www.drupal.org/node/1928868. */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset) { + public function offsetUnset($offset): void { 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 0e6a377bc6784933c07bc8813ac80be26d037eac..ee648a50f86f98de5478824bfd56e2f4839a4407 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php @@ -170,8 +170,7 @@ public function first() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetExists($offset) { + public function offsetExists($offset): bool { // We do not want to throw exceptions here, so we do not use get(). return isset($this->list[$offset]); } @@ -179,24 +178,21 @@ public function offsetExists($offset) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset) { + public function offsetUnset($offset): void { $this->removeItem($offset); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) { + public function offsetGet($offset): mixed { return $this->get($offset); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { if (!isset($offset)) { // The [] operator has been used. $this->appendItem($value); @@ -235,16 +231,14 @@ public function getItemDefinition() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->list); } /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { 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 e216ceb775717eb00a744203a9b3995ce6f825c4..e08e9312e0c7760d6dc5e6b8569e42e707259d77 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php @@ -183,8 +183,7 @@ public function toArray() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function getIterator() { + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->getProperties()); } diff --git a/core/modules/comment/src/CommentFieldItemList.php b/core/modules/comment/src/CommentFieldItemList.php index 985f8652250dbf816475f0968eea80b67994c3eb..53420df3e78bacda3172be43a19140947fae82ee 100644 --- a/core/modules/comment/src/CommentFieldItemList.php +++ b/core/modules/comment/src/CommentFieldItemList.php @@ -30,8 +30,7 @@ public function get($index) { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function offsetExists($offset) { + public function offsetExists($offset): bool { // 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 93f8637a564ab417868effad00f3906b28c39e5e..3f9d07c860d5a3a388ee8aa550130841989e36f0 100644 --- a/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php @@ -38,8 +38,7 @@ public function getStorageType() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { return $this->getSectionList()->count(); } diff --git a/core/modules/layout_builder/src/SectionListTrait.php b/core/modules/layout_builder/src/SectionListTrait.php index 3a2947b99e18691dac56003462c8f56092f47dd2..7a049dec6c40cabdf30343afedd0477d81e4786d 100644 --- a/core/modules/layout_builder/src/SectionListTrait.php +++ b/core/modules/layout_builder/src/SectionListTrait.php @@ -25,8 +25,7 @@ abstract protected function setSections(array $sections); /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function count() { + public function count(): int { 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 54d55cfb0332567419525b80bb62ffa1025b07f3..b9261d098943762007b561e63afa302b293de1ba 100644 --- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -913,8 +913,7 @@ public function destroy() { * * This is called before beginning a foreach loop. */ - #[\ReturnTypeWillChange] - public function rewind() { + public function rewind(): void { $this->currentRow = NULL; $fields = []; foreach ($this->sourceIdFields() as $field) { @@ -935,8 +934,7 @@ public function rewind() { * * This is called when entering a loop iteration, returning the current row. */ - #[\ReturnTypeWillChange] - public function current() { + public function current(): mixed { return $this->currentRow; } @@ -947,8 +945,7 @@ public function current() { * current row. It must be a scalar - we will serialize to fulfill the * requirement, but using getCurrentKey() is preferable. */ - #[\ReturnTypeWillChange] - public function key() { + public function key(): mixed { return serialize($this->currentKey); } @@ -992,8 +989,7 @@ public function currentSource() { * This is called at the bottom of the loop implicitly, as well as explicitly * from rewind(). */ - #[\ReturnTypeWillChange] - public function next() { + public function next(): void { $this->currentRow = $this->result->fetchAssoc(); $this->currentKey = []; if ($this->currentRow) { @@ -1011,8 +1007,7 @@ public function next() { * This is called at the top of the loop, returning TRUE to process the loop * and FALSE to terminate it. */ - #[\ReturnTypeWillChange] - public function valid() { + public function valid(): bool { 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 3191c7256d4a3494152ed4e16418da8a51df810c..90a66e45ed8a2bd493a73550aa5b29b21befe512 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php @@ -343,8 +343,7 @@ protected function getIterator() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function current() { + public function current(): mixed { return $this->currentRow; } @@ -356,8 +355,7 @@ public function current() { * serialize to fulfill the requirement, but using getCurrentIds() is * preferable. */ - #[\ReturnTypeWillChange] - public function key() { + public function key(): mixed { return serialize($this->currentSourceIds); } @@ -367,8 +365,7 @@ public function key() { * Implementation of \Iterator::valid() - called at the top of the loop, * returning TRUE to process the loop and FALSE to terminate it. */ - #[\ReturnTypeWillChange] - public function valid() { + public function valid(): bool { return isset($this->currentRow); } @@ -379,8 +376,7 @@ public function valid() { * should implement initializeIterator() to do any class-specific setup for * iterating source records. */ - #[\ReturnTypeWillChange] - public function rewind() { + public function rewind(): void { $this->getIterator()->rewind(); $this->next(); } @@ -388,8 +384,7 @@ public function rewind() { /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] - public function next() { + public function next(): void { $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 773919205fa1ccbf098d6efce3aa59086fc76198..f6ce4a00b11363187436499663dfc002e6f3ebc8 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -448,8 +448,7 @@ protected function getMockSource() { ->onlyMethods(get_class_methods($class)) ->getMockForAbstractClass(); $source->expects($this->once()) - ->method('rewind') - ->willReturn(TRUE); + ->method('rewind'); $source->expects($this->any()) ->method('initializeIterator') ->willReturn([]); diff --git a/core/tests/Drupal/Tests/StreamCapturer.php b/core/tests/Drupal/Tests/StreamCapturer.php index eb7d54aa9b7633f6f12da61f3dbb0189f59caa80..2be2ef60f4f0f2d81f3a7e4b15d40f82ed7dd2e6 100644 --- a/core/tests/Drupal/Tests/StreamCapturer.php +++ b/core/tests/Drupal/Tests/StreamCapturer.php @@ -11,8 +11,7 @@ class StreamCapturer extends \php_user_filter { public static $cache = ''; - #[\ReturnTypeWillChange] - public function filter($in, $out, &$consumed, $closing) { + public function filter($in, $out, &$consumed, $closing): int { while ($bucket = stream_bucket_make_writeable($in)) { self::$cache .= $bucket->data; // cSpell:disable-next-line