[DependencyInjection] Forbid container cloning
This commit is contained in:
parent
0e5eb6b6eb
commit
ba129041ba
@ -604,4 +604,8 @@ class Container implements IntrospectableContainerInterface
|
|||||||
{
|
{
|
||||||
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.')));
|
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function __clone()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,6 +662,16 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($c->has('alias'));
|
$this->assertTrue($c->has('alias'));
|
||||||
$this->assertSame($c->get('alias'), $c->get('bar'));
|
$this->assertSame($c->get('alias'), $c->get('bar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testThatCloningIsNotSupported()
|
||||||
|
{
|
||||||
|
$class = new \ReflectionClass('Symfony\Component\DependencyInjection\Container');
|
||||||
|
$clone = $class->getMethod('__clone');
|
||||||
|
if (PHP_VERSION_ID >= 540000) {
|
||||||
|
$this->assertFalse($class->isCloneable());
|
||||||
|
}
|
||||||
|
$this->assertTrue($clone->isPrivate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProjectServiceContainer extends Container
|
class ProjectServiceContainer extends Container
|
||||||
|
Reference in New Issue
Block a user