[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

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

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace ProxyManager\ProxyGenerator\NullObject\MethodGenerator;
   6  
   7  use ProxyManager\Generator\MethodGenerator;
   8  use ProxyManager\Generator\Util\IdentifierSuffixer;
   9  use Zend\Code\Reflection\MethodReflection;
  10  
  11  /**
  12   * Method decorator for null objects
  13   *
  14   * @author Vincent Blanchon <blanchon.vincent@gmail.com>
  15   * @license MIT
  16   */
  17  class NullObjectMethodInterceptor extends MethodGenerator
  18  {
  19      /**
  20       * @param \Zend\Code\Reflection\MethodReflection $originalMethod
  21       *
  22       * @return self|static
  23       */
  24      public static function generateMethod(MethodReflection $originalMethod) : self
  25      {
  26          /* @var $method self */
  27          $method = static::fromReflectionWithoutBodyAndDocBlock($originalMethod);
  28  
  29          if ($originalMethod->returnsReference()) {
  30              $reference = IdentifierSuffixer::getIdentifier('ref');
  31  
  32              $method->setBody("\$$reference = null;\nreturn \$$reference;");
  33          }
  34  
  35          return $method;
  36      }
  37  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1