2626use Symfony \Component \DependencyInjection \ExpressionLanguage ;
2727use Symfony \Component \ExpressionLanguage \Expression ;
2828use 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 ;
@@ -621,7 +631,7 @@ private function addService($id, $definition)
621631 $ visibility = $ isProxyCandidate ? 'public ' : 'protected ' ;
622632 $ code = <<<EOF
623633
624- /**
634+ /* { $ this -> docStar }
625635 * Gets the ' $ id' service. $ doc
626636 * $ lazyInitializationDoc
627637 * $ return
@@ -737,7 +747,7 @@ private function addServiceSynchronizer($id, Definition $definition)
737747
738748 return <<<EOF
739749
740- /**
750+ /* { $ this -> docStar }
741751 * Updates the ' $ id' service.
742752 */
743753 protected function synchronize {$ this ->camelize ($ id )}Service()
@@ -829,7 +839,7 @@ private function startClass($class, $baseClass, $namespace)
829839use Symfony\Component\DependencyInjection\Exception\RuntimeException;
830840$ bagClass
831841
832- /**
842+ /* { $ this -> docStar }
833843 * $ class.
834844 *
835845 * This class has been auto-generated
@@ -855,7 +865,7 @@ private function addConstructor()
855865
856866 $ code = <<<EOF
857867
858- /**
868+ /* { $ this -> docStar }
859869 * Constructor.
860870 */
861871 public function __construct()
@@ -892,7 +902,7 @@ private function addFrozenConstructor()
892902
893903 $ code = <<<EOF
894904
895- /**
905+ /* { $ this -> docStar }
896906 * Constructor.
897907 */
898908 public function __construct()
@@ -939,7 +949,7 @@ private function addFrozenCompile()
939949 {
940950 return <<<EOF
941951
942- /**
952+ /* { $ this -> docStar }
943953 * {@inheritdoc}
944954 */
945955 public function compile()
@@ -1060,11 +1070,14 @@ public function getParameterBag()
10601070 }
10611071
10621072EOF;
1073+ if ('' === $ this ->docStar ) {
1074+ $ code = str_replace ('/** ' , '/* ' , $ code );
1075+ }
10631076 }
10641077
10651078 $ code .= <<<EOF
10661079
1067- /**
1080+ /* { $ this -> docStar }
10681081 * Gets the default parameters.
10691082 *
10701083 * @return array An array of the default parameters
0 commit comments