Skip to content

Commit 68fb163

Browse files
committed
[DependencyInjection] Forbid container cloning
1 parent 0e5eb6b commit 68fb163

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,4 +604,8 @@ public static function underscore($id)
604604
{
605605
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.')));
606606
}
607+
608+
private function __clone()
609+
{
610+
}
607611
}

src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,13 @@ public function testAlias()
662662
$this->assertTrue($c->has('alias'));
663663
$this->assertSame($c->get('alias'), $c->get('bar'));
664664
}
665+
666+
public function testThatCloningIsNotSupported()
667+
{
668+
$class = new \ReflectionClass('Symfony\Component\DependencyInjection\Container');
669+
$clone = $class->getMethod('__clone');
670+
$this->assertTrue($clone->isPrivate());
671+
}
665672
}
666673

667674
class ProjectServiceContainer extends Container

0 commit comments

Comments
 (0)
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