Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

AbstractBaseFactory.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.34 KiB


 001  <?php
 002   
 003  declare(strict_types=1);
 004   
 005  namespace ProxyManager\Factory;
 006   
 007  use ProxyManager\Configuration;
 008  use ProxyManager\Generator\ClassGenerator;
 009  use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
 010  use ProxyManager\Signature\Exception\InvalidSignatureException;
 011  use ProxyManager\Signature\Exception\MissingSignatureException;
 012  use ProxyManager\Version;
 013  use ReflectionClass;
 014   
 015  /**
 016   * Base factory common logic
 017   *
 018   * @author Marco Pivetta <ocramius@gmail.com>
 019   * @license MIT
 020   */
 021  abstract class AbstractBaseFactory
 022  {
 023      /**
 024       * @var \ProxyManager\Configuration
 025       */
 026      protected $configuration;
 027   
 028      /**
 029       * Cached checked class names
 030       *
 031       * @var string[]
 032       */
 033      private $checkedClasses = [];
 034   
 035      /**
 036       * @param \ProxyManager\Configuration $configuration
 037       */
 038      public function __construct(Configuration $configuration = null)
 039      {
 040          $this->configuration = $configuration ?: new Configuration();
 041      }
 042   
 043      /**
 044       * Generate a proxy from a class name
 045       *
 046       * @param string  $className
 047       * @param mixed[] $proxyOptions
 048       *
 049       * @throws InvalidSignatureException
 050       * @throws MissingSignatureException
 051       * @throws \OutOfBoundsException
 052       */
 053      protected function generateProxy(string $className, array $proxyOptions = []) : string
 054      {
 055          if (\array_key_exists($className, $this->checkedClasses)) {
 056              return $this->checkedClasses[$className];
 057          }
 058   
 059          $proxyParameters = [
 060              'className'           => $className,
 061              'factory'             => get_class($this),
 062              'proxyManagerVersion' => Version::getVersion(),
 063              'proxyOptions'        => $proxyOptions,
 064          ];
 065          $proxyClassName  = $this
 066              ->configuration
 067              ->getClassNameInflector()
 068              ->getProxyClassName($className, $proxyParameters);
 069   
 070          if (! class_exists($proxyClassName)) {
 071              $this->generateProxyClass(
 072                  $proxyClassName,
 073                  $className,
 074                  $proxyParameters,
 075                  $proxyOptions
 076              );
 077          }
 078   
 079          $this
 080              ->configuration
 081              ->getSignatureChecker()
 082              ->checkSignature(new ReflectionClass($proxyClassName), $proxyParameters);
 083   
 084          return $this->checkedClasses[$className] = $proxyClassName;
 085      }
 086   
 087      abstract protected function getGenerator() : ProxyGeneratorInterface;
 088   
 089      /**
 090       * Generates the provided `$proxyClassName` from the given `$className` and `$proxyParameters`
 091       *
 092       * @param string  $proxyClassName
 093       * @param string  $className
 094       * @param array   $proxyParameters
 095       * @param mixed[] $proxyOptions
 096       */
 097      private function generateProxyClass(
 098          string $proxyClassName,
 099          string $className,
 100          array $proxyParameters,
 101          array $proxyOptions = []
 102      ) : void {
 103          $className = $this->configuration->getClassNameInflector()->getUserClassName($className);
 104          $phpClass  = new ClassGenerator($proxyClassName);
 105   
 106          $this->getGenerator()->generate(new ReflectionClass($className), $phpClass, $proxyOptions);
 107   
 108          $phpClass = $this->configuration->getClassSignatureGenerator()->addSignature($phpClass, $proxyParameters);
 109   
 110          $this->configuration->getGeneratorStrategy()->generate($phpClass, $proxyOptions);
 111   
 112          $autoloader = $this->configuration->getProxyAutoloader();
 113   
 114          $autoloader($proxyClassName);
 115      }
 116  }
 117