Skip to content

Commit dee84ee

Browse files
Merge branch '2.7' into 2.8
* 2.7: (36 commits) [DoctrineBridge] Bypass the db when no valid identifier is provided in ORMQueryBuilderLoader [Serializer] Fixed typo in comment [Form] Fixed: Filter non-integers when selecting entities by int ID Fix merge Fix merge Add test for HHVM FatalErrors [2.6][Debug] Fix fatal-errors handling on HHVM [Debug] Fix log level of stacked errors [VarDumper] Fix uninitialized id in HtmlDumper Fixed fluent interface [Console] Fix tests on Windows [2.7] Fix unsilenced deprecation notices [2.3][Debug] Fix fatal-errors handling on HHVM [Debug] fix debug class loader case test on windows Standardize the name of the exception variables [Debug+VarDumper] Fix handling of PHP7 exception/error model Do not trigger deprecation error in ResolveParameterPlaceHoldersPass [2.3] Static Code Analysis for Components Added a small Upgrade note regarding security.context added missing deprecation in CHANGELOG ... Conflicts: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig src/Symfony/Component/HttpKernel/Kernel.php
2 parents 3dd2230 + 93b8b76 commit dee84ee

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed

AbstractType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public function finishView(FormView $view, FormInterface $form, array $options)
4545
*/
4646
public function setDefaultOptions(OptionsResolverInterface $resolver)
4747
{
48+
if (!$resolver instanceof OptionsResolver) {
49+
throw new \InvalidArgumentException(sprintf('Custom resolver "%s" must extend "Symfony\Component\OptionsResolver\OptionsResolver".', get_class($resolver)));
50+
}
51+
4852
$this->configureOptions($resolver);
4953
}
5054

AbstractTypeExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public function finishView(FormView $view, FormInterface $form, array $options)
4545
*/
4646
public function setDefaultOptions(OptionsResolverInterface $resolver)
4747
{
48+
if (!$resolver instanceof OptionsResolver) {
49+
throw new \InvalidArgumentException(sprintf('Custom resolver "%s" must extend "Symfony\Component\OptionsResolver\OptionsResolver".', get_class($resolver)));
50+
}
51+
4852
$this->configureOptions($resolver);
4953
}
5054

Tests/AbstractExtensionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ public function testGetType()
2828
$loader = new ConcreteExtension();
2929
$this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('foo'));
3030
}
31+
32+
/**
33+
* @expectedException \InvalidArgumentException
34+
* @expectedExceptionMessage Custom resolver "Symfony\Component\Form\Tests\Fixtures\CustomOptionsResolver" must extend "Symfony\Component\OptionsResolver\OptionsResolver".
35+
*/
36+
public function testCustomOptionsResolver()
37+
{
38+
$extension = new Fixtures\FooTypeBarExtension();
39+
$resolver = new Fixtures\CustomOptionsResolver();
40+
$extension->setDefaultOptions($resolver);
41+
}
3142
}
3243

3344
class ConcreteExtension extends AbstractExtension
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Tests\Fixtures;
13+
14+
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
15+
16+
class CustomOptionsResolver implements OptionsResolverInterface
17+
{
18+
public function setDefaults(array $defaultValues)
19+
{
20+
}
21+
22+
public function replaceDefaults(array $defaultValues)
23+
{
24+
}
25+
26+
public function setOptional(array $optionNames)
27+
{
28+
}
29+
30+
public function setRequired($optionNames)
31+
{
32+
}
33+
34+
public function setAllowedValues($allowedValues)
35+
{
36+
}
37+
38+
public function addAllowedValues($allowedValues)
39+
{
40+
}
41+
42+
public function setAllowedTypes($allowedTypes)
43+
{
44+
}
45+
46+
public function addAllowedTypes($allowedTypes)
47+
{
48+
}
49+
50+
public function setNormalizers(array $normalizers)
51+
{
52+
}
53+
54+
public function isKnown($option)
55+
{
56+
}
57+
58+
public function isRequired($option)
59+
{
60+
}
61+
62+
public function resolve(array $options = array())
63+
{
64+
}
65+
}

Tests/SimpleFormTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,17 @@ public function testInitializeFailsIfParent()
10571057
$child->initialize();
10581058
}
10591059

1060+
/**
1061+
* @expectedException \InvalidArgumentException
1062+
* @expectedExceptionMessage Custom resolver "Symfony\Component\Form\Tests\Fixtures\CustomOptionsResolver" must extend "Symfony\Component\OptionsResolver\OptionsResolver".
1063+
*/
1064+
public function testCustomOptionsResolver()
1065+
{
1066+
$fooType = new Fixtures\FooType();
1067+
$resolver = new Fixtures\CustomOptionsResolver();
1068+
$fooType->setDefaultOptions($resolver);
1069+
}
1070+
10601071
protected function createForm()
10611072
{
10621073
return $this->getBuilder()->getForm();

0 commit comments

Comments
 (0)