[ Index ]

PHP Cross Reference of phpBB-3.3.7-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/ -> MagicGet.php (source)

   1  <?php
   2  /*
   3   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   4   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   5   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   6   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   7   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   8   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   9   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14   *
  15   * This software consists of voluntary contributions made by many individuals
  16   * and is licensed under the MIT license.
  17   */
  18  
  19  declare(strict_types=1);
  20  
  21  namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator;
  22  
  23  use ProxyManager\Generator\MagicMethodGenerator;
  24  use ProxyManager\ProxyGenerator\Util\GetMethodIfExists;
  25  use Zend\Code\Generator\ParameterGenerator;
  26  use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator;
  27  use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator;
  28  use ReflectionClass;
  29  use Zend\Code\Generator\PropertyGenerator;
  30  
  31  /**
  32   * Magic `__get` for lazy loading ghost objects
  33   *
  34   * @author Marco Pivetta <ocramius@gmail.com>
  35   * @license MIT
  36   */
  37  class MagicGet extends MagicMethodGenerator
  38  {
  39      /**
  40       * @param ReflectionClass   $originalClass
  41       * @param PropertyGenerator $prefixInterceptors
  42       * @param PropertyGenerator $suffixInterceptors
  43       *
  44       * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
  45       * @throws \InvalidArgumentException
  46       */
  47      public function __construct(
  48          ReflectionClass $originalClass,
  49          PropertyGenerator $prefixInterceptors,
  50          PropertyGenerator $suffixInterceptors
  51      ) {
  52          parent::__construct($originalClass, '__get', [new ParameterGenerator('name')]);
  53  
  54          $parent = GetMethodIfExists::get($originalClass, '__get');
  55  
  56          $this->setDocBlock(($parent ? "{@inheritDoc}\n" : '') . '@param string $name');
  57  
  58          $callParent = '$returnValue = & parent::__get($name);';
  59  
  60          if (! $parent) {
  61              $callParent = PublicScopeSimulator::getPublicAccessSimulationCode(
  62                  PublicScopeSimulator::OPERATION_GET,
  63                  'name',
  64                  null,
  65                  null,
  66                  'returnValue'
  67              );
  68          }
  69  
  70          $this->setBody(InterceptorGenerator::createInterceptedMethodBody(
  71              $callParent,
  72              $this,
  73              $prefixInterceptors,
  74              $suffixInterceptors,
  75              $parent
  76          ));
  77      }
  78  }


Generated: Thu Mar 24 21:31:15 2022 Cross-referenced by PHPXref 0.7.1