10000 Fix return types for PHP 8.1 · symfony/symfony@3eca446 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3eca446

Browse files
committed
Fix return types for PHP 8.1
1 parent 2cee75b commit 3eca446

File tree

54 files changed

+194
-42
lines changed

Some content is hidden

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

54 files changed

+194
-42
lines changed

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,10 @@ public function resultWithEmptyIterator(): array
827827

828828
return [
829829
[$entity, new class() implements \Iterator {
830+
/**
831+
* @return mixed
832+
*/
833+
#[\ReturnTypeWillChange]
830834
public function current()
831835
{
832836
return null;
@@ -837,19 +841,28 @@ public function valid(): bool
837841
return false;
838842
}
839843

840-
public function next()
844+
public function next(): void
841845
{
842846
}
843847

848+
/**
849+
* @return mixed
850+
*/
851+
#[\ReturnTypeWillChange]
844852
public function key()
845853
{
854+
return false;
846855
}
847856

848-
public function rewind()
857+
public function rewind(): void
849858
{
850859
}
851860
}],
852861
[$entity, new class() implements \Iterator {
862+
/**
863+
* @return mixed
864+
*/
865+
#[\ReturnTypeWillChange]
853866
public function current()
854867
{
855868
return false;
@@ -860,15 +873,20 @@ public function valid(): bool
860873
return false;
861874
}
862875

863-
public function next()
876+
public function next(): void
864877
{
865878
}
866879

880+
/**
881+
* @return mixed
882+
*/
883+
#[\ReturnTypeWillChange]
867884
public function key()
868885
{
886+
return false;
869887
}
870888

871-
public function rewind()
889+
public function rewind(): void
872890
{
873891
}
874892
}],

src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct(KernelInterface $kernel, string $rootDir, array $pat
4545
/**
4646
* @return \Traversable
4747
*/
48+
#[\ReturnTypeWillChange]
4849
public function getIterator()
4950
{
5051
if (null !== $this->templates) {

src/Symfony/Component/Config/Resource/GlobResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function __wakeup(): void
102102
/**
103103
* @return \Traversable
104104
*/
105+
#[\ReturnTypeWillChange]
105106
public function getIterator()
106107
{
107108
if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ public function getCommand()
9898
}
9999

100100
/**
101-
* @return Helper[]
101+
* @return \Traversable<Helper>
102102
*/
103+
#[\ReturnTypeWillChange]
103104
public function getIterator()
104105
{
105106
return new \ArrayIterator($this->helpers);

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ public function getNode($position)
11491149
/**
11501150
* @return int
11511151
*/
1152+
#[\ReturnTypeWillChange]
11521153
public function count()
11531154
{
11541155
return \count($this->nodes);
@@ -1157,6 +1158,7 @@ public function count()
11571158
/**
11581159
* @return \ArrayIterator|\DOMNode[]
11591160
*/
1161+
#[\ReturnTypeWillChange]
11601162
public function getIterator()
11611163
{
11621164
return new \ArrayIterator($this->nodes);

src/Symfony/Component/DomCrawler/Form.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ public function all()
321321
*
322322
* @return bool true if the field exists, false otherwise
323323
*/
324+
#[\ReturnTypeWillChange]
324325
public function offsetExists($name)
325326
{
326327
return $this->has($name);
@@ -335,6 +336,7 @@ public function offsetExists($name)
335336
*
336337
* @throws \InvalidArgumentException if the field does not exist
337338
*/
339+
#[\ReturnTypeWillChange]
338340
public function offsetGet($name)
339341
{
340342
return $this->fields->get($name);
@@ -350,6 +352,7 @@ public function offsetGet($name)
350352
*
351353
* @throws \InvalidArgumentException if the field does not exist
352354
*/
355+
#[\ReturnTypeWillChange]
353356
public function offsetSet($name, $value)
354357
{
355358
$this->fields->set($name, $value);
@@ -362,6 +365,7 @@ public function offsetSet($name, $value)
362365
*
363366
* @return void
364367
*/
368+
#[\ReturnTypeWillChange]
365369
public function offsetUnset($name)
366370
{
367371
$this->fields->remove($name);

src/Symfony/Component/EventDispatcher/GenericEvent.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public function hasArgument($key)
123123
*
124124
* @throws \InvalidArgumentException if key does not exist in $this->args
125125
*/
126+
#[\ReturnTypeWillChange]
126127
public function offsetGet($key)
127128
{
128129
return $this->getArgument($key);
@@ -136,6 +137,7 @@ public function offsetGet($key)
136137
*
137138
* @return void
138139
*/
140+
#[\ReturnTypeWillChange]
139141
public function offsetSet($key, $value)
140142
{
141143
$this->setArgument($key, $value);
@@ -148,6 +150,7 @@ public function offsetSet($key, $value)
148150
*
149151
* @return void
150152
*/
153+
#[\ReturnTypeWillChange]
151154
public function offsetUnset($key)
152155
{
153156
if ($this->hasArgument($key)) {
@@ -162,6 +165,7 @@ public function offsetUnset($key)
162165
*
163166
* @return bool
164167
*/
168+
#[\ReturnTypeWillChange]
165169
public function offsetExists($key)
166170
{
167171
return $this->hasArgument($key);
@@ -172,6 +176,7 @@ public function offsetExists($key)
172176
*
173177
* @return \ArrayIterator
174178
*/
179+
#[\ReturnTypeWillChange]
175180
public function getIterator()
176181
{
177182
return new \ArrayIterator($this->arguments);

src/Symfony/Component/Finder/Finder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ public function in($dirs)
618618
*
619619
* @throws \LogicException if the in() method has not been called
620620
*/
621+
#[\ReturnTypeWillChange]
621622
public function getIterator()
622623
{
623624
if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
@@ -702,6 +703,7 @@ public function hasResults()
702703
*
703704
* @return int
704705
*/
706+
#[\ReturnTypeWillChange]
705707
public function count()
706708
{
707709
return iterator_count($this->getIterator());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +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]
4950
public function accept()
5051
{
5152
$fileinfo = $this->current();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +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]
4142
public function accept()
4243
{
4344
$fileinfo = $this->current();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +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]
4142
public function accept()
4243
{
4344
return $this->getInnerIterator()->getDepth() >= $this->minDepth;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +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]
5556
public function accept()
5657
{
5758
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
@@ -71,6 +72,7 @@ public function accept()
7172
/**
7273
* @return bool
7374
*/
75+
#[\ReturnTypeWillChange]
7476
public function hasChildren()
7577
{
7678
return $this->isRecursive && $this->iterator->hasChildren();
@@ -79,6 +81,7 @@ public function hasChildren()
7981
/**
8082
* @return self
8183
*/
84+
#[\ReturnTypeWillChange]
8285
public function getChildren()
8386
{
8487
$children = new self($this->iterator->getChildren(), []);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +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]
4243
public function accept()
4344
{
4445
$fileinfo = $this->current();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class FilecontentFilterIterator extends MultiplePcreFilterIterator
2424
*
2525
* @return bool true if the value should be kept, false otherwise
2626
*/
27+
#[\ReturnTypeWillChange]
2728
public function accept()
2829
{
2930
if (!$this->matchRegexps && !$this->noMatchRegexps) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class FilenameFilterIterator extends MultiplePcreFilterIterator
2525
*
2626
* @return bool true if the value should be kept, false otherwise
2727
*/
28+
#[\ReturnTypeWillChange]
2829
public function accept()
2930
{
3031
return $this->isAccepted($this->current()->getFilename());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
2424
*
2525
* @return bool true if the value should be kept, false otherwise
2626
*/
27+
#[\ReturnTypeWillChange]
2728
public function accept()
2829
{
2930
$filename = $this->current()->getRelativePathname();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +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]
4142
public function accept()
4243
{
4344
$fileinfo = $this->current();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder =
8181
/**
8282
* @return \Traversable
8383
*/
84+
#[\ReturnTypeWillChange]
8485
public function getIterator()
8586
{
8687
if (1 === $this->sort) {

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public function __construct(array $values = [])
2323
$this->rewind();
2424
}
2525

26-
public function attach(\SplFileInfo $fileinfo)
26+
public function attach(\SplFileInfo $fileinfo): void
2727
{
2828
$this->values[] = $fileinfo;
2929
}
3030

31-
public function rewind()
31+
public function rewind(): void
3232
{
3333
reset($this->values);
3434
}
@@ -38,16 +38,24 @@ public function valid(): bool
3838
return false !== $this->current();
3939
}
4040

41-
public function next()
41+
public function next(): void
4242
{
4343
next($this->values);
4444
}
4545

46+
/**
47+
* @return mixed
48+
*/
49+
#[\ReturnTypeWillChange]
4650
public function current()
4751
{
4852
return current($this->values);
4953
}
5054

55+
/**
56+
* @return mixed
57+
*/
58+
#[\ReturnTypeWillChange]
5159
public function key()
5260
{
5361
return key($this->values);

src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct()
5454
{
5555
}
5656

57-
public function accept()
57+
public function accept(): bool
5858
{
5959
throw new \BadFunctionCallException('Not implemented');
6060
}

src/Symfony/Component/Form/Button.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function __construct(FormConfigInterface $config)
5151
*
5252
* @return bool Always returns false
5353
*/
54+
#[\ReturnTypeWillChange]
5455
public function offsetExists($offset)
5556
{
5657
return false;
@@ -67,6 +68,7 @@ public function offsetExists($offset)
6768
*
6869
* @throws BadMethodCallException
6970
*/
71+
#[\ReturnTypeWillChange]
7072
public function offsetGet($offset)
7173
{
7274
throw new BadMethodCallException('Buttons cannot have children.');
@@ -84,6 +86,7 @@ public function offsetGet($offset)
8486
*
8587
* @throws BadMethodCallException
8688
*/
89+
#[\ReturnTypeWillChange]
8790
public function offsetSet($offset, $value)
8891
{
8992
throw new BadMethodCallException('Buttons cannot have children.');
@@ -100,6 +103,7 @@ public function offsetSet($offset, $value)
100103
*
101104
* @throws BadMethodCallException
102105
*/
106+
#[\ReturnTypeWillChange]
103107
public function offsetUnset($offset)
104108
{
105109
throw new BadMethodCallException('Buttons cannot have children.');
@@ -436,6 +440,7 @@ public function createView(FormView $parent = null)
436440
*
437441
* @return int Always returns 0
438442
*/
443+
#[\ReturnTypeWillChange]
439444
public function count()
440445
{
441446
return 0;
@@ -446,6 +451,7 @@ public function count()
446451
*
447452
* @return \EmptyIterator Always returns an empty iterator
448453
*/
454+
#[\ReturnTypeWillChange]
449455
public function getIterator()
450456
{
451457
return new \EmptyIterator();

0 commit comments

Comments
 (0)
0