Skip to content

Commit 8b1f412

Browse files
committed
Merge branch '3.2' into 3.3
* 3.2: Don't access private services from container aware commands (deprecated) Improve CircularReferenceException message
2 parents 966662d + 04baf86 commit 8b1f412

File tree

4 files changed

+48
-30
lines changed

4 files changed

+48
-30
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

1414
use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper;
15+
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
1516
use Symfony\Component\Console\Input\InputArgument;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Input\InputOption;
@@ -112,7 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
112113
private function convertController(Route $route)
113114
{
114115
if ($route->hasDefault('_controller')) {
115-
$nameParser = $this->getContainer()->get('controller_name_converter');
116+
$nameParser = new ControllerNameParser($this->getApplication()->getKernel());
116117
try {
117118
$route->setDefault('_controller', $nameParser->build($route->getDefault('_controller')));
118119
} catch (\InvalidArgumentException $e) {

src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Console\Application;
15+
use Symfony\Bundle\FrameworkBundle\Console\Application;
1616
use Symfony\Component\Console\Tester\CommandTester;
1717
use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand;
18+
use Symfony\Component\HttpKernel\KernelInterface;
1819
use Symfony\Component\Routing\Route;
1920
use Symfony\Component\Routing\RouteCollection;
2021

@@ -51,16 +52,15 @@ public function testDebugInvalidRoute()
5152
*/
5253
private function createCommandTester()
5354
{
54-
$application = new Application();
55+
$application = new Application($this->getKernel());
5556

5657
$command = new RouterDebugCommand();
57-
$command->setContainer($this->getContainer());
5858
$application->add($command);
5959

6060
return new CommandTester($application->find('debug:router'));
6161
}
6262

63-
private function getContainer()
63+
private function getKernel()
6464
{
6565
$routeCollection = new RouteCollection();
6666
$routeCollection->add('foo', new Route('foo'));
@@ -82,14 +82,25 @@ private function getContainer()
8282
->with('router')
8383
->will($this->returnValue(true))
8484
;
85-
8685
$container
86+
->expects($this->any())
8787
->method('get')
88-
->will($this->returnValueMap(array(
89-
array('router', 1, $router),
90-
array('controller_name_converter', 1, $loader),
91-
)));
88+
->with('router')
89+
->willReturn($router)
90+
;
91+
92+
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
93+
$kernel
94+
->expects($this->any())
95+
->method('getContainer')
96+
->willReturn($container)
97+
;
98+
$kernel
99+
->expects($this->once())
100+
->method('getBundles')
101+
->willReturn(array())
102+
;
92103

93-
return $container;
104+
return $kernel;
94105
}
95106
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Console\Application;
15+
use Symfony\Bundle\FrameworkBundle\Console\Application;
1616
use Symfony\Component\Console\Tester\CommandTester;
1717
use Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand;
1818
use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand;
19+
use Symfony\Component\HttpKernel\KernelInterface;
1920
use Symfony\Component\Routing\Route;
2021
use Symfony\Component\Routing\RouteCollection;
2122
use Symfony\Component\Routing\RequestContext;
@@ -45,20 +46,14 @@ public function testWithNotMatchPath()
4546
*/
4647
private function createCommandTester()
4748
{
48-
$application = new Application();
49-
50-
$command = new RouterMatchCommand();
51-
$command->setContainer($this->getContainer());
52-
$application->add($command);
53-
54-
$command = new RouterDebugCommand();
55-
$command->setContainer($this->getContainer());
56-
$application->add($command);
49+
$application = new Application($this->getKernel());
50+
$application->add(new RouterMatchCommand());
51+
$application->add(new RouterDebugCommand());
5752

5853
return new CommandTester($application->find('router:match'));
5954
}
6055

61-
private function getContainer()
56+
private function getKernel()
6257
{
6358
$routeCollection = new RouteCollection();
6459
$routeCollection->add('foo', new Route('foo'));
@@ -81,16 +76,27 @@ private function getContainer()
8176

8277
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
8378
$container
84-
->expects($this->once())
79+
->expects($this->atLeastOnce())
8580
->method('has')
8681
->with('router')
8782
->will($this->returnValue(true));
88-
$container->method('get')
89-
->will($this->returnValueMap(array(
90-
array('router', 1, $router),
91-
array('controller_name_converter', 1, $loader),
92-
)));
83+
$container
84+
->expects($this->any())
85+
->method('get')
86+
->willReturn($router);
87+
88+
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
89+
$kernel
90+
->expects($this->any())
91+
->method('getContainer')
92+
->willReturn($container)
93+
;
94+
$kernel
95+
->expects($this->once())
96+
->method('getBundles')
97+
->willReturn(array())
98+
;
9399

94-
return $container;
100+
return $kernel;
95101
}
96102
}

src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ protected function handleCircularReference($object)
192192
return call_user_func($this->circularReferenceHandler, $object);
193193
}
194194

195-
throw new CircularReferenceException(sprintf('A circular reference has been detected (configured limit: %d).', $this->circularReferenceLimit));
195+
throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', get_class($object), $this->circularReferenceLimit));
196196
}
197197

198198
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy