Skip to content

Commit 40fcc28

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: Fix return types for PHP 8.1
2 parents 7d3ece4 + a08b922 commit 40fcc28

File tree

12 files changed

+58
-10
lines changed

12 files changed

+58
-10
lines changed

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.');
@@ -430,6 +434,7 @@ public function createView(FormView $parent = null)
430434
*
431435
* @return int Always returns 0
432436
*/
437+
#[\ReturnTypeWillChange]
433438
public function count()
434439
{
435440
return 0;
@@ -440,6 +445,7 @@ public function count()
440445
*
441446
* @return \EmptyIterator Always returns an empty iterator
442447
*/
448+
#[\ReturnTypeWillChange]
443449
public function getIterator()
444450
{
445451
return new \EmptyIterator();

ButtonBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ public function getIsEmptyCallback(): ?callable
715715
*
716716
* @return int Always returns 0
717717
*/
718+
#[\ReturnTypeWillChange]
718719
public function count()
719720
{
720721
return 0;
@@ -725,6 +726,7 @@ public function count()
725726
*
726727
* @return \EmptyIterator Always returns an empty iterator
727728
*/
729+
#[\ReturnTypeWillChange]
728730
public function getIterator()
729731
{
730732
return new \EmptyIterator();

ChoiceList/View/ChoiceGroupView.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public function __construct(string $label, array $choices = [])
3535
/**
3636
* {@inheritdoc}
3737
*
38-
* @return self[]|ChoiceView[]
38+
* @return \Traversable<ChoiceGroupView|ChoiceView>
3939
*/
40+
#[\ReturnTypeWillChange]
4041
public function getIterator()
4142
{
4243
return new \ArrayIterator($this->choices);

Extension/Validator/ViolationMapper/ViolationPath.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public function mapsForm(int $index)
221221
*
222222
* @return ViolationPathIterator
223223
*/
224+
#[\ReturnTypeWillChange]
224225
public function getIterator()
225226
{
226227
return new ViolationPathIterator($this);

Form.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ public function get(string $name)
965965
*
966966
* @return bool
967967
*/
968+
#[\ReturnTypeWillChange]
968969
public function offsetExists($name)
969970
{
970971
return $this->has($name);
@@ -979,6 +980,7 @@ public function offsetExists($name)
979980
*
980981
* @throws OutOfBoundsException if the named child does not exist
981982
*/
983+
#[\ReturnTypeWillChange]
982984
public function offsetGet($name)
983985
{
984986
return $this->get($name);
@@ -997,6 +999,7 @@ public function offsetGet($name)
997999
*
9981000
* @see self::add()
9991001
*/
1002+
#[\ReturnTypeWillChange]
10001003
public function offsetSet($name, $child)
10011004
{
10021005
$this->add($child);
@@ -1011,6 +1014,7 @@ public function offsetSet($name, $child)
10111014
*
10121015
* @throws AlreadySubmittedException if the form has already been submitted
10131016
*/
1017+
#[\ReturnTypeWillChange]
10141018
public function offsetUnset($name)
10151019
{
10161020
$this->remove($name);
@@ -1021,6 +1025,7 @@ public function offsetUnset($name)
10211025
*
10221026
* @return \Traversable<FormInterface>
10231027
*/
1028+
#[\ReturnTypeWillChange]
10241029
public function getIterator()
10251030
{
10261031
return $this->children;
@@ -1031,6 +1036,7 @@ public function getIterator()
10311036
*
10321037
* @return int The number of embedded form children
10331038
*/
1039+
#[\ReturnTypeWillChange]
10341040
public function count()
10351041
{
10361042
return \count($this->children);

FormBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function all()
161161
/**
162162
* @return int
163163
*/
164+
#[\ReturnTypeWillChange]
164165
public function count()
165166
{
166167
if ($this->locked) {
@@ -215,6 +216,7 @@ public function getForm()
215216
*
216217
* @return FormBuilderInterface[]|\Traversable
217218
*/
219+
#[\ReturnTypeWillChange]
218220
public function getIterator()
219221
{
220222
if ($this->locked) {

FormErrorIterator.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function getForm()
9393
*
9494
* @return FormError|self An error or an iterator containing nested errors
9595
*/
96+
#[\ReturnTypeWillChange]
9697
public function current()
9798
{
9899
return current($this->errors);
@@ -101,6 +102,7 @@ public function current()
101102
/**
102103
* Advances the iterator to the next position.
103104
*/
105+
#[\ReturnTypeWillChange]
104106
public function next()
105107
{
106108
next($this->errors);
@@ -111,6 +113,7 @@ public function next()
111113
*
112114
* @return int The 0-indexed position
113115
*/
116+
#[\ReturnTypeWillChange]
114117
public function key()
115118
{
116119
return key($this->errors);
@@ -121,6 +124,7 @@ public function key()
121124
*
122125
* @return bool Whether the iterator is valid
123126
*/
127+
#[\ReturnTypeWillChange]
124128
public function valid()
125129
{
126130
return null !== key($this->errors);
@@ -132,6 +136,7 @@ public function valid()
132136
* This method detects if errors have been added to the form since the
133137
* construction of the iterator.
134138
*/
139+
#[\ReturnTypeWillChange]
135140
public function rewind()
136141
{
137142
reset($this->errors);
@@ -144,6 +149,7 @@ public function rewind()
144149
*
145150
* @return bool Whether that position exists
146151
*/
152+
#[\ReturnTypeWillChange]
147153
public function offsetExists($position)
148154
{
149155
return isset($this->errors[$position]);
@@ -158,6 +164,7 @@ public function offsetExists($position)
158164
*
159165
* @throws OutOfBoundsException If the given position does not exist
160166
*/
167+
#[\ReturnTypeWillChange]
161168
public function offsetGet($position)
162169
{
163170
if (!isset($this->errors[$position])) {
@@ -174,6 +181,7 @@ public function offsetGet($position)
174181
*
175182
* @throws BadMethodCallException
176183
*/
184+
#[\ReturnTypeWillChange]
177185
public function offsetSet($position, $value)
178186
{
179187
throw new BadMethodCallException('The iterator doesn\'t support modification of elements.');
@@ -186,6 +194,7 @@ public function offsetSet($position, $value)
186194
*
187195
* @throws BadMethodCallException
188196
*/
197+
#[\ReturnTypeWillChange]
189198
public function offsetUnset($position)
190199
{
191200
throw new BadMethodCallException('The iterator doesn\'t support modification of elements.');
@@ -197,6 +206,7 @@ public function offsetUnset($position)
197206
*
198207
* @return bool Whether the current element is an instance of this class
199208
*/
209+
#[\ReturnTypeWillChange]
200210
public function hasChildren()
201211
{
202212
return current($this->errors) instanceof self;
@@ -207,6 +217,7 @@ public function hasChildren()
207217
*
208218
* @return self
209219
*/
220+
#[\ReturnTypeWillChange]
210221
public function getChildren()
211222
{
212223
return current($this->errors);
@@ -229,6 +240,7 @@ public function getChildren()
229240
*
230241
* @return int The number of iterated elements
231242
*/
243+
#[\ReturnTypeWillChange]
232244
public function count()
233245
{
234246
return \count($this->errors);
@@ -243,6 +255,7 @@ public function count()
243255
*
244256
* @throws OutOfBoundsException If the position is invalid
245257
*/
258+
#[\ReturnTypeWillChange]
246259
public function seek($position)
247260
{
248261
if (!isset($this->errors[$position])) {

FormView.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function setMethodRendered()
108108
*
109109
* @return self The child view
110110
*/
111+
#[\ReturnTypeWillChange]
111112
public function offsetGet($name)
112113
{
113114
return $this->children[$name];
@@ -120,6 +121,7 @@ public function offsetGet($name)
120121
*
121122
* @return bool Whether the child view exists
122123
*/
124+
#[\ReturnTypeWillChange]
123125
public function offsetExists($name)
124126
{
125127
return isset($this->children[$name]);
@@ -132,6 +134,7 @@ public function offsetExists($name)
132134
*
133135
* @throws BadMethodCallException always as setting a child by name is not allowed
134136
*/
137+
#[\ReturnTypeWillChange]
135138
public function offsetSet($name, $value)
136139
{
137140
throw new BadMethodCallException('Not supported.');
@@ -144,6 +147,7 @@ public function offsetSet($name, $value)
144147
*
145148
* @return void
146149
*/
150+
#[\ReturnTypeWillChange]
147151
public function offsetUnset($name)
148152
{
149153
unset($this->children[$name]);
@@ -154,6 +158,7 @@ public function offsetUnset($name)
154158
*
155159
* @return \ArrayIterator<string, FormView> The iterator
156160
*/
161+
#[\ReturnTypeWillChange]
157162
public function getIterator()
158163
{
159164
return new \ArrayIterator($this->children);
@@ -164,6 +169,7 @@ public function getIterator()
164169
*
165170
* @return int The number of children views
166171
*/
172+
#[\ReturnTypeWillChange]
167173
public function count()
168174
{
169175
return \count($this->children);

Tests/Fixtures/CustomArrayObject.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ public function offsetExists($offset): bool
2929
return \array_key_exists($offset, $this->array);
3030
}
3131

32+
/**
33+
* @param mixed $offset
34+
* @return mixed
35+
*/
36+
#[\ReturnTypeWillChange]
3237
public function offsetGet($offset)
3338
{
3439
return $this->array[$offset];
3540
}
3641

37-
public function offsetSet($offset, $value)
42+
public function offsetSet($offset, $value): void
3843
{
3944
if (null === $offset) {
4045
$this->array[] = $value;
@@ -43,7 +48,7 @@ public function offsetSet($offset, $value)
4348
}
4449
}
4550

46-
public function offsetUnset($offset)
51+
public function offsetUnset($offset): void
4752
{
4853
unset($this->array[$offset]);
4954
}
@@ -73,7 +78,7 @@ public function __unserialize(array $data): void
7378
$this->array = $data;
7479
}
7580

76-
public function unserialize($serialized)
81+
public function unserialize($serialized): void
7782
{
7883
$this->__unserialize((array) unserialize((string) $serialized));
7984
}

Util/InheritDataAwareIterator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class InheritDataAwareIterator extends \IteratorIterator implements \RecursiveIt
3030
*
3131
* @return static
3232
*/
33+
#[\ReturnTypeWillChange]
3334
public function getChildren()
3435
{
3536
return new static($this->current());
@@ -38,6 +39,7 @@ public function getChildren()
3839
/**
3940
* @return bool
4041
*/
42+
#[\ReturnTypeWillChange]
4143
public function hasChildren()
4244
{
4345
return (bool) $this->current()->getConfig()->getInheritData();

0 commit comments

Comments
 (0)