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