Skip to content

Commit d7c3e91

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: (48 commits) [Process] Use stream based storage to avoid memory issues Fix upgrade guides concerning erroneous removal of assets helper [Process] Remove a misleading comment Fix markdown typo ChooseBaseUrl should return an index [Form] ChoiceType: Fix a notice when 'choices' normalizer is replaced Improve the phpdoc of SplFileInfo methods [Process] Use stream based storage to avoid memory issues [FrameworkBundle] Don't log twice with the error handler synchronize 2.8 and 3.0 upgrade files Remove useless is_object condition [Process] Fix typo, no arguments needed anymore [Serializer] Introduce constants for context keys Fixed the documentation of VoterInterface::supportsAttribute Fixed Bootstrap form theme form "reset" buttons Fixed the form profiler when using long form types [PropertyInfo] PhpDocExtractor: Fix a notice when the property doesn't exist Remove useless duplicated tests [FrameworkBundle] Optimize framework extension tests synchronize 2.7 and 3.0 upgrade files ...
2 parents 94bda38 + ac08db9 commit d7c3e91

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

DependencyInjection/Compiler/AddConsoleCommandPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function process(ContainerBuilder $container)
3737
}
3838

3939
$class = $container->getParameterBag()->resolveValue($definition->getClass());
40-
$r = new \ReflectionClass($class);
41-
if (!$r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command')) {
40+
if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) {
4241
throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id));
4342
}
4443
$container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $class)), $id);

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
abstract class FrameworkExtensionTest extends TestCase
2424
{
25+
private static $containerCache = array();
26+
2527
abstract protected function loadFromFile(ContainerBuilder $container, $file);
2628

2729
public function testFormCsrfProtection()
@@ -482,6 +484,10 @@ protected function createContainer(array $data = array())
482484

483485
protected function createContainerFromFile($file, $data = array())
484486
{
487+
$cacheKey = md5($file.serialize($data));
488+
if (isset(self::$containerCache[$cacheKey])) {
489+
return self::$containerCache[$cacheKey];
490+
}
485491
$container = $this->createContainer($data);
486492
$container->registerExtension(new FrameworkExtension());
487493
$this->loadFromFile($container, $file);
@@ -490,7 +496,7 @@ protected function createContainerFromFile($file, $data = array())
490496
$container->getCompilerPassConfig()->setRemovingPasses(array());
491497
$container->compile();
492498

493-
return $container;
499+
return self::$containerCache[$cacheKey] = $container;
494500
}
495501

496502
protected function createContainerFromClosure($closure, $data = array())

Translation/PhpExtractor.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function extract($resource, MessageCatalogue $catalog)
6060
$files = $this->extractFiles($resource);
6161
foreach ($files as $file) {
6262
$this->parseTokens(token_get_all(file_get_contents($file)), $catalog);
63+
64+
if (PHP_VERSION_ID >= 70000) {
65+
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
66+
gc_mem_caches();
67+
}
6368
}
6469
}
6570

@@ -80,7 +85,7 @@ public function setPrefix($prefix)
8085
*/
8186
protected function normalizeToken($token)
8287
{
83-
if (is_array($token)) {
88+
if (isset($token[1]) && 'b"' !== $token) {
8489
return $token[1];
8590
}
8691

@@ -94,7 +99,7 @@ private function seekToNextRelevantToken(\Iterator $tokenIterator)
9499
{
95100
for (; $tokenIterator->valid(); $tokenIterator->next()) {
96101
$t = $tokenIterator->current();
97-
if (!is_array($t) || ($t[0] !== T_WHITESPACE)) {
102+
if (T_WHITESPACE !== $t[0]) {
98103
break;
99104
}
100105
}
@@ -111,7 +116,7 @@ private function getMessage(\Iterator $tokenIterator)
111116

112117
for (; $tokenIterator->valid(); $tokenIterator->next()) {
113118
$t = $tokenIterator->current();
114-
if (!is_array($t)) {
119+
if (!isset($t[1])) {
115120
break;
116121
}
117122

0 commit comments

Comments
 (0)