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

CanProxyAssertion.php

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


 01  <?php
 02   
 03  declare(strict_types=1);
 04   
 05  namespace ProxyManager\ProxyGenerator\Assertion;
 06   
 07  use BadMethodCallException;
 08  use ProxyManager\Exception\InvalidProxiedClassException;
 09  use ReflectionClass;
 10  use ReflectionMethod;
 11   
 12  /**
 13   * Assertion that verifies that a class can be proxied
 14   *
 15   * @author Marco Pivetta <ocramius@gmail.com>
 16   * @license MIT
 17   */
 18  final class CanProxyAssertion
 19  {
 20      /**
 21       * Disabled constructor: not meant to be instantiated
 22       *
 23       * @throws BadMethodCallException
 24       */
 25      public function __construct()
 26      {
 27          throw new BadMethodCallException('Unsupported constructor.');
 28      }
 29   
 30      /**
 31       * @param ReflectionClass $originalClass
 32       * @param bool            $allowInterfaces
 33       *
 34       * @throws InvalidProxiedClassException
 35       */
 36      public static function assertClassCanBeProxied(ReflectionClass $originalClass, bool $allowInterfaces = true) : void
 37      {
 38          self::isNotFinal($originalClass);
 39          self::hasNoAbstractProtectedMethods($originalClass);
 40   
 41          if (! $allowInterfaces) {
 42              self::isNotInterface($originalClass);
 43          }
 44      }
 45   
 46      /**
 47       * @param ReflectionClass $originalClass
 48       *
 49       * @throws InvalidProxiedClassException
 50       */
 51      private static function isNotFinal(ReflectionClass $originalClass) : void
 52      {
 53          if ($originalClass->isFinal()) {
 54              throw InvalidProxiedClassException::finalClassNotSupported($originalClass);
 55          }
 56      }
 57   
 58      /**
 59       * @param ReflectionClass $originalClass
 60       *
 61       * @throws InvalidProxiedClassException
 62       */
 63      private static function hasNoAbstractProtectedMethods(ReflectionClass $originalClass) : void
 64      {
 65          $protectedAbstract = array_filter(
 66              $originalClass->getMethods(),
 67              function (ReflectionMethod $method) : bool {
 68                  return $method->isAbstract() && $method->isProtected();
 69              }
 70          );
 71   
 72          if ($protectedAbstract) {
 73              throw InvalidProxiedClassException::abstractProtectedMethodsNotSupported($originalClass);
 74          }
 75      }
 76   
 77      /**
 78       * @param ReflectionClass $originalClass
 79       *
 80       * @throws InvalidProxiedClassException
 81       */
 82      private static function isNotInterface(ReflectionClass $originalClass) : void
 83      {
 84          if ($originalClass->isInterface()) {
 85              throw InvalidProxiedClassException::interfaceNotSupported($originalClass);
 86          }
 87      }
 88  }
 89