Skip to content

[DependencyInjection] The class of a service definition might be passed as parameter #32279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
The class of a service definition might be passed as parameter.
  • Loading branch information
derrabus committed Jun 29, 2019
commit af42a0ff8b45ed4edb3f4539fd37ee382721be69
8 changes: 4 additions & 4 deletions src/Symfony/Component/DependencyInjection/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class Definition
private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.';

/**
* @param string|null $class The service class
* @param array $arguments An array of arguments to pass to the service constructor
* @param string|Parameter|null $class The service class
* @param array $arguments An array of arguments to pass to the service constructor
*/
public function __construct($class = null, array $arguments = [])
{
Expand Down Expand Up @@ -157,7 +157,7 @@ public function getDecoratedService()
/**
* Sets the service class.
*
* @param string $class The service class
* @param string|Parameter|null $class The service class
*
* @return $this
*/
Expand All @@ -173,7 +173,7 @@ public function setClass($class)
/**
* Gets the service class.
*
* @return string|null The service class
* @return string|Parameter|null The service class
*/
public function getClass()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;

class DefinitionTest extends TestCase
{
Expand Down Expand Up @@ -45,6 +46,14 @@ public function testSetGetClass()
$this->assertEquals('foo', $def->getClass(), '->getClass() returns the class name');
}

public function testSetGetClassWithParameter()
{
$def = new Definition('stdClass');
$parameter = new Parameter('foo');
$this->assertSame($def, $def->setClass($parameter), '->setClass() implements a fluent interface');
$this->assertSame($parameter, $def->getClass(), '->getClass() returns the parameterized class name');
}

public function testSetGetDecoratedService()
{
$def = new Definition('stdClass');
Expand Down
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