8000 [Form] fix return type declarations · symfony/symfony@8706f18 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8706f18

Browse files
[Form] fix return type declarations
1 parent a32a713 commit 8706f18

15 files changed

+145
-191
lines changed

src/Symfony/Component/Form/ButtonBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
2727
/**
2828
* @var bool
2929
*/
30-
private $disabled;
30+
private $disabled = false;
3131

3232
/**
3333
* @var ResolvedFormTypeInterface

src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ButtonType extends BaseType implements ButtonTypeInterface
2626
*/
2727
public function getParent()
2828
{
29+
return null;
2930
}
3031

3132
/**

src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public function configureOptions(OptionsResolver $resolver)
190190
*/
191191
public function getParent()
192192
{
193+
return null;
193194
}
194195

195196
/**

src/Symfony/Component/Form/FormError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function setOrigin(FormInterface $origin)
127127
/**
128128
* Returns the form that caused this error.
129129
*
130-
* @return FormInterface The form that caused this error
130+
* @return FormInterface|null The form that caused this error
131131
*/
132132
public function getOrigin()
133133
{

src/Symfony/Component/Form/FormInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
3131
* @throws Exception\LogicException when trying to set a parent for a form with
3232
* an empty name
3333
*/
34-
public function setParent(self $parent = null);
34+
public function setParent(FormInterface $parent = null);
3535

3636
/**
3737
* Returns the parent form.

src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
1515
use Symfony\Component\Form\Test\TypeTestCase;
16+
use Symfony\Component\Validator\ConstraintViolationList;
1617
use Symfony\Component\Validator\Mapping\ClassMetadata;
1718
use Symfony\Component\Validator\Validator\ValidatorInterface;
1819

@@ -37,9 +38,9 @@ protected function getValidatorExtension()
3738
}
3839

3940
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
40-
$metadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->setMethods(['addPropertyConstraint'])->getMock();
41+
$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->setMethods(['addPropertyConstraint'])->getMock();
4142
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
42-
$this->validator->expects($this->any())->method('validate')->will($this->returnValue([]));
43+
$this->validator->expects($this->any())->method('validate')->will($this->returnValue(new ConstraintViolationList()));
4344

4445
return new ValidatorExtension($this->validator);
4546
}

src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function getPostMaxSizeFixtures()
346346
[1024, '1K', false],
347347
[null, '1K', false],
348348
[1024, '', false],
349-
[1024, 0, false],
349+
[1024, '0', false],
350350
];
351351
}
352352

src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
use PHPUnit\Framework\MockObject\MockObject;
1515
use PHPUnit\Framework\TestCase;
16+
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1617
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
18+
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
1719

1820
/**
1921
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -38,7 +40,7 @@ protected function setUp()
3840

3941
public function testCreateFromChoicesEmpty()
4042
{
41-
$list = new \stdClass();
43+
$list = new ArrayChoiceList([]);
4244

4345
$this->decoratedFactory->expects($this->once())
4446
->method('createListFromChoices')
@@ -54,7 +56,7 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
5456
// The top-most traversable is converted to an array
5557
$choices1 = new \ArrayIterator(['A' => 'a']);
5658
$choices2 = ['A' => 'a'];
57-
$list = new \stdClass();
59+
$list = new ArrayChoiceList([]);
5860

5961
$this->decoratedFactory->expects($this->once())
6062
->method('createListFromChoices')
@@ -69,8 +71,8 @@ public function testCreateFromChoicesGroupedChoices()
6971
{
7072
$choices1 = ['key' => ['A' => 'a']];
7173
$choices2 = ['A' => 'a'];
72-
$list1 = new \stdClass();
73-
$list2 = new \stdClass();
74+
$list1 = new ArrayChoiceList([]);
75+
$list2 = new ArrayChoiceList([]);
7476

7577
$this->decoratedFactory->expects($this->at(0))
7678
->method('createListFromChoices')
@@ -92,7 +94,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
9294
{
9395
$choices1 = [$choice1];
9496
$choices2 = [$choice2];
95-
$list = new \stdClass();
97+
$list = new ArrayChoiceList([]);
9698

9799
$this->decoratedFactory->expects($this->once())
98100
->method('createListFromChoices')
@@ -110,8 +112,8 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
110112
{
111113
$choices1 = [$choice1];
112114
$choices2 = [$choice2];
113-
$list1 = new \stdClass();
114-
$list2 = new \stdClass();
115+
$list1 = new ArrayChoiceList([]);
116+
$list2 = new ArrayChoiceList([]);
115117

116118
$this->decoratedFactory->expects($this->at(0))
117119
->method('createListFromChoices')
@@ -129,7 +131,7 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
129131
public function testCreateFromChoicesSameValueClosure()
130132
{
131133
$choices = [1];
132-
$list = new \stdClass();
134+
$list = new ArrayChoiceList([]);
133135
$closure = function () {};
134136

135137
$this->decoratedFactory->expects($this->once())
@@ -144,8 +146,8 @@ public function testCreateFromChoicesSameValueClosure()
144146
public function testCreateFromChoicesDifferentValueClosure()
145147
{
146148
$choices = [1];
147-
$list1 = new \stdClass();
148-
$list2 = new \stdClass();
149+
$list1 = new ArrayChoiceList([]);
150+
$list2 = new ArrayChoiceList([]);
149151
$closure1 = function () {};
150152
$closure2 = function () {};
151153

@@ -165,7 +167,7 @@ public function testCreateFromChoicesDifferentValueClosure()
165167
public function testCreateFromLoaderSameLoader()
166168
{
167169
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
168-
$list = new \stdClass();
170+
$list = new ArrayChoiceList([]);
169171

170172
$this->decoratedFactory->expects($this->once())
171173
->method('createListFromLoader')
@@ -180,8 +182,8 @@ public function testCreateFromLoaderDifferentLoader()
180182
{
181183
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
182184
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
183-
$list1 = new \stdClass();
184-
$list2 = new \stdClass();
185+
$list1 = new ArrayChoiceList([]);
186+
$list2 = new ArrayChoiceList([]);
185187

186188
$this->decoratedFactory->expects($this->at(0))
187189
->method('createListFromLoader')
@@ -199,7 +201,7 @@ public function testCreateFromLoaderDifferentLoader()
199201
public function testCreateFromLoaderSameValueClosure()
200202
{
201203
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
202-
$list = new \stdClass();
204+
$list = new ArrayChoiceList([]);
203205
$closure = function () {};
204206

205207
$this->decoratedFactory->expects($this->once())
@@ -214,8 +216,8 @@ public function testCreateFromLoaderSameValueClosure()
214216
public function testCreateFromLoaderDifferentValueClosure()
215217
{
216218
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
217-
$list1 = new \stdClass();
218-
$list2 = new \stdClass();
219+
$list1 = new ArrayChoiceList([]);
220+
$list2 = new ArrayChoiceList([]);
219221
$closure1 = function () {};
220222
$closure2 = function () {};
221223

@@ -236,7 +238,7 @@ public function testCreateViewSamePreferredChoices()
236238
{
237239
$preferred = ['a'];
238240
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
239-
$view = new \stdClass();
241+
$view = new ChoiceListView();
240242

241243
$this->decoratedFactory->expects($this->once())
242244
->method('createView')
@@ -252,8 +254,8 @@ public function testCreateViewDifferentPreferredChoices()
252254
$preferred1 = ['a'];
253255
$preferred2 = ['b'];
254256
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
255-
$view1 = new \stdClass();
256-
$view2 = new \stdClass();
257+
$view1 = new ChoiceListView();
258+
$view2 = new ChoiceListView();
257259

258260
$this->decoratedFactory->expects($this->at(0))
259261
->method('createView')
@@ -272,7 +274,7 @@ public function testCreateViewSamePreferredChoicesClosure()
272274
{
273275
$preferred = function () {};
274276
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
275-
$view = new \stdClass();
277+
$view = new ChoiceListView();
276278

277279
$this->decoratedFactory->expects($this->once())
278280
->method('createView')
@@ -288,8 +290,8 @@ public function testCreateViewDifferentPreferredChoicesClosure()
288290
$preferred1 = function () {};
289291
$preferred2 = function () {};
290292
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
291-
$view1 = new \stdClass();
292-
$view2 = new \stdClass();
293+
$view1 = new ChoiceListView();
294+
$view2 = new ChoiceListView();
293295

< 48DA /code>
294296
$this->decoratedFactory->expects($this->at(0))
295297
->method('createView')
@@ -308,7 +310,7 @@ public function testCreateViewSameLabelClosure()
308310
{
309311
$labels = function () {};
310312
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
311-
$view = new \stdClass();
313+
$view = new ChoiceListView();
312314

313315
$this->decoratedFactory->expects($this->once())
314316
->method('createView')
@@ -324,8 +326,8 @@ public function testCreateViewDifferentLabelClosure()
324326
$labels1 = function () {};
325327
$labels2 = function () {};
326328
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
327-
$view1 = new \stdClass();
328-
$view2 = new \stdClass();
329+
$view1 = new ChoiceListView();
330+
$view2 = new ChoiceListView();
329331

330332
$this->decoratedFactory->expects($this->at(0))
331333
->method('createView')
@@ -344,7 +346,7 @@ public function testCreateViewSameIndexClosure()
344346
{
345347
$index = function () {};
346348
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
347-
$view = new \stdClass();
349+
$view = new ChoiceListView();
348350

349351
$this->decoratedFactory->expects($this->once())
350352
->method('createView')
@@ -360,8 +362,8 @@ public function testCreateViewDifferentIndexClosure()
360362
$index1 = function () {};
361363
$index2 = function () {};
362364
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
363-
$view1 = new \stdClass();
364-
$view2 = new \stdClass();
365+
$view1 = new ChoiceListView();
366+
$view2 = new ChoiceListView();
365367

366368
$this->decoratedFactory->expects($this->at(0))
367369
->method('createView')
@@ -380,7 +382,7 @@ public function testCreateViewSameGroupByClosure()
380382
{
381383
$groupBy = function () {};
382384
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
383-
$view = new \stdClass();
385+
$view = new ChoiceListView();
384386

385387
$this->decoratedFactory->expects($this->once())
386388
->method('createView')
@@ -396,8 +398,8 @@ public function testCreateViewDifferentGroupByClosure()
396398
$groupBy1 = function () {};
397399
$groupBy2 = function () {};
398400
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
399-
$view1 = new \stdClass();
400-
$view2 = new \stdClass();
401+
$view1 = new ChoiceListView();
402+
$view2 = new ChoiceListView();
401403

402404
$this->decoratedFactory->expects($this->at(0))
403405
->method('createView')
@@ -416,7 +418,7 @@ public function testCreateViewSameAttributes()
416418
{
417419
$attr = ['class' => 'foobar'];
418420
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
419-
$view = new \stdClass();
421+
$view = new ChoiceListView();
420422

421423
$this->decoratedFactory->expects($this->once())
422424
->method('createView')
@@ -432,8 +434,8 @@ public function testCreateViewDifferentAttributes()
432434
$attr1 = ['class' => 'foobar1'];
433435
$attr2 = ['class' => 'foobar2'];
434436
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
435-
$view1 = new \stdClass();
436-
$view2 = new \stdClass();
437+
$view1 = new ChoiceListView();
438+
$view2 = new ChoiceListView();
437439

438440
$this->decoratedFactory->expects($this->at(0))
439441
->method('createView')
@@ -452,7 +454,7 @@ public function testCreateViewSameAttributesClosure()
452454
{
453455
$attr = function () {};
454456
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
455-
$view = new \stdClass();
457+
$view = new ChoiceListView();
456458

457459
$this->decoratedFactory->expects($this->once())
458460
->method('createView')
@@ -468,8 +470,8 @@ public function testCreateViewDifferentAttributesClosure()
468470
$attr1 = function () {};
469471
$attr2 = function () {};
470472
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
471-
$view1 = new \stdClass();
472-
$view2 = new \stdClass();
473+
$view1 = new ChoiceListView();
474+
$view2 = new ChoiceListView();
473475

474476
$this->decoratedFactory->expects($this->at(0))
475477
->method('createView')

0 commit comments

Comments
 (0)
0