[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/vendor/symfony/proxy-manager-bridge/LazyProxy/PhpDumper/ -> LazyLoadingValueHolderGenerator.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
  13  
  14  use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator as BaseGenerator;
  15  use Zend\Code\Generator\ClassGenerator;
  16  
  17  /**
  18   * @internal
  19   */
  20  class LazyLoadingValueHolderGenerator extends BaseGenerator
  21  {
  22      /**
  23       * {@inheritdoc}
  24       */
  25      public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator)
  26      {
  27          parent::generate($originalClass, $classGenerator);
  28  
  29          if ($classGenerator->hasMethod('__destruct')) {
  30              $destructor = $classGenerator->getMethod('__destruct');
  31              $body = $destructor->getBody();
  32              $newBody = preg_replace('/^(\$this->initializer[a-zA-Z0-9]++) && .*;\n\nreturn (\$this->valueHolder)/', '$1 || $2', $body);
  33  
  34              if ($body === $newBody) {
  35                  throw new \UnexpectedValueException(sprintf('Unexpected lazy-proxy format generated for method "%s::__destruct()".', $originalClass->name));
  36              }
  37  
  38              $destructor->setBody($newBody);
  39          }
  40      }
  41  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1