Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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

TraitGenerator.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 4.74 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-2015 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  class TraitGenerator extends ClassGenerator
015  {
016      const OBJECT_TYPE = 'trait';
017   
018      /**
019       * Build a Code Generation Php Object from a Class Reflection
020       *
021       * @param  ClassReflection $classReflection
022       * @return TraitGenerator
023       */
024      public static function fromReflection(ClassReflection $classReflection)
025      {
026          // class generator
027          $cg = new static($classReflection->getName());
028   
029          $cg->setSourceContent($cg->getSourceContent());
030          $cg->setSourceDirty(false);
031   
032          if ($classReflection->getDocComment() != '') {
033              $cg->setDocBlock(DocBlockGenerator::fromReflection($classReflection->getDocBlock()));
034          }
035   
036          // set the namespace
037          if ($classReflection->inNamespace()) {
038              $cg->setNamespaceName($classReflection->getNamespaceName());
039          }
040   
041          $properties = array();
042          foreach ($classReflection->getProperties() as $reflectionProperty) {
043              if ($reflectionProperty->getDeclaringClass()->getName() == $classReflection->getName()) {
044                  $properties[] = PropertyGenerator::fromReflection($reflectionProperty);
045              }
046          }
047          $cg->addProperties($properties);
048   
049          $methods = array();
050          foreach ($classReflection->getMethods() as $reflectionMethod) {
051              $className = ($cg->getNamespaceName())
052                  ? $cg->getNamespaceName() . '\\' . $cg->getName()
053                  : $cg->getName();
054              if ($reflectionMethod->getDeclaringClass()->getName() == $className) {
055                  $methods[] = MethodGenerator::fromReflection($reflectionMethod);
056              }
057          }
058          $cg->addMethods($methods);
059   
060          return $cg;
061      }
062   
063      /**
064       * Generate from array
065       *
066       * @configkey name           string        [required] Class Name
067       * @configkey filegenerator  FileGenerator File generator that holds this class
068       * @configkey namespacename  string        The namespace for this class
069       * @configkey docblock       string        The docblock information
070       * @configkey properties
071       * @configkey methods
072       *
073       * @throws Exception\InvalidArgumentException
074       * @param  array $array
075       * @return TraitGenerator
076       */
077      public static function fromArray(array $array)
078      {
079          if (! isset($array['name'])) {
080              throw new Exception\InvalidArgumentException(
081                  'Class generator requires that a name is provided for this object'
082              );
083          }
084   
085          $cg = new static($array['name']);
086          foreach ($array as $name => $value) {
087              // normalize key
088              switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
089                  case 'containingfile':
090                      $cg->setContainingFileGenerator($value);
091                      break;
092                  case 'namespacename':
093                      $cg->setNamespaceName($value);
094                      break;
095                  case 'docblock':
096                      $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
097                      $cg->setDocBlock($docBlock);
098                      break;
099                  case 'properties':
100                      $cg->addProperties($value);
101                      break;
102                  case 'methods':
103                      $cg->addMethods($value);
104                      break;
105              }
106          }
107   
108          return $cg;
109      }
110   
111      /**
112       * @param  array|string $flags
113       * @return self
114       */
115      public function setFlags($flags)
116      {
117          return $this;
118      }
119   
120      /**
121       * @param  string $flag
122       * @return self
123       */
124      public function addFlag($flag)
125      {
126          return $this;
127      }
128   
129      /**
130       * @param  string $flag
131       * @return self
132       */
133      public function removeFlag($flag)
134      {
135          return $this;
136      }
137   
138      /**
139       * @param  bool $isFinal
140       * @return self
141       */
142      public function setFinal($isFinal)
143      {
144          return $this;
145      }
146   
147      /**
148       * @param  string $extendedClass
149       * @return self
150       */
151      public function setExtendedClass($extendedClass)
152      {
153          return $this;
154      }
155   
156      /**
157       * @param  array $implementedInterfaces
158       * @return self
159       */
160      public function setImplementedInterfaces(array $implementedInterfaces)
161      {
162          return $this;
163      }
164   
165      /**
166       * @param  bool $isAbstract
167       * @return self
168       */
169      public function setAbstract($isAbstract)
170      {
171          return $this;
172      }
173  }
174