25
25
use Symfony \Component \DependencyInjection \LazyProxy \PhpDumper \NullDumper ;
26
26
use Symfony \Component \DependencyInjection \ExpressionLanguage ;
27
27
use Symfony \Component \ExpressionLanguage \Expression ;
28
+ use Symfony \Component \HttpKernel \Kernel ;
28
29
29
30
/**
30
31
* PhpDumper dumps a service container as a PHP class.
@@ -56,6 +57,7 @@ class PhpDumper extends Dumper
56
57
private $ expressionLanguage ;
57
58
private $ targetDirRegex ;
58
59
private $ targetDirMaxMatches ;
60
+ private $ docStar ;
59
61
60
62
/**
61
63
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
@@ -102,7 +104,9 @@ public function dump(array $options = array())
102
104
'class ' => 'ProjectServiceContainer ' ,
103
105
'base_class ' => 'Container ' ,
104
106
'namespace ' => '' ,
107
+ 'debug ' => true ,
105
108
), $ options );
109
+ $ this ->docStar = $ options ['debug ' ] ? '* ' : '' ;
106
110
107
111
if (!empty ($ options ['file ' ]) && is_dir ($ dir = dirname ($ options ['file ' ]))) {
108
112
// Build a regexp where the first root dirs are mandatory,
@@ -227,9 +231,15 @@ private function addProxyClasses()
227
231
array ($ this ->getProxyDumper (), 'isProxyCandidate ' )
228
232
);
229
233
$ code = '' ;
234
+ $ strip = '' === $ this ->docStar && method_exists ('Symfony\Component\HttpKernel\Kernel ' , 'stripComments ' );
230
235
231
236
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 ;
233
243
}
234
244
235
245
return $ code ;
@@ -617,7 +627,7 @@ private function addService($id, $definition)
617
627
$ visibility = $ isProxyCandidate ? 'public ' : 'protected ' ;
618
628
$ code = <<<EOF
619
629
620
- /**
630
+ /* { $ this -> docStar }
621
631
* Gets the ' $ id' service. $ doc
622
632
* $ lazyInitializationDoc
623
633
* $ return
@@ -740,7 +750,7 @@ private function startClass($class, $baseClass, $namespace)
740
750
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
741
751
$ bagClass
742
752
743
- /**
753
+ /* { $ this -> docStar }
744
754
* $ class.
745
755
*
746
756
* This class has been auto-generated
@@ -766,7 +776,7 @@ private function addConstructor()
766
776
767
777
$ code = <<<EOF
768
778
769
- /**
779
+ /* { $ this -> docStar }
770
780
* Constructor.
771
781
*/
772
782
public function __construct()
@@ -797,7 +807,7 @@ private function addFrozenConstructor()
797
807
798
808
$ code = <<<EOF
799
809
800
- /**
810
+ /* { $ this -> docStar }
801
811
* Constructor.
802
812
*/
803
813
public function __construct()
@@ -829,7 +839,7 @@ private function addFrozenCompile()
829
839
{
830
840
return <<<EOF
831
841
832
- /**
842
+ /* { $ this -> docStar }
833
843
* {@inheritdoc}
834
844
*/
835
845
public function compile()
@@ -950,11 +960,14 @@ public function getParameterBag()
950
960
}
951
961
952
962
EOF;
963
+ if ('' === $ this ->docStar ) {
964
+ $ code = str_replace ('/** ' , '/* ' , $ code );
965
+ }
953
966
}
954
967
955
968
$ code .= <<<EOF
956
969
957
- /**
970
+ /* { $ this -> docStar }
958
971
* Gets the default parameters.
959
972
*
960
973
* @return array An array of the default parameters
0 commit comments