[ Index ] |
PHP Cross Reference of phpBB-3.3.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare(strict_types=1); 4 5 namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator; 6 7 use ProxyManager\Factory\RemoteObject\AdapterInterface; 8 use ProxyManager\Generator\MethodGenerator; 9 use ProxyManager\ProxyGenerator\Util\Properties; 10 use ProxyManager\ProxyGenerator\Util\UnsetPropertiesGenerator; 11 use ReflectionClass; 12 use Zend\Code\Generator\ParameterGenerator; 13 use Zend\Code\Generator\PropertyGenerator; 14 15 /** 16 * The `staticProxyConstructor` implementation for remote object proxies 17 * 18 * @author Vincent Blanchon <blanchon.vincent@gmail.com> 19 * @author Marco Pivetta <ocramius@gmail.com> 20 * @license MIT 21 */ 22 class StaticProxyConstructor extends MethodGenerator 23 { 24 /** 25 * Constructor 26 * 27 * @param ReflectionClass $originalClass Reflection of the class to proxy 28 * @param PropertyGenerator $adapter Adapter property 29 */ 30 public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapter) 31 { 32 $adapterName = $adapter->getName(); 33 34 parent::__construct( 35 'staticProxyConstructor', 36 [new ParameterGenerator($adapterName, AdapterInterface::class)], 37 MethodGenerator::FLAG_PUBLIC | MethodGenerator::FLAG_STATIC, 38 null, 39 'Constructor for remote object control\n\n' 40 . '@param \\ProxyManager\\Factory\\RemoteObject\\AdapterInterface \$adapter' 41 ); 42 43 $body = 'static $reflection;' . "\n\n" 44 . '$reflection = $reflection ?? $reflection = new \ReflectionClass(__CLASS__);' . "\n" 45 . '$instance = $reflection->newInstanceWithoutConstructor();' . "\n\n" 46 . '$instance->' . $adapterName . ' = $' . $adapterName . ";\n\n" 47 . UnsetPropertiesGenerator::generateSnippet(Properties::fromReflectionClass($originalClass), 'instance'); 48 49 $this->setBody($body . "\n\nreturn \$instance;"); 50 } 51 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Nov 4 14:26:03 2023 | Cross-referenced by PHPXref 0.7.1 |