Skip to content

Commit 8baf6af

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Finder] Partially revert #17134 to fix a regression [HttpKernel] Fix mem usage when stripping the prod container exception when registering bags for started sessions Conflicts: src/Symfony/Component/Validator/composer.json
2 parents d67cd45 + cac43a6 commit 8baf6af

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

Dumper/PhpDumper.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Symfony\Component\DependencyInjection\ExpressionLanguage;
2727
use Symfony\Component\ExpressionLanguage\Expression;
2828
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
29+
use Symfony\Component\HttpKernel\Kernel;
2930

3031
/**
3132
* PhpDumper dumps a service container as a PHP class.
@@ -57,6 +58,7 @@ class PhpDumper extends Dumper
5758
private $expressionLanguage;
5859
private $targetDirRegex;
5960
private $targetDirMaxMatches;
61+
private $docStar;
6062

6163
/**
6264
* @var ExpressionFunctionProviderInterface[]
@@ -108,7 +110,9 @@ public function dump(array $options = array())
108110
'class' => 'ProjectServiceContainer',
109111
'base_class' => 'Container',
110112
'namespace' => '',
113+
'debug' => true,
111114
), $options);
115+
$this->docStar = $options['debug'] ? '*' : '';
112116

113117
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
114118
// Build a regexp where the first root dirs are mandatory,
@@ -233,9 +237,15 @@ private function addProxyClasses()
233237
array($this->getProxyDumper(), 'isProxyCandidate')
234238
);
235239
$code = '';
240+
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
236241

237242
foreach ($definitions as $definition) {
238-
$code .= "\n".$this->getProxyDumper()->getProxyCode($definition);
243+
$proxyCode = "\n".$this->getProxyDumper()->getProxyCode($definition);
244+
if ($strip) {
245+
$proxyCode = "<?php\n".$proxyCode;
246+
$proxyCode = substr(Kernel::stripComments($proxyCode), 5);
247+
}
248+
$code .= $proxyCode;
239249
}
240250

241251
return $code;
@@ -637,7 +647,7 @@ private function addService($id, $definition)
637647
$visibility = $isProxyCandidate ? 'public' : 'protected';
638648
$code = <<<EOF
639649
640-
/**
650+
/*{$this->docStar}
641651
* Gets the '$id' service.$doc
642652
*$lazyInitializationDoc
643653
* $return
@@ -757,7 +767,7 @@ private function addServiceSynchronizer($id, Definition $definition)
757767

758768
return <<<EOF
759769
760-
/**
770+
/*{$this->docStar}
761771
* Updates the '$id' service.
762772
*/
763773
protected function synchronize{$this->camelize($id)}Service()
@@ -849,7 +859,7 @@ private function startClass($class, $baseClass, $namespace)
849859
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
850860
$bagClass
851861
852-
/**
862+
/*{$this->docStar}
853863
* $class.
854864
*
855865
* This class has been auto-generated
@@ -875,7 +885,7 @@ private function addConstructor()
875885

876886
$code = <<<EOF
877887
878-
/**
888+
/*{$this->docStar}
879889
* Constructor.
880890
*/
881891
public function __construct()
@@ -912,7 +922,7 @@ private function addFrozenConstructor()
912922

913923
$code = <<<EOF
914924
915-
/**
925+
/*{$this->docStar}
916926
* Constructor.
917927
*/
918928
public function __construct()
@@ -959,7 +969,7 @@ private function addFrozenCompile()
959969
{
960970
return <<<EOF
961971
962-
/**
972+
/*{$this->docStar}
963973
* {@inheritdoc}
964974
*/
965975
public function compile()
@@ -1080,11 +1090,14 @@ public function getParameterBag()
10801090
}
10811091

10821092
EOF;
1093+
if ('' === $this->docStar) {
1094+
$code = str_replace('/**', '/*', $code);
1095+
}
10831096
}
10841097

10851098
$code .= <<<EOF
10861099
1087-
/**
1100+
/*{$this->docStar}
10881101
* Gets the default parameters.
10891102
*
10901103
* @return array An array of the default parameters

0 commit comments

Comments
 (0)