Skip to content

Commit 08b0176

Browse files
committed
minor #42378 Remove ReturnTypeWillChange (derrabus)
This PR was merged into the 6.0 branch. Discussion ---------- Remove `ReturnTypeWillChange` | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A This PR removed the `ReturnTypeWillChange` attribute everywhere by adding actual return types. Commits ------- 2d3e1ed Remove ReturnTypeWillChange
2 parents 3f42796 + 2d3e1ed commit 08b0176

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+178
-704
lines changed

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

+4-20
Original file line numberDiff line numberDiff line change
@@ -855,11 +855,7 @@ public function resultWithEmptyIterator(): array
855855

856856
return [
857857
[$entity, new class() implements \Iterator {
858-
/**
859-
* @return mixed
860-
*/
861-
#[\ReturnTypeWillChange]
862-
public function current()
858+
public function current(): mixed
863859
{
864860
return null;
865861
}
@@ -873,11 +869,7 @@ public function next(): void
873869
{
874870
}
875871

876-
/**
877-
* @return mixed
878-
*/
879-
#[\ReturnTypeWillChange]
880-
public function key()
872+
public function key(): mixed
881873
{
882874
return false;
883875
}
@@ -887,11 +879,7 @@ public function rewind(): void
887879
}
888880
}],
889881
[$entity, new class() implements \Iterator {
890-
/**
891-
* @return mixed
892-
*/
893-
#[\ReturnTypeWillChange]
894-
public function current()
882+
public function current(): mixed
895883
{
896884
return false;
897885
}
@@ -905,11 +893,7 @@ public function next(): void
905893
{
906894
}
907895

908-
/**
909-
* @return mixed
910-
*/
911-
#[\ReturnTypeWillChange]
912-
public function key()
896+
public function key(): mixed
913897
{
914898
return false;
915899
}

src/Symfony/Component/Console/Helper/HelperSet.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ public function getCommand()
8989
}
9090

9191
/**
92-
* @return \Traversable<Helper>
92+
* @return \Traversable<string, Helper>
9393
*/
94-
#[\ReturnTypeWillChange]
95-
public function getIterator()
94+
public function getIterator(): \Traversable
9695
{
9796
return new \ArrayIterator($this->helpers);
9897
}

src/Symfony/Component/DomCrawler/Crawler.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -1071,20 +1071,15 @@ public function getNode(int $position)
10711071
return $this->nodes[$position] ?? null;
10721072
}
10731073

1074-
/**
1075-
* @return int
1076-
*/
1077-
#[\ReturnTypeWillChange]
1078-
public function count()
1074+
public function count(): int
10791075
{
10801076
return \count($this->nodes);
10811077
}
10821078

10831079
/**
1084-
* @return \ArrayIterator|\DOMNode[]
1080+
* @return \ArrayIterator<int, \DOMNode>
10851081
*/
1086-
#[\ReturnTypeWillChange]
1087-
public function getIterator()
1082+
public function getIterator(): \ArrayIterator
10881083
{
10891084
return new \ArrayIterator($this->nodes);
10901085
}

src/Symfony/Component/DomCrawler/Form.php

+4-14
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,8 @@ public function all()
301301
* Returns true if the named field exists.
302302
*
303303
* @param string $name The field name
304-
*
305-
* @return bool true if the field exists, false otherwise
306304
*/
307-
#[\ReturnTypeWillChange]
308-
public function offsetExists(mixed $name)
305+
public function offsetExists(mixed $name): bool
309306
{
310307
return $this->has($name);
311308
}
@@ -319,8 +316,7 @@ public function offsetExists(mixed $name)
319316
*
320317
* @throws \InvalidArgumentException if the field does not exist
321318
*/
322-
#[\ReturnTypeWillChange]
323-
public function offsetGet(mixed $name)
319+
public function offsetGet(mixed $name): FormField|array
324320
{
325321
return $this->fields->get($name);
326322
}
@@ -331,12 +327,9 @@ public function offsetGet(mixed $name)
331327
* @param string $name The field name
332328
* @param string|array $value The value of the field
333329
*
334-
* @return void
335-
*
336330
* @throws \InvalidArgumentException if the field does not exist
337331
*/
338-
#[\ReturnTypeWillChange]
339-
public function offsetSet(mixed $name, mixed $value)
332+
public function offsetSet(mixed $name, mixed $value): void
340333
{
341334
$this->fields->set($name, $value);
342335
}
@@ -345,11 +338,8 @@ public function offsetSet(mixed $name, mixed $value)
345338
* Removes a field from the form.
346339
*
347340
* @param string $name The field name
348-
*
349-
* @return void
350341
*/
351-
#[\ReturnTypeWillChange]
352-
public function offsetUnset(mixed $name)
342+
public function offsetUnset(mixed $name): void
353343
{
354344
$this->fields->remove($name);
355345
}

src/Symfony/Component/EventDispatcher/GenericEvent.php

+5-20
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,9 @@ public function hasArgument(string $key)
112112
*
113113
* @param string $key Array key
114114
*
115-
* @return mixed
116-
*
117115
* @throws \InvalidArgumentException if key does not exist in $this->args
118116
*/
119-
#[\ReturnTypeWillChange]
120-
public function offsetGet(mixed $key)
117+
public function offsetGet(mixed $key): mixed
121118
{
122119
return $this->getArgument($key);
123120
}
@@ -126,11 +123,8 @@ public function offsetGet(mixed $key)
126123
* ArrayAccess for argument setter.
127124
*
128125
* @param string $key Array key to set
129-
*
130-
* @return void
131126
*/
132-
#[\ReturnTypeWillChange]
133-
public function offsetSet(mixed $key, mixed $value)
127+
public function offsetSet(mixed $key, mixed $value): void
134128
{
135129
$this->setArgument($key, $value);
136130
}
@@ -139,11 +133,8 @@ public function offsetSet(mixed $key, mixed $value)
139133
* ArrayAccess for unset argument.
140134
*
141135
* @param string $key Array key
142-
*
143-
* @return void
144136
*/
145-
#[\ReturnTypeWillChange]
146-
public function offsetUnset(mixed $key)
137+
public function offsetUnset(mixed $key): void
147138
{
148139
if ($this->hasArgument($key)) {
149140
unset($this->arguments[$key]);
@@ -154,22 +145,16 @@ public function offsetUnset(mixed $key)
154145
* ArrayAccess has argument.
155146
*
156147
* @param string $key Array key
157-
*
158-
* @return bool
159148
*/
160-
#[\ReturnTypeWillChange]
161-
public function offsetExists(mixed $key)
149+
public function offsetExists(mixed $key): bool
162150
{
163151
return $this->hasArgument($key);
164152
}
165153

166154
/**
167155
* IteratorAggregate for iterating over the object like an array.
168-
*
169-
* @return \ArrayIterator
170156
*/
171-
#[\ReturnTypeWillChange]
172-
public function getIterator()
157+
public function getIterator(): \ArrayIterator
173158
{
174159
return new \ArrayIterator($this->arguments);
175160
}

src/Symfony/Component/Finder/Finder.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,11 @@ public function in(string|array $dirs)
603603
*
604604
* This method implements the IteratorAggregate interface.
605605
*
606-
* @return \Iterator|SplFileInfo[] An iterator
606+
* @return \Iterator<SplFileInfo> An iterator
607607
*
608608
* @throws \LogicException if the in() method has not been called
609609
*/
610-
#[\ReturnTypeWillChange]
611-
public function getIterator()
610+
public function getIterator(): \Iterator
612611
{
613612
if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
614613
throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
@@ -687,11 +686,8 @@ public function hasResults()
687686

688687
/**
689688
* Counts all the results collected by the iterators.
690-
*
691-
* @return int
692689
*/
693-
#[\ReturnTypeWillChange]
694-
public function count()
690+
public function count(): int
695691
{
696692
return iterator_count($this->getIterator());
697693
}

src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public function __construct(\Iterator $iterator, array $filters)
4646
*
4747
* @return bool true if the value should be kept, false otherwise
4848
*/
49-
#[\ReturnTypeWillChange]
50-
public function accept()
49+
public function accept(): bool
5150
{
5251
$fileinfo = $this->current();
5352

src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators)
3838
*
3939
* @return bool true if the value should be kept, false otherwise
4040
*/
41-
#[\ReturnTypeWillChange]
42-
public function accept()
41+
public function accept(): bool
4342
{
4443
$fileinfo = $this->current();
4544

src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth
3838
*
3939
* @return bool true if the value should be kept, false otherwise
4040
*/
41-
#[\ReturnTypeWillChange]
42-
public function accept()
41+
public function accept(): bool
4342
{
4443
return $this->getInnerIterator()->getDepth() >= $this->minDepth;
4544
}

src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public function __construct(\Iterator $iterator, array $directories)
5252
*
5353
* @return bool True if the value should be kept, false otherwise
5454
*/
55-
#[\ReturnTypeWillChange]
56-
public function accept()
55+
public function accept(): bool
5756
{
5857
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
5958
return false;
@@ -69,20 +68,12 @@ public function accept()
6968
return true;
7069
}
7170

72-
/**
73-
* @return bool
74-
*/
75-
#[\ReturnTypeWillChange]
76-
public function hasChildren()
71+
public function hasChildren(): bool
7772
{
7873
return $this->isRecursive && $this->iterator->hasChildren();
7974
}
8075

81-
/**
82-
* @return self
83-
*/
84-
#[\ReturnTypeWillChange]
85-
public function getChildren()
76+
public function getChildren(): self
8677
{
8778
$children = new self($this->iterator->getChildren(), []);
8879
$children->excludedDirs = $this->excludedDirs;

src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public function __construct(\Iterator $iterator, int $mode)
3939
*
4040
* @return bool true if the value should be kept, false otherwise
4141
*/
42-
#[\ReturnTypeWillChange]
43-
public function accept()
42+
public function accept(): bool
4443
{
4544
$fileinfo = $this->current();
4645
if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {

src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class FilecontentFilterIterator extends MultiplePcreFilterIterator
2424
*
2525
* @return bool true if the value should be kept, false otherwise
2626
*/
27-
#[\ReturnTypeWillChange]
28-
public function accept()
27+
public function accept(): bool
2928
{
3029
if (!$this->matchRegexps && !$this->noMatchRegexps) {
3130
return true;

src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class FilenameFilterIterator extends MultiplePcreFilterIterator
2525
*
2626
* @return bool true if the value should be kept, false otherwise
2727
*/
28-
#[\ReturnTypeWillChange]
29-
public function accept()
28+
public function accept(): bool
3029
{
3130
return $this->isAccepted($this->current()->getFilename());
3231
}

src/Symfony/Component/Finder/Iterator/PathFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
2424
*
2525
* @return bool true if the value should be kept, false otherwise
2626
*/
27-
#[\ReturnTypeWillChange]
28-
public function accept()
27+
public function accept(): bool
2928
{
3029
$filename = $this->current()->getRelativePathname();
3130

src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs
4848

4949
/**
5050
* Return an instance of SplFileInfo with support for relative paths.
51-
*
52-
* @return SplFileInfo File information
5351
*/
54-
#[\ReturnTypeWillChange]
55-
public function current()
52+
public function current(): SplFileInfo
5653
{
5754
// the logic here avoids redoing the same work in all iterations
5855

@@ -105,11 +102,8 @@ public function getChildren()
105102

106103
/**
107104
* Do nothing for non rewindable stream.
108-
*
109-
* @return void
110105
*/
111-
#[\ReturnTypeWillChange]
112-
public function rewind()
106+
public function rewind(): void
113107
{
114108
if (false === $this->isRewindable()) {
115109
return;

src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators)
3838
*
3939
* @return bool true if the value should be kept, false otherwise
4040
*/
41-
#[\ReturnTypeWillChange]
42-
public function accept()
41+
public function accept(): bool
4342
{
4443
$fileinfo = $this->current();
4544
if (!$fileinfo->isFile()) {

src/Symfony/Component/Finder/Iterator/SortableIterator.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ public function __construct(\Traversable $iterator, int|callable $sort, bool $re
7878
}
7979
}
8080

81-
/**
82-
* @return \Traversable
83-
*/
84-
#[\ReturnTypeWillChange]
85-
public function getIterator()
81+
public function getIterator(): \Traversable
8682
{
8783
if (1 === $this->sort) {
8884
return $this->iterator;

0 commit comments

Comments
 (0)