[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare(strict_types=1); 4 5 namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; 6 7 use ProxyManager\Generator\MethodGenerator; 8 use ProxyManager\ProxyGenerator\Util\Properties; 9 use ProxyManager\ProxyGenerator\Util\UnsetPropertiesGenerator; 10 use ReflectionClass; 11 use Zend\Code\Generator\ParameterGenerator; 12 use Zend\Code\Generator\PropertyGenerator; 13 14 /** 15 * The `staticProxyConstructor` implementation for access interceptor value holders 16 * 17 * @author Marco Pivetta <ocramius@gmail.com> 18 * @license MIT 19 */ 20 class StaticProxyConstructor extends MethodGenerator 21 { 22 /** 23 * Constructor 24 * 25 * @param ReflectionClass $originalClass 26 * @param PropertyGenerator $valueHolder 27 * @param PropertyGenerator $prefixInterceptors 28 * @param PropertyGenerator $suffixInterceptors 29 * 30 * @throws \Zend\Code\Generator\Exception\InvalidArgumentException 31 */ 32 public function __construct( 33 ReflectionClass $originalClass, 34 PropertyGenerator $valueHolder, 35 PropertyGenerator $prefixInterceptors, 36 PropertyGenerator $suffixInterceptors 37 ) { 38 parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC); 39 40 $prefix = new ParameterGenerator('prefixInterceptors'); 41 $suffix = new ParameterGenerator('suffixInterceptors'); 42 43 $prefix->setDefaultValue([]); 44 $suffix->setDefaultValue([]); 45 $prefix->setType('array'); 46 $suffix->setType('array'); 47 48 $this->setParameter(new ParameterGenerator('wrappedObject')); 49 $this->setParameter($prefix); 50 $this->setParameter($suffix); 51 $this->setReturnType($originalClass->getName()); 52 53 $this->setDocBlock( 54 "Constructor to setup interceptors\n\n" 55 . "@param \\" . $originalClass->getName() . " \$wrappedObject\n" 56 . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" 57 . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic\n\n" 58 . '@return self' 59 ); 60 61 $this->setBody( 62 'static $reflection;' . "\n\n" 63 . '$reflection = $reflection ?? $reflection = new \ReflectionClass(__CLASS__);' . "\n" 64 . '$instance = $reflection->newInstanceWithoutConstructor();' . "\n\n" 65 . UnsetPropertiesGenerator::generateSnippet(Properties::fromReflectionClass($originalClass), 'instance') 66 . '$instance->' . $valueHolder->getName() . " = \$wrappedObject;\n" 67 . '$instance->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" 68 . '$instance->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;\n\n" 69 . 'return $instance;' 70 ); 71 } 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |