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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
AbstractMemberGenerator.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-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 abstract class AbstractMemberGenerator extends AbstractGenerator
013 {
014 /**#@+
015 * @const int Flags for construction usage
016 */
017 const FLAG_ABSTRACT = 0x01;
018 const FLAG_FINAL = 0x02;
019 const FLAG_STATIC = 0x04;
020 const FLAG_PUBLIC = 0x10;
021 const FLAG_PROTECTED = 0x20;
022 const FLAG_PRIVATE = 0x40;
023 /**#@-*/
024
025 /**#@+
026 * @param const string
027 */
028 const VISIBILITY_PUBLIC = 'public';
029 const VISIBILITY_PROTECTED = 'protected';
030 const VISIBILITY_PRIVATE = 'private';
031 /**#@-*/
032
033 /**
034 * @var DocBlockGenerator
035 */
036 protected $docBlock = null;
037
038 /**
039 * @var string
040 */
041 protected $name = null;
042
043 /**
044 * @var int
045 */
046 protected $flags = self::FLAG_PUBLIC;
047
048 /**
049 * @param int|array $flags
050 * @return AbstractMemberGenerator
051 */
052 public function setFlags($flags)
053 {
054 if (is_array($flags)) {
055 $flagsArray = $flags;
056 $flags = 0x00;
057 foreach ($flagsArray as $flag) {
058 $flags |= $flag;
059 }
060 }
061 // check that visibility is one of three
062 $this->flags = $flags;
063
064 return $this;
065 }
066
067 /**
068 * @param int $flag
069 * @return AbstractMemberGenerator
070 */
071 public function addFlag($flag)
072 {
073 $this->setFlags($this->flags | $flag);
074 return $this;
075 }
076
077 /**
078 * @param int $flag
079 * @return AbstractMemberGenerator
080 */
081 public function removeFlag($flag)
082 {
083 $this->setFlags($this->flags & ~$flag);
084 return $this;
085 }
086
087 /**
088 * @param bool $isAbstract
089 * @return AbstractMemberGenerator
090 */
091 public function setAbstract($isAbstract)
092 {
093 return (($isAbstract) ? $this->addFlag(self::FLAG_ABSTRACT) : $this->removeFlag(self::FLAG_ABSTRACT));
094 }
095
096 /**
097 * @return bool
098 */
099 public function isAbstract()
100 {
101 return (bool) ($this->flags & self::FLAG_ABSTRACT);
102 }
103
104 /**
105 * @param bool $isFinal
106 * @return AbstractMemberGenerator
107 */
108 public function setFinal($isFinal)
109 {
110 return (($isFinal) ? $this->addFlag(self::FLAG_FINAL) : $this->removeFlag(self::FLAG_FINAL));
111 }
112
113 /**
114 * @return bool
115 */
116 public function isFinal()
117 {
118 return (bool) ($this->flags & self::FLAG_FINAL);
119 }
120
121 /**
122 * @param bool $isStatic
123 * @return AbstractMemberGenerator
124 */
125 public function setStatic($isStatic)
126 {
127 return (($isStatic) ? $this->addFlag(self::FLAG_STATIC) : $this->removeFlag(self::FLAG_STATIC));
128 }
129
130 /**
131 * @return bool
132 */
133 public function isStatic()
134 {
135 return (bool) ($this->flags & self::FLAG_STATIC); // is FLAG_STATIC in flags
136 }
137
138 /**
139 * @param string $visibility
140 * @return AbstractMemberGenerator
141 */
142 public function setVisibility($visibility)
143 {
144 switch ($visibility) {
145 case self::VISIBILITY_PUBLIC:
146 $this->removeFlag(self::FLAG_PRIVATE | self::FLAG_PROTECTED); // remove both
147 $this->addFlag(self::FLAG_PUBLIC);
148 break;
149 case self::VISIBILITY_PROTECTED:
150 $this->removeFlag(self::FLAG_PUBLIC | self::FLAG_PRIVATE); // remove both
151 $this->addFlag(self::FLAG_PROTECTED);
152 break;
153 case self::VISIBILITY_PRIVATE:
154 $this->removeFlag(self::FLAG_PUBLIC | self::FLAG_PROTECTED); // remove both
155 $this->addFlag(self::FLAG_PRIVATE);
156 break;
157 }
158
159 return $this;
160 }
161
162 /**
163 * @return string
164 */
165 public function getVisibility()
166 {
167 switch (true) {
168 case ($this->flags & self::FLAG_PROTECTED):
169 return self::VISIBILITY_PROTECTED;
170 case ($this->flags & self::FLAG_PRIVATE):
171 return self::VISIBILITY_PRIVATE;
172 default:
173 return self::VISIBILITY_PUBLIC;
174 }
175 }
176
177 /**
178 * @param string $name
179 * @return AbstractMemberGenerator
180 */
181 public function setName($name)
182 {
183 $this->name = (string) $name;
184 return $this;
185 }
186
187 /**
188 * @return string
189 */
190 public function getName()
191 {
192 return $this->name;
193 }
194
195 /**
196 * @param DocBlockGenerator|string $docBlock
197 * @throws Exception\InvalidArgumentException
198 * @return AbstractMemberGenerator
199 */
200 public function setDocBlock($docBlock)
201 {
202 if (is_string($docBlock)) {
203 $docBlock = new DocBlockGenerator($docBlock);
204 } elseif (!$docBlock instanceof DocBlockGenerator) {
205 throw new Exception\InvalidArgumentException(sprintf(
206 '%s is expecting either a string, array or an instance of %s\DocBlockGenerator',
207 __METHOD__,
208 __NAMESPACE__
209 ));
210 }
211
212 $this->docBlock = $docBlock;
213
214 return $this;
215 }
216
217 /**
218 * @return DocBlockGenerator
219 */
220 public function getDocBlock()
221 {
222 return $this->docBlock;
223 }
224 }
225