Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Dumper/PhpDumper.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 1fec387a4317 |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
394 $lineage[$class] = substr($exportedFile, 1, -1); | 394 $lineage[$class] = substr($exportedFile, 1, -1); |
395 } | 395 } |
396 | 396 |
397 private function generateProxyClasses() | 397 private function generateProxyClasses() |
398 { | 398 { |
399 $alreadyGenerated = array(); | |
399 $definitions = $this->container->getDefinitions(); | 400 $definitions = $this->container->getDefinitions(); |
400 $strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments'); | 401 $strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments'); |
401 $proxyDumper = $this->getProxyDumper(); | 402 $proxyDumper = $this->getProxyDumper(); |
402 ksort($definitions); | 403 ksort($definitions); |
403 foreach ($definitions as $definition) { | 404 foreach ($definitions as $definition) { |
404 if (!$proxyDumper->isProxyCandidate($definition)) { | 405 if (!$proxyDumper->isProxyCandidate($definition)) { |
405 continue; | 406 continue; |
406 } | 407 } |
408 if (isset($alreadyGenerated[$class = $definition->getClass()])) { | |
409 continue; | |
410 } | |
411 $alreadyGenerated[$class] = true; | |
407 // register class' reflector for resource tracking | 412 // register class' reflector for resource tracking |
408 $this->container->getReflectionClass($definition->getClass()); | 413 $this->container->getReflectionClass($class); |
409 $proxyCode = "\n".$proxyDumper->getProxyCode($definition); | 414 $proxyCode = "\n".$proxyDumper->getProxyCode($definition); |
410 if ($strip) { | 415 if ($strip) { |
411 $proxyCode = "<?php\n".$proxyCode; | 416 $proxyCode = "<?php\n".$proxyCode; |
412 $proxyCode = substr(Kernel::stripComments($proxyCode), 5); | 417 $proxyCode = substr(Kernel::stripComments($proxyCode), 5); |
413 } | 418 } |
494 // this is an indication for a wrong implementation, you can circumvent this problem | 499 // this is an indication for a wrong implementation, you can circumvent this problem |
495 // by setting up your service structure like this: | 500 // by setting up your service structure like this: |
496 // $b = new ServiceB(); | 501 // $b = new ServiceB(); |
497 // $a = new ServiceA(ServiceB $b); | 502 // $a = new ServiceA(ServiceB $b); |
498 // $b->setServiceA(ServiceA $a); | 503 // $b->setServiceA(ServiceA $a); |
499 if (isset($inlinedDefinition[$definition]) && $this->hasReference($id, array($def->getArguments(), $def->getFactory()))) { | 504 if (isset($inlinedDefinitions[$definition]) && $this->hasReference($id, array($def->getArguments(), $def->getFactory()))) { |
500 throw new ServiceCircularReferenceException($id, array($id)); | 505 throw new ServiceCircularReferenceException($id, array($id)); |
501 } | 506 } |
502 | 507 |
503 $code .= $this->addNewInstance($def, '$'.$name, ' = ', $id); | 508 $code .= $this->addNewInstance($def, '$'.$name, ' = ', $id); |
504 | 509 |
1894 } | 1899 } |
1895 | 1900 |
1896 if ($this->container->hasDefinition($id) && ($definition = $this->container->getDefinition($id)) && !$definition->isSynthetic()) { | 1901 if ($this->container->hasDefinition($id) && ($definition = $this->container->getDefinition($id)) && !$definition->isSynthetic()) { |
1897 if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) { | 1902 if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) { |
1898 $code = 'null'; | 1903 $code = 'null'; |
1904 if (!$definition->isShared()) { | |
1905 return $code; | |
1906 } | |
1899 } elseif ($this->isTrivialInstance($definition)) { | 1907 } elseif ($this->isTrivialInstance($definition)) { |
1900 $code = substr($this->addNewInstance($definition, '', '', $id), 8, -2); | 1908 $code = substr($this->addNewInstance($definition, '', '', $id), 8, -2); |
1901 if ($definition->isShared()) { | 1909 if ($definition->isShared()) { |
1902 $code = sprintf('$this->services[\'%s\'] = %s', $id, $code); | 1910 $code = sprintf('$this->services[\'%s\'] = %s', $id, $code); |
1903 } | 1911 } |