Skip to content

Remove ReturnTypeWillChange #42378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -873,11 +869,7 @@ public function next(): void
{
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return false;
}
Expand All @@ -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;
}
Expand All @@ -905,11 +893,7 @@ public function next(): void
{
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Console/Helper/HelperSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ public function getCommand()
}

/**
* @return \Traversable<Helper>
* @return \Traversable<string, Helper>
*/
#[\ReturnTypeWillChange]
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->helpers);
}
Expand Down
11 changes: 3 additions & 8 deletions src/Symfony/Component/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, \DOMNode>
*/
#[\ReturnTypeWillChange]
public function getIterator()
public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->nodes);
}
Expand Down
18 changes: 4 additions & 14 deletions src/Symfony/Component/DomCrawler/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
25 changes: 5 additions & 20 deletions src/Symfony/Component/EventDispatcher/GenericEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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]);
Expand All @@ -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);
}
Expand Down
10 changes: 3 additions & 7 deletions src/Symfony/Component/Finder/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,11 @@ public function in(string|array $dirs)
*
* This method implements the IteratorAggregate interface.
*
* @return \Iterator|SplFileInfo[] An iterator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to fix those phpdocs in lower branches?

* @return \Iterator<SplFileInfo> 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.');
Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Finder/Iterator/PathFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 1 addition & 5 deletions src/Symfony/Component/Finder/Iterator/SortableIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading