Skip to content

Commit 3471f64

Browse files
Merge branch '2.8' into 3.0
* 2.8: [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/DependencyInjection/Dumper/PhpDumper.php src/Symfony/Component/Validator/composer.json
2 parents 15b42f3 + 8baf6af commit 3471f64

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

Dumper/PhpDumper.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;
2626
use Symfony\Component\DependencyInjection\ExpressionLanguage;
2727
use Symfony\Component\ExpressionLanguage\Expression;
28+
use Symfony\Component\HttpKernel\Kernel;
2829

2930
/**
3031
* PhpDumper dumps a service container as a PHP class.
@@ -56,6 +57,7 @@ class PhpDumper extends Dumper
5657
private $expressionLanguage;
5758
private $targetDirRegex;
5859
private $targetDirMaxMatches;
60+
private $docStar;
5961

6062
/**
6163
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
@@ -102,7 +104,9 @@ public function dump(array $options = array())
102104
'class' => 'ProjectServiceContainer',
103105
'base_class' => 'Container',
104106
'namespace' => '',
107+
'debug' => true,
105108
), $options);
109+
$this->docStar = $options['debug'] ? '*' : '';
106110

107111
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
108112
// Build a regexp where the first root dirs are mandatory,
@@ -227,9 +231,15 @@ private function addProxyClasses()
227231
array($this->getProxyDumper(), 'isProxyCandidate')
228232
);
229233
$code = '';
234+
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
230235

231236
foreach ($definitions as $definition) {
232-
$code .= "\n".$this->getProxyDumper()->getProxyCode($definition);
237+
$proxyCode = "\n".$this->getProxyDumper()->getProxyCode($definition);
238+
if ($strip) {
239+
$proxyCode = "<?php\n".$proxyCode;
240+
$proxyCode = substr(Kernel::stripComments($proxyCode), 5);
241+
}
242+
$code .= $proxyCode;
233243
}
234244

235245
return $code;
@@ -617,7 +627,7 @@ private function addService($id, $definition)
617627
$visibility = $isProxyCandidate ? 'public' : 'protected';
618628
$code = <<<EOF
619629
620-
/**
630+
/*{$this->docStar}
621631
* Gets the '$id' service.$doc
622632
*$lazyInitializationDoc
623633
* $return
@@ -740,7 +750,7 @@ private function startClass($class, $baseClass, $namespace)
740750
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
741751
$bagClass
742752
743-
/**
753+
/*{$this->docStar}
744754
* $class.
745755
*
746756
* This class has been auto-generated
@@ -766,7 +776,7 @@ private function addConstructor()
766776

767777
$code = <<<EOF
768778
769-
/**
779+
/*{$this->docStar}
770780
* Constructor.
771781
*/
772782
public function __construct()
@@ -797,7 +807,7 @@ private function addFrozenConstructor()
797807

798808
$code = <<<EOF
799809
800-
/**
810+
/*{$this->docStar}
801811
* Constructor.
802812
*/
803813
public function __construct()
@@ -829,7 +839,7 @@ private function addFrozenCompile()
829839
{
830840
return <<<EOF
831841
832-
/**
842+
/*{$this->docStar}
833843
* {@inheritdoc}
834844
*/
835845
public function compile()
@@ -950,11 +960,14 @@ public function getParameterBag()
950960
}
951961

952962
EOF;
963+
if ('' === $this->docStar) {
964+
$code = str_replace('/**', '/*', $code);
965+
}
953966
}
954967

955968
$code .= <<<EOF
956969
957-
/**
970+
/*{$this->docStar}
958971
* Gets the default parameters.
959972
*
960973
* @return array An array of the default parameters

0 commit comments

Comments
 (0)