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

InterfaceGenerator.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 4.41 KiB


 001  <?php
 002  /**
 003   * Zend Framework (http://framework.zend.com/)
 004   *
 005   * @link      http://github.com/zendframework/zf2 for the canonical source repository
 006   * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 007   * @license   http://framework.zend.com/license/new-bsd New BSD License
 008   */
 009   
 010  namespace Zend\Code\Generator;
 011   
 012  use Zend\Code\Reflection\ClassReflection;
 013   
 014  use function sprintf;
 015  use function str_replace;
 016  use function strtolower;
 017   
 018  class InterfaceGenerator extends ClassGenerator
 019  {
 020      const OBJECT_TYPE = 'interface';
 021      const IMPLEMENTS_KEYWORD = 'extends';
 022   
 023      /**
 024       * Build a Code Generation Php Object from a Class Reflection
 025       *
 026       * @param  ClassReflection $classReflection
 027       * @return InterfaceGenerator
 028       */
 029      public static function fromReflection(ClassReflection $classReflection)
 030      {
 031          if (! $classReflection->isInterface()) {
 032              throw new Exception\InvalidArgumentException(sprintf(
 033                  'Class %s is not a interface',
 034                  $classReflection->getName()
 035              ));
 036          }
 037   
 038          // class generator
 039          $cg      = new static($classReflection->getName());
 040          $methods = [];
 041   
 042          $cg->setSourceContent($cg->getSourceContent());
 043          $cg->setSourceDirty(false);
 044   
 045          if ($classReflection->getDocComment() != '') {
 046              $cg->setDocBlock(DocBlockGenerator::fromReflection($classReflection->getDocBlock()));
 047          }
 048   
 049          // set the namespace
 050          if ($classReflection->inNamespace()) {
 051              $cg->setNamespaceName($classReflection->getNamespaceName());
 052          }
 053   
 054          foreach ($classReflection->getMethods() as $reflectionMethod) {
 055              $className = $cg->getNamespaceName()
 056                  ? $cg->getNamespaceName() . '\\' . $cg->getName()
 057                  : $cg->getName();
 058   
 059              if ($reflectionMethod->getDeclaringClass()->getName() == $className) {
 060                  $methods[] = MethodGenerator::fromReflection($reflectionMethod);
 061              }
 062          }
 063   
 064          foreach ($classReflection->getConstants() as $name => $value) {
 065              $cg->addConstant($name, $value);
 066          }
 067   
 068          $cg->addMethods($methods);
 069   
 070          return $cg;
 071      }
 072   
 073      /**
 074       * Generate from array
 075       *
 076       * @configkey name           string        [required] Class Name
 077       * @configkey filegenerator  FileGenerator File generator that holds this class
 078       * @configkey namespacename  string        The namespace for this class
 079       * @configkey docblock       string        The docblock information
 080       * @configkey constants
 081       * @configkey methods
 082       *
 083       * @throws Exception\InvalidArgumentException
 084       * @param  array $array
 085       * @return InterfaceGenerator
 086       */
 087      public static function fromArray(array $array)
 088      {
 089          if (! isset($array['name'])) {
 090              throw new Exception\InvalidArgumentException(
 091                  'Class generator requires that a name is provided for this object'
 092              );
 093          }
 094   
 095          $cg = new static($array['name']);
 096          foreach ($array as $name => $value) {
 097              // normalize key
 098              switch (strtolower(str_replace(['.', '-', '_'], '', $name))) {
 099                  case 'containingfile':
 100                      $cg->setContainingFileGenerator($value);
 101                      break;
 102                  case 'namespacename':
 103                      $cg->setNamespaceName($value);
 104                      break;
 105                  case 'docblock':
 106                      $docBlock = $value instanceof DocBlockGenerator ? $value : DocBlockGenerator::fromArray($value);
 107                      $cg->setDocBlock($docBlock);
 108                      break;
 109                  case 'methods':
 110                      $cg->addMethods($value);
 111                      break;
 112                  case 'constants':
 113                      $cg->addConstants($value);
 114                      break;
 115              }
 116          }
 117   
 118          return $cg;
 119      }
 120   
 121      /**
 122       * {@inheritDoc}
 123       */
 124      public function addPropertyFromGenerator(PropertyGenerator $property)
 125      {
 126          return $this;
 127      }
 128   
 129      /**
 130       * {@inheritDoc}
 131       */
 132      public function addMethodFromGenerator(MethodGenerator $method)
 133      {
 134          $method->setInterface(true);
 135   
 136          return parent::addMethodFromGenerator($method);
 137      }
 138   
 139      /**
 140       * {@inheritDoc}
 141       */
 142      public function setExtendedClass($extendedClass)
 143      {
 144          return $this;
 145      }
 146   
 147      /**
 148       * {@inheritDoc}
 149       */
 150      public function setAbstract($isAbstract)
 151      {
 152          return $this;
 153      }
 154  }
 155