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: class Property extends Nette\Object
 17: {
 18:     /** @var string */
 19:     private $name;
 20: 
 21:     /** @var mixed */
 22:     public $value;
 23: 
 24:     /** @var bool */
 25:     private $static = FALSE;
 26: 
 27:     /** @var string  public|protected|private */
 28:     private $visibility = 'public';
 29: 
 30:     /** @var array of string */
 31:     private $documents = array();
 32: 
 33: 
 34:     /**
 35:      * @return self
 36:      */
 37:     public static function from(\ReflectionProperty $from)
 38:     {
 39:         $prop = new static;
 40:         $prop->name = $from->getName();
 41:         $defaults = $from->getDeclaringClass()->getDefaultProperties();
 42:         $prop->value = isset($defaults[$prop->name]) ? $defaults[$prop->name] : NULL;
 43:         $prop->static = $from->isStatic();
 44:         $prop->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : 'public');
 45:         $prop->documents = preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"));
 46:         return $prop;
 47:     }
 48: 
 49: 
 50:     /**
 51:      * @param  string  without $
 52:      * @return self
 53:      */
 54:     public function setName($name)
 55:     {
 56:         $this->name = (string) $name;
 57:         return $this;
 58:     }
 59: 
 60: 
 61:     /**
 62:      * @return string
 63:      */
 64:     public function getName()
 65:     {
 66:         return $this->name;
 67:     }
 68: 
 69: 
 70:     /**
 71:      * @return self
 72:      */
 73:     public function setValue($val)
 74:     {
 75:         $this->value = $val;
 76:         return $this;
 77:     }
 78: 
 79: 
 80:     /**
 81:      * @return mixed
 82:      */
 83:     public function getValue()
 84:     {
 85:         return $this->value;
 86:     }
 87: 
 88: 
 89:     /**
 90:      * @param  bool
 91:      * @return self
 92:      */
 93:     public function setStatic($state = TRUE)
 94:     {
 95:         $this->static = (bool) $state;
 96:         return $this;
 97:     }
 98: 
 99: 
100:     /**
101:      * @return bool
102:      */
103:     public function isStatic()
104:     {
105:         return $this->static;
106:     }
107: 
108: 
109:     /**
110:      * @param  string  public|protected|private
111:      * @return self
112:      */
113:     public function setVisibility($val)
114:     {
115:         if (!in_array($val, array('public', 'protected', 'private'), TRUE)) {
116:             throw new Nette\InvalidArgumentException('Argument must be public|protected|private.');
117:         }
118:         $this->visibility = (string) $val;
119:         return $this;
120:     }
121: 
122: 
123:     /**
124:      * @return string
125:      */
126:     public function getVisibility()
127:     {
128:         return $this->visibility;
129:     }
130: 
131: 
132:     /**
133:      * @param  string[]
134:      * @return self
135:      */
136:     public function setDocuments(array $s)
137:     {
138:         $this->documents = $s;
139:         return $this;
140:     }
141: 
142: 
143:     /**
144:      * @return string[]
145:      */
146:     public function getDocuments()
147:     {
148:         return $this->documents;
149:     }
150: 
151: 
152:     /**
153:      * @param  string
154:      * @return self
155:      */
156:     public function addDocument($s)
157:     {
158:         $this->documents[] = (string) $s;
159:         return $this;
160:     }
161: 
162: }
163: 
Nette 2.3.4 API API documentation generated by ApiGen 2.8.0