Skip to content

Commit

Permalink
[Form] fix return type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Aug 26, 2019
1 parent a32a713 commit 8706f18
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 191 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/ButtonBuilder.php
Expand Up @@ -27,7 +27,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* @var bool
*/
private $disabled;
private $disabled = false;

/**
* @var ResolvedFormTypeInterface
Expand Down
Expand Up @@ -26,6 +26,7 @@ class ButtonType extends BaseType implements ButtonTypeInterface
*/
public function getParent()
{
return null;
}

/**
Expand Down
Expand Up @@ -190,6 +190,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FormError.php
Expand Up @@ -127,7 +127,7 @@ public function setOrigin(FormInterface $origin)
/**
* Returns the form that caused this error.
*
* @return FormInterface The form that caused this error
* @return FormInterface|null The form that caused this error
*/
public function getOrigin()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FormInterface.php
Expand Up @@ -31,7 +31,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
* @throws Exception\LogicException when trying to set a parent for a form with
* an empty name
*/
public function setParent(self $parent = null);
public function setParent(FormInterface $parent = null);

/**
* Returns the parent form.
Expand Down
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Validator\ValidatorInterface;

Expand All @@ -37,9 +38,9 @@ protected function getValidatorExtension()
}

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

return new ValidatorExtension($this->validator);
}
Expand Down
Expand Up @@ -346,7 +346,7 @@ public function getPostMaxSizeFixtures()
[1024, '1K', false],
[null, '1K', false],
[1024, '', false],
[1024, 0, false],
[1024, '0', false],
];
}

Expand Down
Expand Up @@ -13,7 +13,9 @@

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;

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

public function testCreateFromChoicesEmpty()
{
$list = new \stdClass();
$list = new ArrayChoiceList([]);

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

$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
Expand All @@ -69,8 +71,8 @@ public function testCreateFromChoicesGroupedChoices()
{
$choices1 = ['key' => ['A' => 'a']];
$choices2 = ['A' => 'a'];
$list1 = new \stdClass();
$list2 = new \stdClass();
$list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]);

$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
Expand All @@ -92,7 +94,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
{
$choices1 = [$choice1];
$choices2 = [$choice2];
$list = new \stdClass();
$list = new ArrayChoiceList([]);

$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
Expand All @@ -110,8 +112,8 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
{
$choices1 = [$choice1];
$choices2 = [$choice2];
$list1 = new \stdClass();
$list2 = new \stdClass();
$list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]);

$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
Expand All @@ -129,7 +131,7 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
public function testCreateFromChoicesSameValueClosure()
{
$choices = [1];
$list = new \stdClass();
$list = new ArrayChoiceList([]);
$closure = function () {};

$this->decoratedFactory->expects($this->once())
Expand All @@ -144,8 +146,8 @@ public function testCreateFromChoicesSameValueClosure()
public function testCreateFromChoicesDifferentValueClosure()
{
$choices = [1];
$list1 = new \stdClass();
$list2 = new \stdClass();
$list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]);
$closure1 = function () {};
$closure2 = function () {};

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

$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
Expand All @@ -180,8 +182,8 @@ public function testCreateFromLoaderDifferentLoader()
{
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list1 = new \stdClass();
$list2 = new \stdClass();
$list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]);

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

$this->decoratedFactory->expects($this->once())
Expand All @@ -214,8 +216,8 @@ public function testCreateFromLoaderSameValueClosure()
public function testCreateFromLoaderDifferentValueClosure()
{
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list1 = new \stdClass();
$list2 = new \stdClass();
$list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]);
$closure1 = function () {};
$closure2 = function () {};

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

$this->decoratedFactory->expects($this->once())
->method('createView')
Expand All @@ -252,8 +254,8 @@ public function testCreateViewDifferentPreferredChoices()
$preferred1 = ['a'];
$preferred2 = ['b'];
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
$view1 = new ChoiceListView();
$view2 = new ChoiceListView();

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

$this->decoratedFactory->expects($this->once())
->method('createView')
Expand All @@ -288,8 +290,8 @@ public function testCreateViewDifferentPreferredChoicesClosure()
$preferred1 = function () {};
$preferred2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
$view1 = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
Expand All @@ -308,7 +310,7 @@ public function testCreateViewSameLabelClosure()
{
$labels = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$view = new ChoiceListView();

$this->decoratedFactory->expects($this->once())
->method('createView')
Expand All @@ -324,8 +326,8 @@ public function testCreateViewDifferentLabelClosure()
$labels1 = function () {};
$labels2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
$view1 = new ChoiceListView();
$view2 = new ChoiceListView();

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

$this->decoratedFactory->expects($this->once())
->method('createView')
Expand All @@ -360,8 +362,8 @@ public function testCreateViewDifferentIndexClosure()
$index1 = function () {};
$index2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
$view1 = new ChoiceListView();
$view2 = new ChoiceListView();

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

$this->decoratedFactory->expects($this->once())
->method('createView')
Expand All @@ -396,8 +398,8 @@ public function testCreateViewDifferentGroupByClosure()
$groupBy1 = function () {};
$groupBy2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
$view1 = new ChoiceListView();
$view2 = new ChoiceListView();

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

$this->decoratedFactory->expects($this->once())
->method('createView')
Expand All @@ -432,8 +434,8 @@ public function testCreateViewDifferentAttributes()
$attr1 = ['class' => 'foobar1'];
$attr2 = ['class' => 'foobar2'];
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
$view1 = new ChoiceListView();
$view2 = new ChoiceListView();

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

$this->decoratedFactory->expects($this->once())
->method('createView')
Expand All @@ -468,8 +470,8 @@ public function testCreateViewDifferentAttributesClosure()
$attr1 = function () {};
$attr2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
$view1 = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
Expand Down

0 comments on commit 8706f18

Please sign in to comment.