From 3eca446b21607ea1c7a865ece2dd8254c33679cc Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 26 Jul 2021 15:29:22 +0200 Subject: [PATCH] Fix return types for PHP 8.1 --- .../Constraints/UniqueEntityValidatorTest.php | 26 ++++++++++++++++--- .../Bundle/TwigBundle/TemplateIterator.php | 1 + .../Config/Resource/GlobResource.php | 1 + .../Component/Console/Helper/HelperSet.php | 3 ++- src/Symfony/Component/DomCrawler/Crawler.php | 2 ++ src/Symfony/Component/DomCrawler/Form.php | 4 +++ .../EventDispatcher/GenericEvent.php | 5 ++++ src/Symfony/Component/Finder/Finder.php | 2 ++ .../Finder/Iterator/CustomFilterIterator.php | 1 + .../Iterator/DateRangeFilterIterator.php | 1 + .../Iterator/DepthRangeFilterIterator.php | 1 + .../ExcludeDirectoryFilterIterator.php | 3 +++ .../Iterator/FileTypeFilterIterator.php | 1 + .../Iterator/FilecontentFilterIterator.php | 1 + .../Iterator/FilenameFilterIterator.php | 1 + .../Finder/Iterator/PathFilterIterator.php | 1 + .../Iterator/SizeRangeFilterIterator.php | 1 + .../Finder/Iterator/SortableIterator.php | 1 + .../Finder/Tests/Iterator/Iterator.php | 14 +++++++--- .../MultiplePcreFilterIteratorTest.php | 2 +- src/Symfony/Component/Form/Button.php | 6 +++++ src/Symfony/Component/Form/ButtonBuilder.php | 2 ++ .../Form/ChoiceList/View/ChoiceGroupView.php | 3 ++- .../ViolationMapper/ViolationPath.php | 1 + src/Symfony/Component/Form/Form.php | 6 +++++ src/Symfony/Component/Form/FormBuilder.php | 2 ++ .../Component/Form/FormErrorIterator.php | 13 ++++++++++ src/Symfony/Component/Form/FormView.php | 6 +++++ .../Form/Tests/Fixtures/CustomArrayObject.php | 11 +++++--- .../Form/Util/InheritDataAwareIterator.php | 2 ++ .../Component/Form/Util/OrderedHashMap.php | 6 +++++ .../Form/Util/OrderedHashMapIterator.php | 10 +++---- .../Component/HttpFoundation/File/Stream.php | 1 + .../Component/HttpFoundation/HeaderBag.php | 2 ++ .../Component/HttpFoundation/ParameterBag.php | 2 ++ .../Session/Attribute/AttributeBag.php | 2 ++ .../HttpFoundation/Session/Session.php | 2 ++ .../Handler/MemcachedSessionHandler.php | 2 ++ .../HttpFoundation/Tests/File/FakeFile.php | 10 +++---- .../Util/ArrayAccessibleResourceBundle.php | 12 +++------ .../Component/Intl/Data/Util/RingBuffer.php | 5 ++-- .../Ldap/Adapter/ExtLdap/Collection.php | 1 + .../OptionsResolver/OptionsResolver.php | 5 ++++ src/Symfony/Component/Process/InputStream.php | 1 + src/Symfony/Component/Process/Process.php | 1 + .../Component/PropertyAccess/PropertyPath.php | 1 + .../Fixtures/NonTraversableArrayObject.php | 11 +++++--- .../Tests/Fixtures/TraversableArrayObject.php | 9 +++++-- .../Component/Routing/RouteCollection.php | 2 ++ .../Exception/AuthenticationException.php | 2 +- .../Component/Templating/PhpEngine.php | 4 +++ .../Validator/ConstraintViolationList.php | 6 +++++ .../Tests/Fixtures/CustomArrayObject.php | 9 +++++-- .../Component/VarDumper/Cloner/Data.php | 6 +++++ 54 files changed, 194 insertions(+), 42 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 05faff5872dd8..c0945114c9c23 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -827,6 +827,10 @@ public function resultWithEmptyIterator(): array return [ [$entity, new class() implements \Iterator { + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function current() { return null; @@ -837,19 +841,28 @@ public function valid(): bool return false; } - public function next() + public function next(): void { } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function key() { + return false; } - public function rewind() + public function rewind(): void { } }], [$entity, new class() implements \Iterator { + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function current() { return false; @@ -860,15 +873,20 @@ public function valid(): bool return false; } - public function next() + public function next(): void { } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function key() { + return false; } - public function rewind() + public function rewind(): void { } }], diff --git a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php index 8af15aa3a9f5f..b16eadc40bf54 100644 --- a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php +++ b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php @@ -45,6 +45,7 @@ public function __construct(KernelInterface $kernel, string $rootDir, array $pat /** * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { if (null !== $this->templates) { diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index 0b535682f4af3..f9429eb8f9bd9 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -102,6 +102,7 @@ public function __wakeup(): void /** * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) { diff --git a/src/Symfony/Component/Console/Helper/HelperSet.php b/src/Symfony/Component/Console/Helper/HelperSet.php index d9d73f25fc69a..9aa1e67ba8c9b 100644 --- a/src/Symfony/Component/Console/Helper/HelperSet.php +++ b/src/Symfony/Component/Console/Helper/HelperSet.php @@ -98,8 +98,9 @@ public function getCommand() } /** - * @return Helper[] + * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->helpers); diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 3f5c2a50d6fec..de7b3aedc37ae 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -1149,6 +1149,7 @@ public function getNode($position) /** * @return int */ + #[\ReturnTypeWillChange] public function count() { return \count($this->nodes); @@ -1157,6 +1158,7 @@ public function count() /** * @return \ArrayIterator|\DOMNode[] */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->nodes); diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index dbba779ced5d0..0c86116a64eca 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -321,6 +321,7 @@ public function all() * * @return bool true if the field exists, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return $this->has($name); @@ -335,6 +336,7 @@ public function offsetExists($name) * * @throws \InvalidArgumentException if the field does not exist */ + #[\ReturnTypeWillChange] public function offsetGet($name) { return $this->fields->get($name); @@ -350,6 +352,7 @@ public function offsetGet($name) * * @throws \InvalidArgumentException if the field does not exist */ + #[\ReturnTypeWillChange] public function offsetSet($name, $value) { $this->fields->set($name, $value); @@ -362,6 +365,7 @@ public function offsetSet($name, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { $this->fields->remove($name); diff --git a/src/Symfony/Component/EventDispatcher/GenericEvent.php b/src/Symfony/Component/EventDispatcher/GenericEvent.php index d86a584153ded..23333bc21284f 100644 --- a/src/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/src/Symfony/Component/EventDispatcher/GenericEvent.php @@ -123,6 +123,7 @@ public function hasArgument($key) * * @throws \InvalidArgumentException if key does not exist in $this->args */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->getArgument($key); @@ -136,6 +137,7 @@ public function offsetGet($key) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->setArgument($key, $value); @@ -148,6 +150,7 @@ public function offsetSet($key, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { if ($this->hasArgument($key)) { @@ -162,6 +165,7 @@ public function offsetUnset($key) * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return $this->hasArgument($key); @@ -172,6 +176,7 @@ public function offsetExists($key) * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->arguments); diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 92249ad902178..e1194ed695e23 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -618,6 +618,7 @@ public function in($dirs) * * @throws \LogicException if the in() method has not been called */ + #[\ReturnTypeWillChange] public function getIterator() { if (0 === \count($this->dirs) && 0 === \count($this->iterators)) { @@ -702,6 +703,7 @@ public function hasResults() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return iterator_count($this->getIterator()); diff --git a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php index a30bbd0b9d265..f85cb7bffb772 100644 --- a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php @@ -46,6 +46,7 @@ public function __construct(\Iterator $iterator, array $filters) * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { $fileinfo = $this->current(); diff --git a/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php index 2e97e00d37456..90616f471b1f7 100644 --- a/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php @@ -38,6 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators) * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { $fileinfo = $this->current(); diff --git a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php index 18e751d77b928..e96fefd961b16 100644 --- a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php @@ -38,6 +38,7 @@ public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { return $this->getInnerIterator()->getDepth() >= $this->minDepth; diff --git a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php index 366ad70cdb9bc..cf9e678771da9 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php @@ -52,6 +52,7 @@ public function __construct(\Iterator $iterator, array $directories) * * @return bool True if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) { @@ -71,6 +72,7 @@ public function accept() /** * @return bool */ + #[\ReturnTypeWillChange] public function hasChildren() { return $this->isRecursive && $this->iterator->hasChildren(); @@ -79,6 +81,7 @@ public function hasChildren() /** * @return self */ + #[\ReturnTypeWillChange] public function getChildren() { $children = new self($this->iterator->getChildren(), []); diff --git a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php index 0ea2c508802de..d054cefb9fff9 100644 --- a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php @@ -39,6 +39,7 @@ public function __construct(\Iterator $iterator, int $mode) * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { $fileinfo = $this->current(); diff --git a/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php index 81594b8774048..41eb767f7a651 100644 --- a/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php @@ -24,6 +24,7 @@ class FilecontentFilterIterator extends MultiplePcreFilterIterator * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { if (!$this->matchRegexps && !$this->noMatchRegexps) { diff --git a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php index e168cd8ffa798..8365756c15209 100644 --- a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php @@ -25,6 +25,7 @@ class FilenameFilterIterator extends MultiplePcreFilterIterator * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { return $this->isAccepted($this->current()->getFilename()); diff --git a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php index 3fda557be366b..f4aaa1fb0027d 100644 --- a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php @@ -24,6 +24,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { $filename = $this->current()->getRelativePathname(); diff --git a/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php index 2aeef67b87f73..4078f3692e052 100644 --- a/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php @@ -38,6 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators) * * @return bool true if the value should be kept, false otherwise */ + #[\ReturnTypeWillChange] public function accept() { $fileinfo = $this->current(); diff --git a/src/Symfony/Component/Finder/Iterator/SortableIterator.php b/src/Symfony/Component/Finder/Iterator/SortableIterator.php index 8559ba51cd794..adc7e999db8b4 100644 --- a/src/Symfony/Component/Finder/Iterator/SortableIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SortableIterator.php @@ -81,6 +81,7 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = /** * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { if (1 === $this->sort) { diff --git a/src/Symfony/Component/Finder/Tests/Iterator/Iterator.php b/src/Symfony/Component/Finder/Tests/Iterator/Iterator.php index bc2eb53b393e0..108c66a273c99 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/Iterator.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/Iterator.php @@ -23,12 +23,12 @@ public function __construct(array $values = []) $this->rewind(); } - public function attach(\SplFileInfo $fileinfo) + public function attach(\SplFileInfo $fileinfo): void { $this->values[] = $fileinfo; } - public function rewind() + public function rewind(): void { reset($this->values); } @@ -38,16 +38,24 @@ public function valid(): bool return false !== $this->current(); } - public function next() + public function next(): void { next($this->values); } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function current() { return current($this->values); } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function key() { return key($this->values); diff --git a/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php index 15e069b9f81c1..590aea21af693 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php @@ -54,7 +54,7 @@ public function __construct() { } - public function accept() + public function accept(): bool { throw new \BadFunctionCallException('Not implemented'); } diff --git a/src/Symfony/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php index f3f1edebf10d2..9c3cf9b6b5976 100644 --- a/src/Symfony/Component/Form/Button.php +++ b/src/Symfony/Component/Form/Button.php @@ -51,6 +51,7 @@ public function __construct(FormConfigInterface $config) * * @return bool Always returns false */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return false; @@ -67,6 +68,7 @@ public function offsetExists($offset) * * @throws BadMethodCallException */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { throw new BadMethodCallException('Buttons cannot have children.'); @@ -84,6 +86,7 @@ public function offsetGet($offset) * * @throws BadMethodCallException */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new BadMethodCallException('Buttons cannot have children.'); @@ -100,6 +103,7 @@ public function offsetSet($offset, $value) * * @throws BadMethodCallException */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new BadMethodCallException('Buttons cannot have children.'); @@ -436,6 +440,7 @@ public function createView(FormView $parent = null) * * @return int Always returns 0 */ + #[\ReturnTypeWillChange] public function count() { return 0; @@ -446,6 +451,7 @@ public function count() * * @return \EmptyIterator Always returns an empty iterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new \EmptyIterator(); diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 4d16632bbe40d..fb310899700f8 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -717,6 +717,7 @@ public function getOption($name, $default = null) * * @return int Always returns 0 */ + #[\ReturnTypeWillChange] public function count() { return 0; @@ -727,6 +728,7 @@ public function count() * * @return \EmptyIterator Always returns an empty iterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new \EmptyIterator(); diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php index dd80486c9acea..a8446655c3565 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php @@ -36,8 +36,9 @@ public function __construct($label, array $choices = []) /** * {@inheritdoc} * - * @return self[]|ChoiceView[] + * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->choices); diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php index fca0bfa16b6b3..47593b82cb1ff 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php @@ -223,6 +223,7 @@ public function mapsForm($index) * * @return ViolationPathIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new ViolationPathIterator($this); diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 9abb6bdeab146..32cc437574d4b 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -958,6 +958,7 @@ public function get($name) * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return $this->has($name); @@ -972,6 +973,7 @@ public function offsetExists($name) * * @throws OutOfBoundsException if the named child does not exist */ + #[\ReturnTypeWillChange] public function offsetGet($name) { return $this->get($name); @@ -990,6 +992,7 @@ public function offsetGet($name) * * @see self::add() */ + #[\ReturnTypeWillChange] public function offsetSet($name, $child) { $this->add($child); @@ -1004,6 +1007,7 @@ public function offsetSet($name, $child) * * @throws AlreadySubmittedException if the form has already been submitted */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { $this->remove($name); @@ -1014,6 +1018,7 @@ public function offsetUnset($name) * * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { return $this->children; @@ -1024,6 +1029,7 @@ public function getIterator() * * @return int The number of embedded form children */ + #[\ReturnTypeWillChange] public function count() { return \count($this->children); diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 2fa65e095c496..9ec863ac493c8 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -161,6 +161,7 @@ public function all() /** * @return int */ + #[\ReturnTypeWillChange] public function count() { if ($this->locked) { @@ -215,6 +216,7 @@ public function getForm() * * @return FormBuilderInterface[]|\Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { if ($this->locked) { diff --git a/src/Symfony/Component/Form/FormErrorIterator.php b/src/Symfony/Component/Form/FormErrorIterator.php index f4614844985a0..0ef5a2e95844c 100644 --- a/src/Symfony/Component/Form/FormErrorIterator.php +++ b/src/Symfony/Component/Form/FormErrorIterator.php @@ -93,6 +93,7 @@ public function getForm() * * @return FormError|self An error or an iterator containing nested errors */ + #[\ReturnTypeWillChange] public function current() { return current($this->errors); @@ -101,6 +102,7 @@ public function current() /** * Advances the iterator to the next position. */ + #[\ReturnTypeWillChange] public function next() { next($this->errors); @@ -111,6 +113,7 @@ public function next() * * @return int The 0-indexed position */ + #[\ReturnTypeWillChange] public function key() { return key($this->errors); @@ -121,6 +124,7 @@ public function key() * * @return bool Whether the iterator is valid */ + #[\ReturnTypeWillChange] public function valid() { return null !== key($this->errors); @@ -132,6 +136,7 @@ public function valid() * This method detects if errors have been added to the form since the * construction of the iterator. */ + #[\ReturnTypeWillChange] public function rewind() { reset($this->errors); @@ -144,6 +149,7 @@ public function rewind() * * @return bool Whether that position exists */ + #[\ReturnTypeWillChange] public function offsetExists($position) { return isset($this->errors[$position]); @@ -158,6 +164,7 @@ public function offsetExists($position) * * @throws OutOfBoundsException If the given position does not exist */ + #[\ReturnTypeWillChange] public function offsetGet($position) { if (!isset($this->errors[$position])) { @@ -174,6 +181,7 @@ public function offsetGet($position) * * @throws BadMethodCallException */ + #[\ReturnTypeWillChange] public function offsetSet($position, $value) { throw new BadMethodCallException('The iterator doesn\'t support modification of elements.'); @@ -186,6 +194,7 @@ public function offsetSet($position, $value) * * @throws BadMethodCallException */ + #[\ReturnTypeWillChange] public function offsetUnset($position) { throw new BadMethodCallException('The iterator doesn\'t support modification of elements.'); @@ -197,6 +206,7 @@ public function offsetUnset($position) * * @return bool Whether the current element is an instance of this class */ + #[\ReturnTypeWillChange] public function hasChildren() { return current($this->errors) instanceof self; @@ -207,6 +217,7 @@ public function hasChildren() * * @return self */ + #[\ReturnTypeWillChange] public function getChildren() { return current($this->errors); @@ -229,6 +240,7 @@ public function getChildren() * * @return int The number of iterated elements */ + #[\ReturnTypeWillChange] public function count() { return \count($this->errors); @@ -243,6 +255,7 @@ public function count() * * @throws OutOfBoundsException If the position is invalid */ + #[\ReturnTypeWillChange] public function seek($position) { if (!isset($this->errors[$position])) { diff --git a/src/Symfony/Component/Form/FormView.php b/src/Symfony/Component/Form/FormView.php index 644bf515e6a71..460e52857680d 100644 --- a/src/Symfony/Component/Form/FormView.php +++ b/src/Symfony/Component/Form/FormView.php @@ -108,6 +108,7 @@ public function setMethodRendered() * * @return self The child view */ + #[\ReturnTypeWillChange] public function offsetGet($name) { return $this->children[$name]; @@ -120,6 +121,7 @@ public function offsetGet($name) * * @return bool Whether the child view exists */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return isset($this->children[$name]); @@ -132,6 +134,7 @@ public function offsetExists($name) * * @throws BadMethodCallException always as setting a child by name is not allowed */ + #[\ReturnTypeWillChange] public function offsetSet($name, $value) { throw new BadMethodCallException('Not supported.'); @@ -144,6 +147,7 @@ public function offsetSet($name, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { unset($this->children[$name]); @@ -154,6 +158,7 @@ public function offsetUnset($name) * * @return \ArrayIterator The iterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->children); @@ -164,6 +169,7 @@ public function getIterator() * * @return int The number of children views */ + #[\ReturnTypeWillChange] public function count() { return \count($this->children); diff --git a/src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php b/src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php index 5c12b6b400bb8..41cb5af4cdf7b 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php @@ -29,12 +29,17 @@ public function offsetExists($offset): bool return \array_key_exists($offset, $this->array); } + /** + * @param mixed $offset + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->array[$offset]; } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (null === $offset) { $this->array[] = $value; @@ -43,7 +48,7 @@ public function offsetSet($offset, $value) } } - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->array[$offset]); } @@ -73,7 +78,7 @@ public function __unserialize(array $data): void $this->array = $data; } - public function unserialize($serialized) + public function unserialize($serialized): void { $this->__unserialize((array) unserialize((string) $serialized)); } diff --git a/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php b/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php index 1bb324423623b..7cba17dbebe1c 100644 --- a/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php +++ b/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php @@ -30,6 +30,7 @@ class InheritDataAwareIterator extends \IteratorIterator implements \RecursiveIt * * @return static */ + #[\ReturnTypeWillChange] public function getChildren() { return new static($this->current()); @@ -38,6 +39,7 @@ public function getChildren() /** * @return bool */ + #[\ReturnTypeWillChange] public function hasChildren() { return (bool) $this->current()->getConfig()->getInheritData(); diff --git a/src/Symfony/Component/Form/Util/OrderedHashMap.php b/src/Symfony/Component/Form/Util/OrderedHashMap.php index 7b1ca264d2bbb..b60a7ce4b0959 100644 --- a/src/Symfony/Component/Form/Util/OrderedHashMap.php +++ b/src/Symfony/Component/Form/Util/OrderedHashMap.php @@ -101,6 +101,7 @@ public function __construct(array $elements = []) /** * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return isset($this->elements[$key]); @@ -111,6 +112,7 @@ public function offsetExists($key) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { if (!isset($this->elements[$key])) { @@ -125,6 +127,7 @@ public function offsetGet($key) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { if (null === $key || !isset($this->elements[$key])) { @@ -148,6 +151,7 @@ public function offsetSet($key, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { if (false !== ($position = array_search((string) $key, $this->orderedKeys))) { @@ -165,6 +169,7 @@ public function offsetUnset($key) /** * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { return new OrderedHashMapIterator($this->elements, $this->orderedKeys, $this->managedCursors); @@ -173,6 +178,7 @@ public function getIterator() /** * @return int */ + #[\ReturnTypeWillChange] public function count() { return \count($this->elements); diff --git a/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php b/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php index 6e295e1871451..87cab46052b40 100644 --- a/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php +++ b/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php @@ -105,6 +105,7 @@ public function __destruct() * * @return mixed */ + #[\ReturnTypeWillChange] public function current() { return $this->current; @@ -112,10 +113,8 @@ public function current() /** * {@inheritdoc} - * - * @return void */ - public function next() + public function next(): void { ++$this->cursor; @@ -133,6 +132,7 @@ public function next() * * @return mixed */ + #[\ReturnTypeWillChange] public function key() { if (null === $this->key) { @@ -154,10 +154,8 @@ public function valid(): bool /** * {@inheritdoc} - * - * @return void */ - public function rewind() + public function rewind(): void { $this->cursor = 0; diff --git a/src/Symfony/Component/HttpFoundation/File/Stream.php b/src/Symfony/Component/HttpFoundation/File/Stream.php index 4a08e7f2dd355..cef3e03977cfe 100644 --- a/src/Symfony/Component/HttpFoundation/File/Stream.php +++ b/src/Symfony/Component/HttpFoundation/File/Stream.php @@ -23,6 +23,7 @@ class Stream extends File * * @return int|false */ + #[\ReturnTypeWillChange] public function getSize() { return false; diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index 15393544fcbfe..9fb113de44e26 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -279,6 +279,7 @@ public function removeCacheControlDirective($key) * * @return \ArrayIterator An \ArrayIterator instance */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->headers); @@ -289,6 +290,7 @@ public function getIterator() * * @return int The number of headers */ + #[\ReturnTypeWillChange] public function count() { return \count($this->headers); diff --git a/src/Symfony/Component/HttpFoundation/ParameterBag.php b/src/Symfony/Component/HttpFoundation/ParameterBag.php index 1de753d3da37b..a2fe0af869873 100644 --- a/src/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/src/Symfony/Component/HttpFoundation/ParameterBag.php @@ -210,6 +210,7 @@ public function filter($key, $default = null, $filter = \FILTER_DEFAULT, $option * * @return \ArrayIterator An \ArrayIterator instance */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->parameters); @@ -220,6 +221,7 @@ public function getIterator() * * @return int The number of parameters */ + #[\ReturnTypeWillChange] public function count() { return \count($this->parameters); diff --git a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php index ee33698cf0842..bd35531739d3c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php @@ -131,6 +131,7 @@ public function clear() * * @return \ArrayIterator An \ArrayIterator instance */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->attributes); @@ -141,6 +142,7 @@ public function getIterator() * * @return int The number of attributes */ + #[\ReturnTypeWillChange] public function count() { return \count($this->attributes); diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index 960679ace8f61..f42ed38ef5573 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -126,6 +126,7 @@ public function isStarted() * * @return \ArrayIterator An \ArrayIterator instance */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->getAttributeBag()->all()); @@ -136,6 +137,7 @@ public function getIterator() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return \count($this->getAttributeBag()->all()); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index d8663a57b76d2..af9d45cae3b40 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -57,6 +57,7 @@ public function __construct(\Memcached $memcached, array $options = []) /** * @return bool */ + #[\ReturnTypeWillChange] public function close() { return $this->memcached->quit(); @@ -73,6 +74,7 @@ protected function doRead($sessionId) /** * @return bool */ + #[\ReturnTypeWillChange] public function updateTimestamp($sessionId, $data) { $this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl); diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php b/src/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php index c415989f2f7f8..8b2f12f4144cf 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php @@ -17,28 +17,28 @@ class FakeFile extends OrigFile { private $realpath; - public function __construct($realpath, $path) + public function __construct(string $realpath, string $path) { $this->realpath = $realpath; parent::__construct($path, false); } - public function isReadable() + public function isReadable(): bool { return true; } - public function getRealpath() + public function getRealpath(): string { return $this->realpath; } - public function getSize() + public function getSize(): int { return 42; } - public function getMTime() + public function getMTime(): int { return time(); } diff --git a/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php b/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php index da6faf67810b6..2679948b14733 100644 --- a/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php +++ b/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php @@ -45,25 +45,21 @@ public function offsetExists($offset): bool } /** + * @param mixed $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); } - /** - * @return void - */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { throw new BadMethodCallException('Resource bundles cannot be modified.'); } - /** - * @return void - */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { throw new BadMethodCallException('Resource bundles cannot be modified.'); } diff --git a/src/Symfony/Component/Intl/Data/Util/RingBuffer.php b/src/Symfony/Component/Intl/Data/Util/RingBuffer.php index 76bca285bbbc2..72d86025f718a 100644 --- a/src/Symfony/Component/Intl/Data/Util/RingBuffer.php +++ b/src/Symfony/Component/Intl/Data/Util/RingBuffer.php @@ -52,6 +52,7 @@ public function offsetExists($key): bool * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { if (!isset($this->indices[$key])) { @@ -66,7 +67,7 @@ public function offsetGet($key) * * @return void */ - public function offsetSet($key, $value) + public function offsetSet($key, $value): void { if (false !== ($keyToRemove = array_search($this->cursor, $this->indices))) { unset($this->indices[$keyToRemove]); @@ -83,7 +84,7 @@ public function offsetSet($key, $value) * * @return void */ - public function offsetUnset($key) + public function offsetUnset($key): void { if (isset($this->indices[$key])) { $this->values[$this->indices[$key]] = null; diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php index 05e81c8378e57..d8da8ddbf6586 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php @@ -45,6 +45,7 @@ public function toArray() /** * @return int */ + #[\ReturnTypeWillChange] public function count() { $con = $this->connection->getResource(); diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 6c6764e1818bd..fc1cf85475861 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -832,6 +832,7 @@ public function resolve(array $options = []) * @throws OptionDefinitionException If there is a cyclic dependency between * lazy options and/or normalizers */ + #[\ReturnTypeWillChange] public function offsetGet($option/*, bool $triggerDeprecation = true*/) { if (!$this->locked) { @@ -1072,6 +1073,7 @@ private function verifyTypes(string $type, $value, array &$invalidTypes, int $le * * @see \ArrayAccess::offsetExists() */ + #[\ReturnTypeWillChange] public function offsetExists($option) { if (!$this->locked) { @@ -1088,6 +1090,7 @@ public function offsetExists($option) * * @throws AccessException */ + #[\ReturnTypeWillChange] public function offsetSet($option, $value) { throw new AccessException('Setting options via array access is not supported. Use setDefault() instead.'); @@ -1100,6 +1103,7 @@ public function offsetSet($option, $value) * * @throws AccessException */ + #[\ReturnTypeWillChange] public function offsetUnset($option) { throw new AccessException('Removing options via array access is not supported. Use remove() instead.'); @@ -1116,6 +1120,7 @@ public function offsetUnset($option) * * @see \Countable::count() */ + #[\ReturnTypeWillChange] public function count() { if (!$this->locked) { diff --git a/src/Symfony/Component/Process/InputStream.php b/src/Symfony/Component/Process/InputStream.php index c86fca86878df..4f8f71331aafc 100644 --- a/src/Symfony/Component/Process/InputStream.php +++ b/src/Symfony/Component/Process/InputStream.php @@ -69,6 +69,7 @@ public function isClosed() /** * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { $this->open = true; diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index a30cc3d118e0e..9fafddd64413d 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -622,6 +622,7 @@ public function getIncrementalOutput() * * @return \Generator */ + #[\ReturnTypeWillChange] public function getIterator($flags = 0) { $this->readPipesForOutput(__FUNCTION__, false); diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index f831ec3fda0bb..ac1f7c3c04cf4 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -154,6 +154,7 @@ public function getParent() * * @return PropertyPathIteratorInterface */ + #[\ReturnTypeWillChange] public function getIterator() { return new PropertyPathIterator($this); diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/NonTraversableArrayObject.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/NonTraversableArrayObject.php index cf02ee69f2979..da8911ed7207f 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/NonTraversableArrayObject.php +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/NonTraversableArrayObject.php @@ -29,12 +29,17 @@ public function offsetExists($offset): bool return \array_key_exists($offset, $this->array); } + /** + * @param mixed $offset + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->array[$offset]; } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (null === $offset) { $this->array[] = $value; @@ -43,7 +48,7 @@ public function offsetSet($offset, $value) } } - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->array[$offset]); } @@ -68,7 +73,7 @@ public function __unserialize(array $data): void $this->array = $data; } - public function unserialize($serialized) + public function unserialize($serialized): void { $this->__unserialize((array) unserialize((string) $serialized)); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TraversableArrayObject.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TraversableArrayObject.php index 5693c6b73e685..26ab98575f25f 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TraversableArrayObject.php +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TraversableArrayObject.php @@ -29,12 +29,17 @@ public function offsetExists($offset): bool return \array_key_exists($offset, $this->array); } + /** + * @param mixed $offset + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->array[$offset]; } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (null === $offset) { $this->array[] = $value; @@ -43,7 +48,7 @@ public function offsetSet($offset, $value) } } - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->array[$offset]); } diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index 3baf0986c5cb1..56e925cac5158 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -51,6 +51,7 @@ public function __clone() * * @return \ArrayIterator|Route[] An \ArrayIterator object for iterating over routes */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->routes); @@ -61,6 +62,7 @@ public function getIterator() * * @return int The number of routes */ + #[\ReturnTypeWillChange] public function count() { return \count($this->routes); diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php index 8a1c8327087dc..04a1212e21bfb 100644 --- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php @@ -128,7 +128,7 @@ public function __sleep(): array /** * @internal */ - public function __wakeup() + public function __wakeup(): void { if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'unserialize'))->getDeclaringClass()->name) { @trigger_error(sprintf('Implementing the "%s::unserialize()" method is deprecated since Symfony 4.3, implement the __serialize() and __unserialize() methods instead.', $c), \E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index b849da174b5f8..e4f85606981ce 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -173,6 +173,7 @@ protected function evaluate(Storage $template, array $parameters = []) * * @throws \InvalidArgumentException if the helper is not defined */ + #[\ReturnTypeWillChange] public function offsetGet($name) { return $this->get($name); @@ -185,6 +186,7 @@ public function offsetGet($name) * * @return bool true if the helper is defined, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return isset($this->helpers[$name]); @@ -198,6 +200,7 @@ public function offsetExists($name) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($name, $value) { $this->set($name, $value); @@ -212,6 +215,7 @@ public function offsetSet($name, $value) * * @throws \LogicException */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { throw new \LogicException(sprintf('You can\'t unset a helper (%s).', $name)); diff --git a/src/Symfony/Component/Validator/ConstraintViolationList.php b/src/Symfony/Component/Validator/ConstraintViolationList.php index bd6443fc45889..e057e916ae16f 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationList.php +++ b/src/Symfony/Component/Validator/ConstraintViolationList.php @@ -110,6 +110,7 @@ public function remove($offset) * * @return \ArrayIterator|ConstraintViolationInterface[] */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->violations); @@ -118,6 +119,7 @@ public function getIterator() /** * @return int */ + #[\ReturnTypeWillChange] public function count() { return \count($this->violations); @@ -126,6 +128,7 @@ public function count() /** * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return $this->has($offset); @@ -136,6 +139,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); @@ -146,6 +150,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $violation) { if (null === $offset) { @@ -160,6 +165,7 @@ public function offsetSet($offset, $violation) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { $this->remove($offset); diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php b/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php index 34b208b2bea0c..f248576d2f2e5 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php @@ -29,12 +29,17 @@ public function offsetExists($offset): bool return \array_key_exists($offset, $this->array); } + /** + * @param mixed $offset + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->array[$offset]; } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (null === $offset) { $this->array[] = $value; @@ -43,7 +48,7 @@ public function offsetSet($offset, $value) } } - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->array[$offset]); } diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index 114bf50e5b038..8f621b12a7627 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -111,6 +111,7 @@ public function getValue($recursive = false) /** * @return int */ + #[\ReturnTypeWillChange] public function count() { return \count($this->getValue()); @@ -119,6 +120,7 @@ public function count() /** * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { if (!\is_array($value = $this->getValue())) { @@ -150,6 +152,7 @@ public function __isset($key) /** * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return $this->__isset($key); @@ -158,6 +161,7 @@ public function offsetExists($key) /** * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->__get($key); @@ -166,6 +170,7 @@ public function offsetGet($key) /** * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { throw new \BadMethodCallException(self::class.' objects are immutable.'); @@ -174,6 +179,7 @@ public function offsetSet($key, $value) /** * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { throw new \BadMethodCallException(self::class.' objects are immutable.');