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
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • 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 (http://nette.org)
  5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\PhpGenerator;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Class property description.
 15:  *
 16:  * @author     David Grudl
 17:  */
 18: class Property extends Nette\Object
 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 array of string */
 33:     private $documents = array();
 34: 
 35: 
 36:     /**
 37:      * @return self
 38:      */
 39:     public static function from(\ReflectionProperty $from)
 40:     {
 41:         $prop = new static;
 42:         $prop->name = $from->getName();
 43:         $defaults = $from->getDeclaringClass()->getDefaultProperties();
 44:         $prop->value = isset($defaults[$prop->name]) ? $defaults[$prop->name] : NULL;
 45:         $prop->static = $from->isStatic();
 46:         $prop->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : 'public');
 47:         $prop->documents = preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"));
 48:         return $prop;
 49:     }
 50: 
 51: 
 52:     /**
 53:      * @param  string  without $
 54:      * @return self
 55:      */
 56:     public function setName($name)
 57:     {
 58:         $this->name = (string) $name;
 59:         return $this;
 60:     }
 61: 
 62: 
 63:     /**
 64:      * @return string
 65:      */
 66:     public function getName()
 67:     {
 68:         return $this->name;
 69:     }
 70: 
 71: 
 72:     /**
 73:      * @return self
 74:      */
 75:     public function setValue($val)
 76:     {
 77:         $this->value = $val;
 78:         return $this;
 79:     }
 80: 
 81: 
 82:     /**
 83:      * @return mixed
 84:      */
 85:     public function getValue()
 86:     {
 87:         return $this->value;
 88:     }
 89: 
 90: 
 91:     /**
 92:      * @param  bool
 93:      * @return self
 94:      */
 95:     public function setStatic($state = TRUE)
 96:     {
 97:         $this->static = (bool) $state;
 98:         return $this;
 99:     }
100: 
101: 
102:     /**
103:      * @return bool
104:      */
105:     public function isStatic()
106:     {
107:         return $this->static;
108:     }
109: 
110: 
111:     /**
112:      * @param  string  public|protected|private
113:      * @return self
114:      */
115:     public function setVisibility($val)
116:     {
117:         if (!in_array($val, array('public', 'protected', 'private'), TRUE)) {
118:             throw new Nette\InvalidArgumentException('Argument must be public|protected|private.');
119:         }
120:         $this->visibility = (string) $val;
121:         return $this;
122:     }
123: 
124: 
125:     /**
126:      * @return string
127:      */
128:     public function getVisibility()
129:     {
130:         return $this->visibility;
131:     }
132: 
133: 
134:     /**
135:      * @param  string[]
136:      * @return self
137:      */
138:     public function setDocuments(array $s)
139:     {
140:         $this->documents = $s;
141:         return $this;
142:     }
143: 
144: 
145:     /**
146:      * @return string[]
147:      */
148:     public function getDocuments()
149:     {
150:         return $this->documents;
151:     }
152: 
153: 
154:     /**
155:      * @param  string
156:      * @return self
157:      */
158:     public function addDocument($s)
159:     {
160:         $this->documents[] = (string) $s;
161:         return $this;
162:     }
163: 
164: }
165: 
Nette 2.3.1 API API documentation generated by ApiGen 2.8.0