diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php index fa9128e..53a14f5 100644 --- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php +++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php @@ -81,6 +81,9 @@ public function testBuildSimpleMethod() { $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public function method() { return $this->lazyLoadItself()->method(); @@ -102,6 +105,9 @@ public function testBuildMethodWithParameter() { $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public function methodWithParameter($parameter) { return $this->lazyLoadItself()->methodWithParameter($parameter); @@ -124,6 +130,9 @@ public function testBuildComplexMethod() { // @todo Solve the silly linebreak for array() $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public function complexMethod($parameter, callable $function, \Drupal\Tests\Component\ProxyBuilder\TestServiceNoMethod $test_service = NULL, array &$elements = array ( )) { @@ -147,6 +156,9 @@ public function testBuildReturnReference() { // @todo Solve the silly linebreak for array() $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public function &returnReference() { return $this->lazyLoadItself()->returnReference(); @@ -169,6 +181,9 @@ public function testBuildWithInterface() { $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public function testMethod($parameter) { return $this->lazyLoadItself()->testMethod($parameter); @@ -205,6 +220,9 @@ public function testBuildWithProtectedAndPrivateMethod() { $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public function testMethod($parameter) { return $this->lazyLoadItself()->testMethod($parameter); @@ -228,6 +246,9 @@ public function testBuildWithPublicStaticMethod() { // Ensure that the static method is not wrapped. $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public static function testMethod($parameter) { \Drupal\Tests\Component\ProxyBuilder\TestServiceWithPublicStaticMethod::testMethod($parameter); @@ -265,11 +286,15 @@ class {{ proxy_class }}{{ interface_string }} { /** + * The id of the original proxied service. + * * @var string */ - protected $serviceId; + protected $drupalProxyOriginalServiceId; /** + * The real proxied service, after it was lazy loaded. + * * @var \{{ class }} */ protected $service; @@ -281,16 +306,30 @@ class {{ proxy_class }}{{ interface_string }} */ protected $container; - public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $serviceId) + /** + * Constructs a ProxyClass Drupal proxy object. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container. + * @param string $drupal_proxy_original_service_id + * The service ID of the original service. + */ + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id) { $this->container = $container; - $this->serviceId = $serviceId; + $this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id; } + /** + * Lazy loads the real service from the container. + * + * @return object + * Returns the constructed real service. + */ protected function lazyLoadItself() { if (!isset($this->service)) { - $this->service = $this->container->get($this->serviceId); + $this->service = $this->container->get($this->drupalProxyOriginalServiceId); } return $this->service; diff --git a/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php index b8458f9..c18b00c 100644 --- a/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php @@ -44,6 +44,9 @@ public function testBuildComplexMethod() { // @todo Solve the silly linebreak for array() $method_body = <<<'EOS' +/** + * {@inheritdoc} + */ public function complexMethod($parameter, callable $function, \Drupal\Tests\Core\ProxyBuilder\TestServiceNoMethod $test_service = NULL, array &$elements = array ( )) { @@ -83,11 +86,15 @@ class {{ proxy_class }}{{ interface_string }} use \Drupal\Core\DependencyInjection\DependencySerializationTrait; /** + * The id of the original proxied service. + * * @var string */ - protected $serviceId; + protected $drupalProxyOriginalServiceId; /** + * The real proxied service, after it was lazy loaded. + * * @var \{{ class }} */ protected $service; @@ -99,16 +106,30 @@ class {{ proxy_class }}{{ interface_string }} */ protected $container; - public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $serviceId) + /** + * Constructs a ProxyClass Drupal proxy object. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container. + * @param string $drupal_proxy_original_service_id + * The service ID of the original service. + */ + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id) { $this->container = $container; - $this->serviceId = $serviceId; + $this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id; } + /** + * Lazy loads the real service from the container. + * + * @return object + * Returns the constructed real service. + */ protected function lazyLoadItself() { if (!isset($this->service)) { - $this->service = $this->container->get($this->serviceId); + $this->service = $this->container->get($this->drupalProxyOriginalServiceId); } return $this->service;