Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • ClassType
  • Helpers
  • Method
  • Parameter
  • PhpFile
  • PhpLiteral
  • PhpNamespace
  • Property
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (https://nette.org)
  5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\PhpGenerator;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Class property description.
 15:  */
 16: class Property
 17: {
 18:     use Nette\SmartObject;
 19: 
 20:     /** @var string */
 21:     private $name = '';
 22: 
 23:     /** @var mixed */
 24:     public $value;
 25: 
 26:     /** @var bool */
 27:     private $static = FALSE;
 28: 
 29:     /** @var string  public|protected|private */
 30:     private $visibility = 'public';
 31: 
 32:     /** @var string|NULL */
 33:     private $comment;
 34: 
 35: 
 36:     /**
 37:      * @return self
 38:      */
 39:     public static function from(\ReflectionProperty $from)
 40:     {
 41:         $prop = new static($from->getName());
 42:         $defaults = $from->getDeclaringClass()->getDefaultProperties();
 43:         $prop->value = isset($defaults[$prop->name]) ? $defaults[$prop->name] : NULL;
 44:         $prop->static = $from->isStatic();
 45:         $prop->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : 'public');
 46:         $prop->comment = $from->getDocComment() ? preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t")) : NULL;
 47:         return $prop;
 48:     }
 49: 
 50: 
 51:     /**
 52:      * @param  string  without $
 53:      */
 54:     public function __construct($name = '')
 55:     {
 56:         $this->setName($name);
 57:     }
 58: 
 59: 
 60:     /** @deprecated */
 61:     public function setName($name)
 62:     {
 63:         $this->name = (string) $name;
 64:         return $this;
 65:     }
 66: 
 67: 
 68:     /**
 69:      * @return string
 70:      */
 71:     public function getName()
 72:     {
 73:         return $this->name;
 74:     }
 75: 
 76: 
 77:     /**
 78:      * @return self
 79:      */
 80:     public function setValue($val)
 81:     {
 82:         $this->value = $val;
 83:         return $this;
 84:     }
 85: 
 86: 
 87:     /**
 88:      * @return mixed
 89:      */
 90:     public function getValue()
 91:     {
 92:         return $this->value;
 93:     }
 94: 
 95: 
 96:     /**
 97:      * @param  bool
 98:      * @return self
 99:      */
100:     public function setStatic($state = TRUE)
101:     {
102:         $this->static = (bool) $state;
103:         return $this;
104:     }
105: 
106: 
107:     /**
108:      * @return bool
109:      */
110:     public function isStatic()
111:     {
112:         return $this->static;
113:     }
114: 
115: 
116:     /**
117:      * @param  string  public|protected|private
118:      * @return self
119:      */
120:     public function setVisibility($val)
121:     {
122:         if (!in_array($val, ['public', 'protected', 'private'], TRUE)) {
123:             throw new Nette\InvalidArgumentException('Argument must be public|protected|private.');
124:         }
125:         $this->visibility = (string) $val;
126:         return $this;
127:     }
128: 
129: 
130:     /**
131:      * @return string
132:      */
133:     public function getVisibility()
134:     {
135:         return $this->visibility;
136:     }
137: 
138: 
139:     /**
140:      * @param  string|NULL
141:      * @return self
142:      */
143:     public function setComment($val)
144:     {
145:         $this->comment = $val ? (string) $val : NULL;
146:         return $this;
147:     }
148: 
149: 
150:     /**
151:      * @return string|NULL
152:      */
153:     public function getComment()
154:     {
155:         return $this->comment;
156:     }
157: 
158: 
159:     /**
160:      * @param  string
161:      * @return self
162:      */
163:     public function addComment($val)
164:     {
165:         $this->comment .= $this->comment ? "\n$val" : $val;
166:         return $this;
167:     }
168: 
169: 
170:     /** @deprecated */
171:     public function setDocuments(array $s)
172:     {
173:         trigger_error(__METHOD__ . '() is deprecated, use similar setComment()', E_USER_DEPRECATED);
174:         return $this->setComment(implode("\n", $s));
175:     }
176: 
177: 
178:     /** @deprecated */
179:     public function getDocuments()
180:     {
181:         trigger_error(__METHOD__ . '() is deprecated, use similar getComment()', E_USER_DEPRECATED);
182:         return $this->comment ? [$this->comment] : [];
183:     }
184: 
185: 
186:     /** @deprecated */
187:     public function addDocument($s)
188:     {
189:         trigger_error(__METHOD__ . '() is deprecated, use addComment()', E_USER_DEPRECATED);
190:         return $this->addComment($s);
191:     }
192: 
193: }
194: 
Nette 2.4-20161109 API API documentation generated by ApiGen 2.8.0