Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

StaticProxyConstructor.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 1.85 KiB


01  <?php
02   
03  declare(strict_types=1);
04   
05  namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator;
06   
07  use ProxyManager\Factory\RemoteObject\AdapterInterface;
08  use ProxyManager\Generator\MethodGenerator;
09  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  }
52