createService() private method

Creates a service for a service definition.
private createService ( Definition $definition, string $id, boolean $tryProxy = true ) : object
$definition Definition A service definition instance
$id string The service identifier
$tryProxy boolean Whether to try proxying the service with a lazy proxy
return object The service described by the service definition
 public function testCreateDeprecatedService()
 {
     ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () {
         $definition = new Definition('stdClass');
         $definition->setDeprecated(true);
         $builder = new ContainerBuilder();
         $builder->createService($definition, 'deprecated_foo');
     });
 }
 public function testCreateDeprecatedService()
 {
     $definition = new Definition('stdClass');
     $definition->setDeprecated(true);
     $that = $this;
     $wasTriggered = false;
     set_error_handler(function ($errno, $errstr) use($that, &$wasTriggered) {
         $that->assertSame(E_USER_DEPRECATED, $errno);
         $that->assertSame('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $errstr);
         $wasTriggered = true;
     });
     $builder = new ContainerBuilder();
     $builder->createService($definition, 'deprecated_foo');
     restore_error_handler();
     $this->assertTrue($wasTriggered);
 }
 public function testCreateDeprecatedService()
 {
     $deprecations = array();
     set_error_handler(function ($type, $msg) use(&$deprecations) {
         if (E_USER_DEPRECATED !== $type) {
             restore_error_handler();
             return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
         }
         $deprecations[] = $msg;
     });
     $definition = new Definition('stdClass');
     $definition->setDeprecated(true);
     $builder = new ContainerBuilder();
     $builder->createService($definition, 'deprecated_foo');
     restore_error_handler();
     $this->assertCount(1, $deprecations);
     $this->assertContains('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $deprecations[0]);
 }