From 2d3e1edc8d6ae9f2b35f99b96c55495b970106a4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 5 Aug 2021 00:33:39 +0200 Subject: [PATCH] Remove ReturnTypeWillChange Signed-off-by: Alexander M. Turek --- .../Constraints/UniqueEntityValidatorTest.php | 24 ++------ .../Component/Console/Helper/HelperSet.php | 5 +- src/Symfony/Component/DomCrawler/Crawler.php | 11 +--- src/Symfony/Component/DomCrawler/Form.php | 18 ++---- .../EventDispatcher/GenericEvent.php | 25 ++------ src/Symfony/Component/Finder/Finder.php | 10 +--- .../Finder/Iterator/CustomFilterIterator.php | 3 +- .../Iterator/DateRangeFilterIterator.php | 3 +- .../Iterator/DepthRangeFilterIterator.php | 3 +- .../ExcludeDirectoryFilterIterator.php | 15 +---- .../Iterator/FileTypeFilterIterator.php | 3 +- .../Iterator/FilecontentFilterIterator.php | 3 +- .../Iterator/FilenameFilterIterator.php | 3 +- .../Finder/Iterator/PathFilterIterator.php | 3 +- .../Iterator/RecursiveDirectoryIterator.php | 10 +--- .../Iterator/SizeRangeFilterIterator.php | 3 +- .../Finder/Iterator/SortableIterator.php | 6 +- src/Symfony/Component/Form/Button.php | 24 ++------ src/Symfony/Component/Form/ButtonBuilder.php | 6 +- .../Form/ChoiceList/View/ChoiceGroupView.php | 3 +- .../ViolationMapper/ViolationPath.php | 5 +- src/Symfony/Component/Form/Form.php | 28 +++------ src/Symfony/Component/Form/FormBuilder.php | 11 +--- .../Component/Form/FormErrorIterator.php | 59 ++++--------------- src/Symfony/Component/Form/FormView.php | 31 ++-------- .../Form/Util/InheritDataAwareIterator.php | 14 +---- .../Component/Form/Util/OrderedHashMap.php | 42 ++----------- .../Form/Util/OrderedHashMapIterator.php | 2 - .../Component/HttpFoundation/File/Stream.php | 8 +-- .../Component/HttpFoundation/HeaderBag.php | 10 +--- .../Component/HttpFoundation/ParameterBag.php | 10 +--- .../Session/Attribute/AttributeBag.php | 10 +--- .../HttpFoundation/Session/Session.php | 10 +--- .../Handler/AbstractSessionHandler.php | 30 ++-------- .../Handler/MarshallingSessionHandler.php | 48 +++------------ .../Handler/MemcachedSessionHandler.php | 18 +----- .../Handler/MigratingSessionHandler.php | 48 +++------------ .../Storage/Handler/MongoDbSessionHandler.php | 6 +- .../Storage/Handler/NullSessionHandler.php | 24 ++------ .../Storage/Handler/PdoSessionHandler.php | 30 ++-------- .../Storage/Handler/RedisSessionHandler.php | 8 +-- .../Storage/Handler/StrictSessionHandler.php | 30 ++-------- .../Storage/Proxy/SessionHandlerProxy.php | 58 ++++-------------- .../Storage/Handler/Fixtures/common.inc | 13 ++-- .../Ldap/Adapter/ExtLdap/Collection.php | 6 +- .../OptionsResolver/OptionsResolver.php | 25 ++------ src/Symfony/Component/Process/InputStream.php | 6 +- src/Symfony/Component/Process/Process.php | 5 +- .../Component/PropertyAccess/PropertyPath.php | 5 +- .../Component/Routing/RouteCollection.php | 10 +--- .../Component/Templating/PhpEngine.php | 20 ++----- .../Validator/ConstraintViolationList.php | 41 +++---------- .../Component/VarDumper/Cloner/Data.php | 30 ++-------- 53 files changed, 178 insertions(+), 704 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index d6b2202e00582..075d82d8af3b8 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -855,11 +855,7 @@ public function resultWithEmptyIterator(): array return [ [$entity, new class() implements \Iterator { - /** - * @return mixed - */ - #[\ReturnTypeWillChange] - public function current() + public function current(): mixed { return null; } @@ -873,11 +869,7 @@ public function next(): void { } - /** - * @return mixed - */ - #[\ReturnTypeWillChange] - public function key() + public function key(): mixed { return false; } @@ -887,11 +879,7 @@ public function rewind(): void } }], [$entity, new class() implements \Iterator { - /** - * @return mixed - */ - #[\ReturnTypeWillChange] - public function current() + public function current(): mixed { return false; } @@ -905,11 +893,7 @@ public function next(): void { } - /** - * @return mixed - */ - #[\ReturnTypeWillChange] - public function key() + public function key(): mixed { return false; } diff --git a/src/Symfony/Component/Console/Helper/HelperSet.php b/src/Symfony/Component/Console/Helper/HelperSet.php index 679dceab16921..ca627a52d344d 100644 --- a/src/Symfony/Component/Console/Helper/HelperSet.php +++ b/src/Symfony/Component/Console/Helper/HelperSet.php @@ -89,10 +89,9 @@ public function getCommand() } /** - * @return \Traversable + * @return \Traversable */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { return new \ArrayIterator($this->helpers); } diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 10ba11bbdc43e..87e6ddb0c83fc 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -1071,20 +1071,15 @@ public function getNode(int $position) return $this->nodes[$position] ?? null; } - /** - * @return int - */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->nodes); } /** - * @return \ArrayIterator|\DOMNode[] + * @return \ArrayIterator */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->nodes); } diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 2c0c6a8a79641..a3ed7e0befa9f 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -301,11 +301,8 @@ public function all() * Returns true if the named field exists. * * @param string $name The field name - * - * @return bool true if the field exists, false otherwise */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $name) + public function offsetExists(mixed $name): bool { return $this->has($name); } @@ -319,8 +316,7 @@ public function offsetExists(mixed $name) * * @throws \InvalidArgumentException if the field does not exist */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $name) + public function offsetGet(mixed $name): FormField|array { return $this->fields->get($name); } @@ -331,12 +327,9 @@ public function offsetGet(mixed $name) * @param string $name The field name * @param string|array $value The value of the field * - * @return void - * * @throws \InvalidArgumentException if the field does not exist */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $name, mixed $value) + public function offsetSet(mixed $name, mixed $value): void { $this->fields->set($name, $value); } @@ -345,11 +338,8 @@ public function offsetSet(mixed $name, mixed $value) * Removes a field from the form. * * @param string $name The field name - * - * @return void */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $name) + public function offsetUnset(mixed $name): void { $this->fields->remove($name); } diff --git a/src/Symfony/Component/EventDispatcher/GenericEvent.php b/src/Symfony/Component/EventDispatcher/GenericEvent.php index 659cc34d29b8c..1871eec8e6b3c 100644 --- a/src/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/src/Symfony/Component/EventDispatcher/GenericEvent.php @@ -112,12 +112,9 @@ public function hasArgument(string $key) * * @param string $key Array key * - * @return mixed - * * @throws \InvalidArgumentException if key does not exist in $this->args */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $key) + public function offsetGet(mixed $key): mixed { return $this->getArgument($key); } @@ -126,11 +123,8 @@ public function offsetGet(mixed $key) * ArrayAccess for argument setter. * * @param string $key Array key to set - * - * @return void */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $key, mixed $value) + public function offsetSet(mixed $key, mixed $value): void { $this->setArgument($key, $value); } @@ -139,11 +133,8 @@ public function offsetSet(mixed $key, mixed $value) * ArrayAccess for unset argument. * * @param string $key Array key - * - * @return void */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $key) + public function offsetUnset(mixed $key): void { if ($this->hasArgument($key)) { unset($this->arguments[$key]); @@ -154,22 +145,16 @@ public function offsetUnset(mixed $key) * ArrayAccess has argument. * * @param string $key Array key - * - * @return bool */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $key) + public function offsetExists(mixed $key): bool { return $this->hasArgument($key); } /** * IteratorAggregate for iterating over the object like an array. - * - * @return \ArrayIterator */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->arguments); } diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 047cef8156435..cd494594634b7 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -603,12 +603,11 @@ public function in(string|array $dirs) * * This method implements the IteratorAggregate interface. * - * @return \Iterator|SplFileInfo[] An iterator + * @return \Iterator An iterator * * @throws \LogicException if the in() method has not been called */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Iterator { if (0 === \count($this->dirs) && 0 === \count($this->iterators)) { throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.'); @@ -687,11 +686,8 @@ public function hasResults() /** * Counts all the results collected by the iterators. - * - * @return int */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return iterator_count($this->getIterator()); } diff --git a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php index 8d1d0b7c06127..af7d5ac8861c5 100644 --- a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php @@ -46,8 +46,7 @@ public function __construct(\Iterator $iterator, array $filters) * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { $fileinfo = $this->current(); diff --git a/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php index 9df0ac64168bb..4dd0f3f0372d3 100644 --- a/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php @@ -38,8 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators) * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { $fileinfo = $this->current(); diff --git a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php index 596406a026853..a7b3a6ec343af 100644 --- a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php @@ -38,8 +38,7 @@ public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { 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 f84f4db124a16..f0f063c376b87 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php @@ -52,8 +52,7 @@ public function __construct(\Iterator $iterator, array $directories) * * @return bool True if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) { return false; @@ -69,20 +68,12 @@ public function accept() return true; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function hasChildren() + public function hasChildren(): bool { return $this->isRecursive && $this->iterator->hasChildren(); } - /** - * @return self - */ - #[\ReturnTypeWillChange] - public function getChildren() + public function getChildren(): self { $children = new self($this->iterator->getChildren(), []); $children->excludedDirs = $this->excludedDirs; diff --git a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php index ea9b7c10499da..dcedeabf54a4f 100644 --- a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php @@ -39,8 +39,7 @@ public function __construct(\Iterator $iterator, int $mode) * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { $fileinfo = $this->current(); if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) { diff --git a/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php index 9493b5e87313e..045c69f662d71 100644 --- a/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php @@ -24,8 +24,7 @@ class FilecontentFilterIterator extends MultiplePcreFilterIterator * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { if (!$this->matchRegexps && !$this->noMatchRegexps) { return true; diff --git a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php index 137c2c443d087..62875c069db9f 100644 --- a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php @@ -25,8 +25,7 @@ class FilenameFilterIterator extends MultiplePcreFilterIterator * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { 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 1d09c2674875a..ab0ab31c3db7f 100644 --- a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php @@ -24,8 +24,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { $filename = $this->current()->getRelativePathname(); diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index 8c813d791b74b..a25631bb21f01 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -48,11 +48,8 @@ public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs /** * Return an instance of SplFileInfo with support for relative paths. - * - * @return SplFileInfo File information */ - #[\ReturnTypeWillChange] - public function current() + public function current(): SplFileInfo { // the logic here avoids redoing the same work in all iterations @@ -105,11 +102,8 @@ public function getChildren() /** * Do nothing for non rewindable stream. - * - * @return void */ - #[\ReturnTypeWillChange] - public function rewind() + public function rewind(): void { if (false === $this->isRewindable()) { return; diff --git a/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php index e53aab72825ca..d524945c7a8d0 100644 --- a/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php @@ -38,8 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators) * * @return bool true if the value should be kept, false otherwise */ - #[\ReturnTypeWillChange] - public function accept() + public function accept(): bool { $fileinfo = $this->current(); if (!$fileinfo->isFile()) { diff --git a/src/Symfony/Component/Finder/Iterator/SortableIterator.php b/src/Symfony/Component/Finder/Iterator/SortableIterator.php index 4a244b4266cdf..2f511cf2fbb83 100644 --- a/src/Symfony/Component/Finder/Iterator/SortableIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SortableIterator.php @@ -78,11 +78,7 @@ public function __construct(\Traversable $iterator, int|callable $sort, bool $re } } - /** - * @return \Traversable - */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { if (1 === $this->sort) { return $this->iterator; diff --git a/src/Symfony/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php index cf7238d5b8878..117d817fb084c 100644 --- a/src/Symfony/Component/Form/Button.php +++ b/src/Symfony/Component/Form/Button.php @@ -38,8 +38,7 @@ public function __construct(FormConfigInterface $config) * * @return bool Always returns false */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $offset) + public function offsetExists(mixed $offset): bool { return false; } @@ -49,12 +48,9 @@ public function offsetExists(mixed $offset) * * This method should not be invoked. * - * @return mixed - * * @throws BadMethodCallException */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $offset) + public function offsetGet(mixed $offset): mixed { throw new BadMethodCallException('Buttons cannot have children.'); } @@ -64,12 +60,9 @@ public function offsetGet(mixed $offset) * * This method should not be invoked. * - * @return void - * * @throws BadMethodCallException */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $offset, mixed $value) + public function offsetSet(mixed $offset, mixed $value): void { throw new BadMethodCallException('Buttons cannot have children.'); } @@ -79,12 +72,9 @@ public function offsetSet(mixed $offset, mixed $value) * * This method should not be invoked. * - * @return void - * * @throws BadMethodCallException */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $offset) + public function offsetUnset(mixed $offset): void { throw new BadMethodCallException('Buttons cannot have children.'); } @@ -407,8 +397,7 @@ public function createView(FormView $parent = null) * * @return int Always returns 0 */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return 0; } @@ -418,8 +407,7 @@ public function count() * * @return \EmptyIterator Always returns an empty iterator */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \EmptyIterator { return new \EmptyIterator(); } diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index b74a32ca24510..8cefe3794ee15 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -693,8 +693,7 @@ public function getIsEmptyCallback(): ?callable * * @return int Always returns 0 */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return 0; } @@ -704,8 +703,7 @@ public function count() * * @return \EmptyIterator Always returns an empty iterator */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \EmptyIterator { return new \EmptyIterator(); } diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php index 5ad89c6b1f82e..185e54ae78a2a 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php @@ -37,8 +37,7 @@ public function __construct(string $label, array $choices = []) * * @return \Traversable */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { 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 87adc8a8bad9e..337fcacfee56e 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php @@ -196,11 +196,8 @@ public function mapsForm(int $index) /** * Returns a new iterator for this path. - * - * @return ViolationPathIterator */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): ViolationPathIterator { return new ViolationPathIterator($this); } diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 018fb13165900..722545163b2b1 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -915,11 +915,8 @@ public function get(string $name) * Returns whether a child with the given name exists (implements the \ArrayAccess interface). * * @param string $name The name of the child - * - * @return bool */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $name) + public function offsetExists(mixed $name): bool { return $this->has($name); } @@ -929,12 +926,9 @@ public function offsetExists(mixed $name) * * @param string $name The name of the child * - * @return FormInterface The child form - * * @throws OutOfBoundsException if the named child does not exist */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $name) + public function offsetGet(mixed $name): FormInterface { return $this->get($name); } @@ -945,15 +939,12 @@ public function offsetGet(mixed $name) * @param string $name Ignored. The name of the child is used * @param FormInterface $child The child to be added * - * @return void - * * @throws AlreadySubmittedException if the form has already been submitted * @throws LogicException when trying to add a child to a non-compound form * * @see self::add() */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $name, mixed $child) + public function offsetSet(mixed $name, mixed $child): void { $this->add($child); } @@ -963,12 +954,9 @@ public function offsetSet(mixed $name, mixed $child) * * @param string $name The name of the child to remove * - * @return void - * * @throws AlreadySubmittedException if the form has already been submitted */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $name) + public function offsetUnset(mixed $name): void { $this->remove($name); } @@ -976,10 +964,9 @@ public function offsetUnset(mixed $name) /** * Returns the iterator for this group. * - * @return \Traversable + * @return \Traversable */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { return $this->children; } @@ -989,8 +976,7 @@ public function getIterator() * * @return int The number of embedded form children */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->children); } diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 7c88ddf977d89..66762cbbff608 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -156,11 +156,7 @@ public function all() return $this->children; } - /** - * @return int - */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { if ($this->locked) { throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); @@ -212,10 +208,9 @@ public function getForm() /** * {@inheritdoc} * - * @return FormBuilderInterface[]|\Traversable + * @return \Traversable */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { if ($this->locked) { throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); diff --git a/src/Symfony/Component/Form/FormErrorIterator.php b/src/Symfony/Component/Form/FormErrorIterator.php index d1df25ebb1a70..43b8940759fb0 100644 --- a/src/Symfony/Component/Form/FormErrorIterator.php +++ b/src/Symfony/Component/Form/FormErrorIterator.php @@ -88,11 +88,8 @@ public function getForm() /** * Returns the current element of the iterator. - * - * @return FormError|self An error or an iterator containing nested errors */ - #[\ReturnTypeWillChange] - public function current() + public function current(): FormError|self { return current($this->errors); } @@ -100,8 +97,7 @@ public function current() /** * Advances the iterator to the next position. */ - #[\ReturnTypeWillChange] - public function next() + public function next(): void { next($this->errors); } @@ -111,19 +107,15 @@ public function next() * * @return int The 0-indexed position */ - #[\ReturnTypeWillChange] - public function key() + public function key(): int { return key($this->errors); } /** * Returns whether the iterator's position is valid. - * - * @return bool Whether the iterator is valid */ - #[\ReturnTypeWillChange] - public function valid() + public function valid(): bool { return null !== key($this->errors); } @@ -134,8 +126,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() + public function rewind(): void { reset($this->errors); } @@ -144,11 +135,8 @@ public function rewind() * Returns whether a position exists in the iterator. * * @param int $position The position - * - * @return bool Whether that position exists */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $position) + public function offsetExists(mixed $position): bool { return isset($this->errors[$position]); } @@ -158,12 +146,9 @@ public function offsetExists(mixed $position) * * @param int $position The position * - * @return FormError|FormErrorIterator The element at the given position - * * @throws OutOfBoundsException If the given position does not exist */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $position) + public function offsetGet(mixed $position): FormError|self { if (!isset($this->errors[$position])) { throw new OutOfBoundsException('The offset '.$position.' does not exist.'); @@ -175,12 +160,9 @@ public function offsetGet(mixed $position) /** * Unsupported method. * - * @return void - * * @throws BadMethodCallException */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $position, mixed $value) + public function offsetSet(mixed $position, mixed $value): void { throw new BadMethodCallException('The iterator doesn\'t support modification of elements.'); } @@ -188,12 +170,9 @@ public function offsetSet(mixed $position, mixed $value) /** * Unsupported method. * - * @return void - * * @throws BadMethodCallException */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $position) + public function offsetUnset(mixed $position): void { throw new BadMethodCallException('The iterator doesn\'t support modification of elements.'); } @@ -201,22 +180,16 @@ public function offsetUnset(mixed $position) /** * Returns whether the current element of the iterator can be recursed * into. - * - * @return bool Whether the current element is an instance of this class */ - #[\ReturnTypeWillChange] - public function hasChildren() + public function hasChildren(): bool { return current($this->errors) instanceof self; } /** * Alias of {@link current()}. - * - * @return self */ - #[\ReturnTypeWillChange] - public function getChildren() + public function getChildren(): self { return current($this->errors); } @@ -235,11 +208,8 @@ public function getChildren() * Alternatively, set the constructor argument $flatten to true as well. * * $count = count($form->getErrors(true, true)); - * - * @return int The number of iterated elements */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->errors); } @@ -247,12 +217,9 @@ public function count() /** * Sets the position of the iterator. * - * @return void - * * @throws OutOfBoundsException If the position is invalid */ - #[\ReturnTypeWillChange] - public function seek(int $position) + public function seek(int $position): void { if (!isset($this->errors[$position])) { throw new OutOfBoundsException('The offset '.$position.' does not exist.'); diff --git a/src/Symfony/Component/Form/FormView.php b/src/Symfony/Component/Form/FormView.php index b22ac50428390..651d64af3870f 100644 --- a/src/Symfony/Component/Form/FormView.php +++ b/src/Symfony/Component/Form/FormView.php @@ -103,11 +103,8 @@ public function setMethodRendered() * Returns a child by name (implements \ArrayAccess). * * @param string $name The child name - * - * @return self The child view */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $name) + public function offsetGet(mixed $name): self { return $this->children[$name]; } @@ -116,11 +113,8 @@ public function offsetGet(mixed $name) * Returns whether the given child exists (implements \ArrayAccess). * * @param string $name The child name - * - * @return bool Whether the child view exists */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $name) + public function offsetExists(mixed $name): bool { return isset($this->children[$name]); } @@ -128,12 +122,9 @@ public function offsetExists(mixed $name) /** * Implements \ArrayAccess. * - * @return void - * * @throws BadMethodCallException always as setting a child by name is not allowed */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $name, mixed $value) + public function offsetSet(mixed $name, mixed $value): void { throw new BadMethodCallException('Not supported.'); } @@ -142,11 +133,8 @@ public function offsetSet(mixed $name, mixed $value) * Removes a child (implements \ArrayAccess). * * @param string $name The child name - * - * @return void */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $name) + public function offsetUnset(mixed $name): void { unset($this->children[$name]); } @@ -156,19 +144,12 @@ public function offsetUnset(mixed $name) * * @return \ArrayIterator The iterator */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->children); } - /** - * Implements \Countable. - * - * @return int The number of children views - */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->children); } diff --git a/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php b/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php index 7cba17dbebe1c..26a2135223a10 100644 --- a/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php +++ b/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php @@ -25,22 +25,12 @@ */ class InheritDataAwareIterator extends \IteratorIterator implements \RecursiveIterator { - /** - * {@inheritdoc} - * - * @return static - */ - #[\ReturnTypeWillChange] - public function getChildren() + public function getChildren(): static { return new static($this->current()); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function hasChildren() + public function hasChildren(): bool { 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 de9ddde22039c..eb136956683db 100644 --- a/src/Symfony/Component/Form/Util/OrderedHashMap.php +++ b/src/Symfony/Component/Form/Util/OrderedHashMap.php @@ -92,22 +92,12 @@ public function __construct(array $elements = []) $this->orderedKeys = array_keys($elements); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $key) + public function offsetExists(mixed $key): bool { return isset($this->elements[$key]); } - /** - * {@inheritdoc} - * - * @return mixed - */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $key) + public function offsetGet(mixed $key): mixed { if (!isset($this->elements[$key])) { throw new \OutOfBoundsException(sprintf('The offset "%s" does not exist.', $key)); @@ -116,13 +106,7 @@ public function offsetGet(mixed $key) return $this->elements[$key]; } - /** - * {@inheritdoc} - * - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $key, mixed $value) + public function offsetSet(mixed $key, mixed $value): void { if (null === $key || !isset($this->elements[$key])) { if (null === $key) { @@ -140,13 +124,7 @@ public function offsetSet(mixed $key, mixed $value) $this->elements[$key] = $value; } - /** - * {@inheritdoc} - * - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $key) + public function offsetUnset(mixed $key): void { if (false !== ($position = array_search((string) $key, $this->orderedKeys))) { array_splice($this->orderedKeys, $position, 1); @@ -160,20 +138,12 @@ public function offsetUnset(mixed $key) } } - /** - * @return \Traversable - */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { return new OrderedHashMapIterator($this->elements, $this->orderedKeys, $this->managedCursors); } - /** - * @return int - */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->elements); } diff --git a/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php b/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php index b7ee3a5da86b2..14008e649a198 100644 --- a/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php +++ b/src/Symfony/Component/Form/Util/OrderedHashMapIterator.php @@ -73,7 +73,6 @@ public function __destruct() /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] public function current(): mixed { return $this->current; @@ -98,7 +97,6 @@ public function next(): void /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] public function key(): mixed { if (null === $this->key) { diff --git a/src/Symfony/Component/HttpFoundation/File/Stream.php b/src/Symfony/Component/HttpFoundation/File/Stream.php index cef3e03977cfe..2c156b2e4eedc 100644 --- a/src/Symfony/Component/HttpFoundation/File/Stream.php +++ b/src/Symfony/Component/HttpFoundation/File/Stream.php @@ -18,13 +18,7 @@ */ class Stream extends File { - /** - * {@inheritdoc} - * - * @return int|false - */ - #[\ReturnTypeWillChange] - public function getSize() + public function getSize(): int|false { return false; } diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index ddd024c59e4e1..d5bff4254c825 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -245,22 +245,16 @@ public function removeCacheControlDirective(string $key) /** * Returns an iterator for headers. - * - * @return \ArrayIterator An \ArrayIterator instance */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->headers); } /** * Returns the number of headers. - * - * @return int The number of headers */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->headers); } diff --git a/src/Symfony/Component/HttpFoundation/ParameterBag.php b/src/Symfony/Component/HttpFoundation/ParameterBag.php index 8492e4c2ba30d..c65ec3d9acf5c 100644 --- a/src/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/src/Symfony/Component/HttpFoundation/ParameterBag.php @@ -192,22 +192,16 @@ public function filter(string $key, mixed $default = null, int $filter = \FILTER /** * Returns an iterator for parameters. - * - * @return \ArrayIterator An \ArrayIterator instance */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->parameters); } /** * Returns the number of parameters. - * - * @return int The number of parameters */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { 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 9ef225a41595f..ade9eaa223e8a 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php @@ -128,22 +128,16 @@ public function clear() /** * Returns an iterator for attributes. - * - * @return \ArrayIterator An \ArrayIterator instance */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->attributes); } /** * Returns the number of attributes. - * - * @return int The number of attributes */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->attributes); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index 76f2b29593385..ea1be4cb4480e 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -125,22 +125,16 @@ public function isStarted() /** * Returns an iterator for attributes. - * - * @return \ArrayIterator An \ArrayIterator instance */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->getAttributeBag()->all()); } /** * Returns the number of attributes. - * - * @return int */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->getAttributeBag()->all()); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php index c2a5aa9cf3145..7b33a8cb6ebe1 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php @@ -28,11 +28,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess private $newSessionId; private $igbinaryEmptyData; - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function open(string $savePath, string $sessionName) + public function open(string $savePath, string $sessionName): bool { $this->sessionName = $sessionName; if (!headers_sent() && !ini_get('session.cache_limiter') && '0' !== ini_get('session.cache_limiter')) { @@ -57,11 +53,7 @@ abstract protected function doWrite(string $sessionId, string $data); */ abstract protected function doDestroy(string $sessionId); - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function validateId(string $sessionId) + public function validateId(string $sessionId): bool { $this->prefetchData = $this->read($sessionId); $this->prefetchId = $sessionId; @@ -69,11 +61,7 @@ public function validateId(string $sessionId) return '' !== $this->prefetchData; } - /** - * @return string - */ - #[\ReturnTypeWillChange] - public function read(string $sessionId) + public function read(string $sessionId): string { if (null !== $this->prefetchId) { $prefetchId = $this->prefetchId; @@ -93,11 +81,7 @@ public function read(string $sessionId) return $data; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function write(string $sessionId, string $data) + public function write(string $sessionId, string $data): bool { if (null === $this->igbinaryEmptyData) { // see https://github.com/igbinary/igbinary/issues/146 @@ -111,11 +95,7 @@ public function write(string $sessionId, string $data) return $this->doWrite($sessionId, $data); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function destroy(string $sessionId) + public function destroy(string $sessionId): bool { if (!headers_sent() && filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) { if (!$this->sessionName) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php index 2e3472a0c4f42..377d1e090c21e 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php @@ -27,56 +27,32 @@ public function __construct(AbstractSessionHandler $handler, MarshallerInterface $this->marshaller = $marshaller; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function open(string $savePath, string $name) + public function open(string $savePath, string $name): bool { return $this->handler->open($savePath, $name); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { return $this->handler->close(); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function destroy(string $sessionId) + public function destroy(string $sessionId): bool { return $this->handler->destroy($sessionId); } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { return $this->handler->gc($maxlifetime); } - /** - * @return string - */ - #[\ReturnTypeWillChange] - public function read(string $sessionId) + public function read(string $sessionId): string { return $this->marshaller->unmarshall($this->handler->read($sessionId)); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function write(string $sessionId, string $data) + public function write(string $sessionId, string $data): bool { $failed = []; $marshalledData = $this->marshaller->marshall(['data' => $data], $failed); @@ -88,20 +64,12 @@ public function write(string $sessionId, string $data) return $this->handler->write($sessionId, $marshalledData['data']); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function validateId(string $sessionId) + public function validateId(string $sessionId): bool { return $this->handler->validateId($sessionId); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function updateTimestamp(string $sessionId, string $data) + public function updateTimestamp(string $sessionId, string $data): bool { return $this->handler->updateTimestamp($sessionId, $data); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index 223e5c08f03c0..7febdbbc30a0f 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -54,11 +54,7 @@ public function __construct(\Memcached $memcached, array $options = []) $this->prefix = $options['prefix'] ?? 'sf2s'; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { return $this->memcached->quit(); } @@ -71,11 +67,7 @@ protected function doRead(string $sessionId) return $this->memcached->get($this->prefix.$sessionId) ?: ''; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function updateTimestamp(string $sessionId, string $data) + public function updateTimestamp(string $sessionId, string $data): bool { $this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl); @@ -100,11 +92,7 @@ protected function doDestroy(string $sessionId) return $result || \Memcached::RES_NOTFOUND == $this->memcached->getResultCode(); } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { // not required here because memcached will auto expire the records anyhow. return 0; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php index 990b3b979659d..d5a6245b4b677 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php @@ -38,11 +38,7 @@ public function __construct(\SessionHandlerInterface $currentHandler, \SessionHa $this->writeOnlyHandler = $writeOnlyHandler; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { $result = $this->currentHandler->close(); $this->writeOnlyHandler->close(); @@ -50,11 +46,7 @@ public function close() return $result; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function destroy(string $sessionId) + public function destroy(string $sessionId): bool { $result = $this->currentHandler->destroy($sessionId); $this->writeOnlyHandler->destroy($sessionId); @@ -62,11 +54,7 @@ public function destroy(string $sessionId) return $result; } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { $result = $this->currentHandler->gc($maxlifetime); $this->writeOnlyHandler->gc($maxlifetime); @@ -74,11 +62,7 @@ public function gc(int $maxlifetime) return $result; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function open(string $savePath, string $sessionName) + public function open(string $savePath, string $sessionName): bool { $result = $this->currentHandler->open($savePath, $sessionName); $this->writeOnlyHandler->open($savePath, $sessionName); @@ -86,21 +70,13 @@ public function open(string $savePath, string $sessionName) return $result; } - /** - * @return string - */ - #[\ReturnTypeWillChange] - public function read(string $sessionId) + public function read(string $sessionId): string { // No reading from new handler until switch-over return $this->currentHandler->read($sessionId); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function write(string $sessionId, string $sessionData) + public function write(string $sessionId, string $sessionData): bool { $result = $this->currentHandler->write($sessionId, $sessionData); $this->writeOnlyHandler->write($sessionId, $sessionData); @@ -108,21 +84,13 @@ public function write(string $sessionId, string $sessionData) return $result; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function validateId(string $sessionId) + public function validateId(string $sessionId): bool { // No reading from new handler until switch-over return $this->currentHandler->validateId($sessionId); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function updateTimestamp(string $sessionId, string $sessionData) + public function updateTimestamp(string $sessionId, string $sessionData): bool { $result = $this->currentHandler->updateTimestamp($sessionId, $sessionData); $this->writeOnlyHandler->updateTimestamp($sessionId, $sessionData); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 7110781594a55..ab686732c9fc1 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -99,11 +99,7 @@ protected function doDestroy(string $sessionId) return true; } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { return $this->getCollection()->deleteMany([ $this->options['expiry_field'] => ['$lt' => new \MongoDB\BSON\UTCDateTime()], diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php index abb9028ff06a1..4c1e2c7b847d7 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php @@ -18,20 +18,12 @@ */ class NullSessionHandler extends AbstractSessionHandler { - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { return true; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function validateId(string $sessionId) + public function validateId(string $sessionId): bool { return true; } @@ -44,11 +36,7 @@ protected function doRead(string $sessionId) return ''; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function updateTimestamp(string $sessionId, string $data) + public function updateTimestamp(string $sessionId, string $data): bool { return true; } @@ -69,11 +57,7 @@ protected function doDestroy(string $sessionId) return true; } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { return 0; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 296568d88ef3e..f1e5ae5eee5c3 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -259,11 +259,7 @@ public function isSessionExpired() return $this->sessionExpired; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function open(string $savePath, string $sessionName) + public function open(string $savePath, string $sessionName): bool { $this->sessionExpired = false; @@ -274,11 +270,7 @@ public function open(string $savePath, string $sessionName) return parent::open($savePath, $sessionName); } - /** - * @return string - */ - #[\ReturnTypeWillChange] - public function read(string $sessionId) + public function read(string $sessionId): string { try { return parent::read($sessionId); @@ -289,11 +281,7 @@ public function read(string $sessionId) } } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { // We delay gc() to close() so that it is executed outside the transactional and blocking read-write process. // This way, pruning expired sessions does not block them from being started while the current session is used. @@ -369,11 +357,7 @@ protected function doWrite(string $sessionId, string $data) return true; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function updateTimestamp(string $sessionId, string $data) + public function updateTimestamp(string $sessionId, string $data): bool { $expiry = time() + (int) ini_get('session.gc_maxlifetime'); @@ -394,11 +378,7 @@ public function updateTimestamp(string $sessionId, string $data) return true; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { $this->commit(); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index bdc47654cd6cc..6503168cd2f5c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -112,13 +112,7 @@ public function close(): bool return true; } - /** - * {@inheritdoc} - * - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { return 0; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php index 84b7b80c9e484..20df26746238f 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php @@ -30,11 +30,7 @@ public function __construct(\SessionHandlerInterface $handler) $this->handler = $handler; } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function open(string $savePath, string $sessionName) + public function open(string $savePath, string $sessionName): bool { parent::open($savePath, $sessionName); @@ -49,11 +45,7 @@ protected function doRead(string $sessionId) return $this->handler->read($sessionId); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function updateTimestamp(string $sessionId, string $data) + public function updateTimestamp(string $sessionId, string $data): bool { return $this->write($sessionId, $data); } @@ -66,11 +58,7 @@ protected function doWrite(string $sessionId, string $data) return $this->handler->write($sessionId, $data); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function destroy(string $sessionId) + public function destroy(string $sessionId): bool { $this->doDestroy = true; $destroyed = parent::destroy($sessionId); @@ -88,20 +76,12 @@ protected function doDestroy(string $sessionId) return $this->handler->destroy($sessionId); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { return $this->handler->close(); } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { return $this->handler->gc($maxlifetime); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php index ddfbdad987226..ba40ff12ef482 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php @@ -35,74 +35,42 @@ public function getHandler() // \SessionHandlerInterface - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function open(string $savePath, string $sessionName) + public function open(string $savePath, string $sessionName): bool { - return (bool) $this->handler->open($savePath, $sessionName); + return $this->handler->open($savePath, $sessionName); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { - return (bool) $this->handler->close(); + return $this->handler->close(); } - /** - * @return string - */ - #[\ReturnTypeWillChange] - public function read(string $sessionId) + public function read(string $sessionId): string { - return (string) $this->handler->read($sessionId); + return $this->handler->read($sessionId); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function write(string $sessionId, string $data) + public function write(string $sessionId, string $data): bool { - return (bool) $this->handler->write($sessionId, $data); + return $this->handler->write($sessionId, $data); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function destroy(string $sessionId) + public function destroy(string $sessionId): bool { - return (bool) $this->handler->destroy($sessionId); + return $this->handler->destroy($sessionId); } - /** - * @return int|false - */ - #[\ReturnTypeWillChange] - public function gc(int $maxlifetime) + public function gc(int $maxlifetime): int|false { return $this->handler->gc($maxlifetime); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function validateId(string $sessionId) + public function validateId(string $sessionId): bool { return !$this->handler instanceof \SessionUpdateTimestampHandlerInterface || $this->handler->validateId($sessionId); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function updateTimestamp(string $sessionId, string $data) + public function updateTimestamp(string $sessionId, string $data): bool { return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId, $data) : $this->write($sessionId, $data); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc index fd662e3a16236..0a331ef34b107 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc @@ -60,14 +60,14 @@ class TestSessionHandler extends AbstractSessionHandler $this->data = $data; } - public function open($path, $name): bool + public function open(string $path, string $name): bool { echo __FUNCTION__, "\n"; return parent::open($path, $name); } - public function validateId($sessionId): bool + public function validateId(string $sessionId): bool { echo __FUNCTION__, "\n"; @@ -77,7 +77,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function read($sessionId): string + public function read(string $sessionId): string { echo __FUNCTION__, "\n"; @@ -97,7 +97,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function write($sessionId, $data): bool + public function write(string $sessionId, string $data): bool { echo __FUNCTION__, "\n"; @@ -107,7 +107,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function destroy($sessionId): bool + public function destroy(string $sessionId): bool { echo __FUNCTION__, "\n"; @@ -121,8 +121,7 @@ class TestSessionHandler extends AbstractSessionHandler return true; } - #[\ReturnTypeWillChange] - public function gc($maxLifetime) + public function gc($maxLifetime): int|false { echo __FUNCTION__, "\n"; diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php index 2a5d46a8c1577..2423a5131e4b6 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php @@ -42,11 +42,7 @@ public function toArray() return $this->entries; } - /** - * @return int - */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { $con = $this->connection->getResource(); $searches = $this->search->getResources(); diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 87c664379eafb..e0da5a685caed 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -914,8 +914,6 @@ public function resolve(array $options = []) * * @param bool $triggerDeprecation Whether to trigger the deprecation or not (true by default) * - * @return mixed The option value - * * @throws AccessException If accessing this method outside of * {@link resolve()} * @throws NoSuchOptionException If the option is not set @@ -924,8 +922,7 @@ public function resolve(array $options = []) * @throws OptionDefinitionException If there is a cyclic dependency between * lazy options and/or normalizers */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $option, bool $triggerDeprecation = true) + public function offsetGet(mixed $option, bool $triggerDeprecation = true): mixed { if (!$this->locked) { throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); @@ -1174,14 +1171,11 @@ private function verifyTypes(string $type, mixed $value, array &$invalidTypes, i /** * Returns whether a resolved option with the given name exists. * - * @return bool Whether the option is set - * * @throws AccessException If accessing this method outside of {@link resolve()} * * @see \ArrayAccess::offsetExists() */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $option) + public function offsetExists(mixed $option): bool { if (!$this->locked) { throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); @@ -1193,12 +1187,9 @@ public function offsetExists(mixed $option) /** * Not supported. * - * @return void - * * @throws AccessException */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $option, mixed $value) + public function offsetSet(mixed $option, mixed $value): void { throw new AccessException('Setting options via array access is not supported. Use setDefault() instead.'); } @@ -1206,12 +1197,9 @@ public function offsetSet(mixed $option, mixed $value) /** * Not supported. * - * @return void - * * @throws AccessException */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $option) + public function offsetUnset(mixed $option): void { throw new AccessException('Removing options via array access is not supported. Use remove() instead.'); } @@ -1221,14 +1209,11 @@ public function offsetUnset(mixed $option) * * This may be only a subset of the defined options. * - * @return int Number of options - * * @throws AccessException If accessing this method outside of {@link resolve()} * * @see \Countable::count() */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { if (!$this->locked) { throw new AccessException('Counting is only supported within closures of lazy options and normalizers.'); diff --git a/src/Symfony/Component/Process/InputStream.php b/src/Symfony/Component/Process/InputStream.php index d4730d630a904..d970ccd1d5cae 100644 --- a/src/Symfony/Component/Process/InputStream.php +++ b/src/Symfony/Component/Process/InputStream.php @@ -66,11 +66,7 @@ public function isClosed() return !$this->open; } - /** - * @return \Traversable - */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { $this->open = true; diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index e7ed10eda3114..aa64e050fd05d 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -613,11 +613,8 @@ public function getIncrementalOutput() * * @throws LogicException in case the output has been disabled * @throws LogicException In case the process is not started - * - * @return \Generator */ - #[\ReturnTypeWillChange] - public function getIterator(int $flags = 0) + public function getIterator(int $flags = 0): \Generator { $this->readPipesForOutput(__FUNCTION__, false); diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index d1de915a8abc7..7feaaa4d573c0 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -143,11 +143,8 @@ public function getParent() /** * Returns a new iterator for this path. - * - * @return PropertyPathIteratorInterface */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): PropertyPathIteratorInterface { return new PropertyPathIterator($this); } diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index 23c7bd3760b3c..8de6051ae4241 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -54,21 +54,17 @@ public function __clone() * * @see all() * - * @return \ArrayIterator|Route[] An \ArrayIterator object for iterating over routes + * @return \ArrayIterator An \ArrayIterator object for iterating over routes */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->all()); } /** * Gets the number of Routes in this collection. - * - * @return int The number of routes */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->routes); } diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index ffa50e2be9a5b..966bbb1761e38 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -165,34 +165,25 @@ protected function evaluate(Storage $template, array $parameters = []) /** * Gets a helper value. * - * @return HelperInterface The helper value - * * @throws \InvalidArgumentException if the helper is not defined */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $name) + public function offsetGet(mixed $name): HelperInterface { return $this->get($name); } /** * Returns true if the helper is defined. - * - * @return bool true if the helper is defined, false otherwise */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $name) + public function offsetExists(mixed $name): bool { return isset($this->helpers[$name]); } /** * Sets a helper. - * - * @return void */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $name, mixed $value) + public function offsetSet(mixed $name, mixed $value): void { $this->set($name, $value); } @@ -200,12 +191,9 @@ public function offsetSet(mixed $name, mixed $value) /** * Removes a helper. * - * @return void - * * @throws \LogicException */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $name) + public function offsetUnset(mixed $name): void { 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 7ea87433233f8..850d067a289b1 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationList.php +++ b/src/Symfony/Component/Validator/ConstraintViolationList.php @@ -114,50 +114,29 @@ public function remove(int $offset) /** * {@inheritdoc} * - * @return \ArrayIterator|ConstraintViolationInterface[] + * @return \ArrayIterator */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->violations); } - /** - * @return int - */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->violations); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $offset) + public function offsetExists(mixed $offset): bool { return $this->has($offset); } - /** - * {@inheritdoc} - * - * @return mixed - */ - #[\ReturnTypeWillChange] - public function offsetGet(mixed $offset) + public function offsetGet(mixed $offset): mixed { return $this->get($offset); } - /** - * {@inheritdoc} - * - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $offset, mixed $violation) + public function offsetSet(mixed $offset, mixed $violation): void { if (null === $offset) { $this->add($violation); @@ -166,13 +145,7 @@ public function offsetSet(mixed $offset, mixed $violation) } } - /** - * {@inheritdoc} - * - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $offset) + public function offsetUnset(mixed $offset): void { $this->remove($offset); } diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index 2f177ac6c2264..6836a7100b3f2 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -108,20 +108,12 @@ public function getValue(array|bool $recursive = false) return $children; } - /** - * @return int - */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->getValue()); } - /** - * @return \Traversable - */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable { if (!\is_array($value = $this->getValue())) { throw new \LogicException(sprintf('"%s" object holds non-iterable type "%s".', self::class, get_debug_type($value))); @@ -149,11 +141,7 @@ public function __isset(string $key) return null !== $this->seek($key); } - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function offsetExists(mixed $key) + public function offsetExists(mixed $key): bool { return $this->__isset($key); } @@ -163,20 +151,12 @@ public function offsetGet(mixed $key): mixed return $this->__get($key); } - /** - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetSet(mixed $key, mixed $value) + public function offsetSet(mixed $key, mixed $value): void { throw new \BadMethodCallException(self::class.' objects are immutable.'); } - /** - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetUnset(mixed $key) + public function offsetUnset(mixed $key): void { throw new \BadMethodCallException(self::class.' objects are immutable.'); }