Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Class.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Server/Reflection/Method.php';
25 
40 {
46  protected $_config = array();
47 
52  protected $_methods = array();
53 
58  protected $_namespace = null;
59 
64  protected $_reflection;
65 
77  public function __construct(ReflectionClass $reflection, $namespace = null, $argv = false)
78  {
79  $this->_reflection = $reflection;
80  $this->setNamespace($namespace);
81 
82  foreach ($reflection->getMethods() as $method) {
83  // Don't aggregate magic methods
84  if ('__' == substr($method->getName(), 0, 2)) {
85  continue;
86  }
87 
88  if ($method->isPublic()) {
89  // Get signatures and description
90  $this->_methods[] = new Zend_Server_Reflection_Method($this, $method, $this->getNamespace(), $argv);
91  }
92  }
93  }
94 
102  public function __call($method, $args)
103  {
104  if (method_exists($this->_reflection, $method)) {
105  return call_user_func_array(array($this->_reflection, $method), $args);
106  }
107 
108  #require_once 'Zend/Server/Reflection/Exception.php';
109  throw new Zend_Server_Reflection_Exception('Invalid reflection method');
110  }
111 
121  public function __get($key)
122  {
123  if (isset($this->_config[$key])) {
124  return $this->_config[$key];
125  }
126 
127  return null;
128  }
129 
139  public function __set($key, $value)
140  {
141  $this->_config[$key] = $value;
142  }
143 
150  public function getMethods()
151  {
152  return $this->_methods;
153  }
154 
160  public function getNamespace()
161  {
162  return $this->_namespace;
163  }
164 
171  public function setNamespace($namespace)
172  {
173  if (empty($namespace)) {
174  $this->_namespace = '';
175  return;
176  }
177 
178  if (!is_string($namespace) || !preg_match('/[a-z0-9_\.]+/i', $namespace)) {
179  #require_once 'Zend/Server/Reflection/Exception.php';
180  throw new Zend_Server_Reflection_Exception('Invalid namespace');
181  }
182 
183  $this->_namespace = $namespace;
184  }
185 
194  public function __wakeup()
195  {
196  $this->_reflection = new ReflectionClass($this->getName());
197  }
198 }
__construct(ReflectionClass $reflection, $namespace=null, $argv=false)
Definition: Class.php:77
setNamespace($namespace)
Definition: Class.php:171
$value
Definition: gender.phtml:16
$method
Definition: info.phtml:13
__call($method, $args)
Definition: Class.php:102