File tree 2 files changed +15
-0
lines changed
src/Symfony/Component/DependencyInjection
tests/Symfony/Tests/Component/DependencyInjection
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -725,6 +725,10 @@ public function findDefinition($id)
725
725
*/
726
726
private function createService (Definition $ definition , $ id )
727
727
{
728
+ if ($ definition ->isSynthetic ()) {
729
+ throw new \RuntimeException (sprintf ('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service. ' , $ id ));
730
+ }
731
+
728
732
if (null !== $ definition ->getFile ()) {
729
733
require_once $ this ->getParameterBag ()->resolveValue ($ definition ->getFile ());
730
734
}
Original file line number Diff line number Diff line change @@ -315,6 +315,17 @@ public function testCreateServiceConfigurator()
315
315
}
316
316
}
317
317
318
+ /**
319
+ * @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
320
+ * @expectedException \RuntimeException
321
+ */
322
+ public function testCreateSyntheticService ()
323
+ {
324
+ $ builder = new ContainerBuilder ();
325
+ $ builder ->register ('foo ' , 'FooClass ' )->setSynthetic (true );
326
+ $ builder ->get ('foo ' );
327
+ }
328
+
318
329
/**
319
330
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices
320
331
*/
You can’t perform that action at this time.
0 commit comments