Skip to content

Commit d32282c

Browse files
Merge branch '3.4' into 4.0
* 3.4: (22 commits) [appveyor] use PHP 7.1 to run composer [HttpKernel] Don't clean legacy containers that are still loaded [VarDumper] Fix HtmlDumper classes match Make the simple auth provider the same as in Symfony 2.7. [PhpUnitBridge] silence wget fix merge [Security] guardAuthenticationProvider::authenticate cannot return null according to interface specification [PhpUnitBridge] Fix #26994 [VarDumper] Remove decoration from actual output in tests [PropertyInfo] Minor cleanup and perf improvement [Bridge/Doctrine] fix count() notice on PHP 7.2 [Security] Skip user checks if not implementing UserInterface [DI] Add check of internal type to ContainerBuilder::getReflectionClass [HttpFoundation] Add HTTP_EARLY_HINTS const [DoctrineBridge] Improve exception message at `IdReader::getIdValue()` Add type hints fixed CS Use new PHP7.2 functions in hasColorSupport [VarDumper] Fix dumping of SplObjectStorage [HttpFoundation] Add functional tests for Response::sendHeaders() ...
2 parents 59768cb + c33774c commit d32282c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

ContainerBuilder.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
123123
private $removedIds = array();
124124
private $alreadyLoading = array();
125125

126+
private static $internalTypes = array(
127+
'int' => true,
128+
'float' => true,
129+
'string' => true,
130+
'bool' => true,
131+
'resource' => true,
132+
'object' => true,
133+
'array' => true,
134+
'null' => true,
135+
'callable' => true,
136+
'iterable' => true,
137+
'mixed' => true,
138+
);
139+
126140
public function __construct(ParameterBagInterface $parameterBag = null)
127141
{
128142
parent::__construct($parameterBag);
@@ -321,6 +335,11 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
321335
if (!$class = $this->getParameterBag()->resolveValue($class)) {
322336
return null;
323337
}
338+
339+
if (isset(self::$internalTypes[$class])) {
340+
return null;
341+
}
342+
324343
$resource = null;
325344

326345
try {

Tests/ContainerBuilderTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,23 @@ public function testGetReflectionClass()
880880
$this->assertSame('BarMissingClass', (string) end($resources));
881881
}
882882

883+
public function testGetReflectionClassOnInternalTypes()
884+
{
885+
$container = new ContainerBuilder();
886+
887+
$this->assertNull($container->getReflectionClass('int'));
888+
$this->assertNull($container->getReflectionClass('float'));
889+
$this->assertNull($container->getReflectionClass('string'));
890+
$this->assertNull($container->getReflectionClass('bool'));
891+
$this->assertNull($container->getReflectionClass('resource'));
892+
$this->assertNull($container->getReflectionClass('object'));
893+
$this->assertNull($container->getReflectionClass('array'));
894+
$this->assertNull($container->getReflectionClass('null'));
895+
$this->assertNull($container->getReflectionClass('callable'));
896+
$this->assertNull($container->getReflectionClass('iterable'));
897+
$this->assertNull($container->getReflectionClass('mixed'));
898+
}
899+
883900
public function testCompilesClassDefinitionsOfLazyServices()
884901
{
885902
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)