8000 Merge branch '2.3' into 2.7 · symfony/symfony@dc59e42 · GitHub
[go: up one dir, main page]

Skip to content

Commit dc59e42

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: [Form] [Validator] Fix locale inconsistencies in Norwegian translations fixed CS [DependencyInjection] fixed exceptions thrown by get method of ContainerBuilder [Form] remove useless code in ResizeFormListener
2 parents 10ba63c + 1229b6d commit dc59e42

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2020
use Symfony\Component\DependencyInjection\Exception\LogicException;
2121
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
22+
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
23+
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
2224
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
2325
use Symfony\Component\Config\Resource\FileResource;
2426
use Symfony\Component\Config\Resource\ResourceInterface;
@@ -419,9 +421,9 @@ public function has($id)
419421
*
420422
* @return object The associated service 10000
421423
*
422-
* @throws InvalidArgumentException when no definitions are available
423-
* @throws InactiveScopeException when the current scope is not active
424-
* @throws LogicException when a circular dependency is detected
424+
* @throws InvalidArgumentException when no definitions are available
425+
* @throws ServiceCircularReferenceException When a circular reference is detected
426+
* @throws ServiceNotFoundException When the service is not defined
425427
* @throws \Exception
426428
*
427429
* @see Reference
@@ -440,7 +442,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
440442

441443
try {
442444
$definition = $this->getDefinition($id);
443-
} catch (InvalidArgumentException $e) {
445+
} catch (ServiceNotFoundException $e) {
444446
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
445447
return;
446448
}
@@ -788,14 +790,14 @@ public function hasDefinition($id)
788790
*
789791
* @return Definition A Definition instance
790792
*
791-
* @throws InvalidArgumentException if the service definition does not exist
793+
* @throws ServiceNotFoundException if the service definition does not exist
792794
*/
793795
public function getDefinition($id)
794796
{
795797
$id = strtolower($id);
796798

797799
if (!array_key_exists($id, $this->definitions)) {
798-
throw new InvalidArgumentException(sprintf('The service definition "%s" does not exist.', $id));
800+
throw new ServiceNotFoundException($id);
799801
}
800802

801803
return $this->definitions[$id];
@@ -810,7 +812,7 @@ public function getDefinition($id)
810812
*
811813
* @return Definition A Definition instance
812814
*
813-
* @throws InvalidArgumentException if the service definition does not exist
815+
* @throws ServiceNotFoundException if the service definition does not exist
814816
*/
815817
public function findDefinition($id)
816818
{

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Symfony\Component\DependencyInjection\Definition;
2222
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2323
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
24+
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
25+
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
2426
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
2527
use Symfony\Component\DependencyInjection\Reference;
2628
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -51,9 +53,9 @@ public function testDefinitions()
5153

5254
try {
5355
$builder->getDefinition('baz');
54-
$this->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
55-
} catch (\InvalidArgumentException $e) {
56-
$this->assertEquals('The service definition "baz" does not exist.', $e->getMessage(), '->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
56+
$this->fail('->getDefinition() throws a ServiceNotFoundException if the service definition does not exist');
57+
} catch (ServiceNotFoundException $e) {
58+
$this->assertEquals('You have requested a non-existent service "baz".', $e->getMessage(), '->getDefinition() throws a ServiceNotFoundException if the service definition does not exist');
5759
}
5860
}
5961

@@ -80,9 +82,9 @@ public function testGet()
8082
$builder = new ContainerBuilder();
8183
try {
8284
$builder->get('foo');
83-
$this->fail('->get() throws an InvalidArgumentException if the service does not exist');
84-
} catch (\InvalidArgumentException $e) {
85-
$this->assertEquals('The service definition "foo" does not exist.', $e->getMessage(), '->get() throws an InvalidArgumentException if the service does not exist');
85+
$this->fail('->get() throws a ServiceNotFoundException if the service does not exist');
86+
} catch (ServiceNotFoundException $e) {
87+
$this->assertEquals('You have requested a non-existent service "foo".', $e->getMessage(), '->get() throws a ServiceNotFoundException if the service does not exist');
8688
}
8789

8890
$this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service does not exist and NULL_ON_INVALID_REFERENCE is passed as a second argument');

src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ public function preSubmit(FormEvent $event)
102102
$form = $event->getForm();
103103
$data = $event->getData();
104104

105-
if (null === $data || '' === $data) {
106-
$data = array();
107-
}
108-
109105
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
110106
$data = array();
111107
}

0 commit comments

Comments
 (0)
0