24 #require_once 'Zend/Server/Reflection/Node.php'; 29 #require_once 'Zend/Server/Reflection/Parameter.php'; 34 #require_once 'Zend/Server/Reflection/Prototype.php'; 100 private $_returnDesc;
103 private $_sigParamsDepth;
110 public function __construct(Reflector $r, $namespace =
null, $argv = array())
116 if ((!$r instanceof ReflectionFunction)
117 && (!$r instanceof ReflectionMethod)) {
118 #require_once 'Zend/Server/Reflection/Exception.php'; 121 $this->_reflection = $r;
124 if (
null !== $namespace){
129 if (is_array($argv)) {
130 $this->_argv = $argv;
134 if ($r instanceof ReflectionMethod) {
135 $this->_class = $r->getDeclaringClass()->getName();
155 if ($level >= $this->_sigParamsDepth) {
159 foreach ($this->_sigParams[$level] as
$value) {
161 if ((
null !==
$value) && ($this->_sigParamsDepth > $level + 1)) {
178 $returnTree = array();
179 foreach ((array) $this->_return as
$value) {
182 $returnTree[] = $node;
202 $this->_return = $return;
203 $this->_returnDesc = $returnDesc;
204 $this->_paramDesc = $paramDesc;
205 $this->_sigParams = $paramTypes;
206 $this->_sigParamsDepth = count($paramTypes);
208 $signatures = array();
210 $endPoints = array();
211 foreach ($signatureTrees as $root) {
212 $tmp = $root->getEndPoints();
214 $endPoints = array_merge($endPoints, array($root));
216 $endPoints = array_merge($endPoints, $tmp);
220 foreach ($endPoints as $node) {
225 $signature = array();
227 array_unshift($signature, $node->getValue());
228 $node = $node->getParent();
231 $signatures[] = $signature;
235 $params = $this->_reflection->getParameters();
236 foreach ($signatures as $signature) {
239 foreach ($signature as $key =>
$type) {
241 $param->setPosition($key);
263 $signatures = array();
265 $paramCount = $function->getNumberOfParameters();
266 $paramCountRequired = $function->getNumberOfRequiredParameters();
267 $parameters = $function->getParameters();
268 $docBlock = $function->getDocComment();
270 if (!empty($docBlock)) {
272 if (preg_match(
':/\*\*\s*\r?\n\s*\*\s(.*?)\r?\n\s*\*(\s@|/):s', $docBlock, $matches))
274 $helpText = $matches[1];
275 $helpText = preg_replace(
'/(^\s*\*\s)/m',
'', $helpText);
276 $helpText = preg_replace(
'/\r?\n\s*\*\s*(\r?\n)*/s',
"\n", $helpText);
277 $helpText = trim($helpText);
282 if (preg_match(
'/@return\s+(\S+)/', $docBlock, $matches)) {
283 $return = explode(
'|', $matches[1]);
284 if (preg_match(
'/@return\s+\S+\s+(.*?)(@|\*\/)/s', $docBlock, $matches))
289 $returnDesc = trim(
$value);
294 if (preg_match_all(
'/@param\s+([^\s]+)/m', $docBlock, $matches)) {
295 $paramTypesTmp = $matches[1];
296 if (preg_match_all(
'/@param\s+\S+\s+(\$\S+)\s+(.*?)(?=@|\*\/)/s', $docBlock, $matches))
298 $paramDesc = $matches[2];
299 foreach ($paramDesc as $key =>
$value) {
302 $paramDesc[$key] = trim(
$value);
307 $helpText = $function->getName();
311 $paramTypesTmp = array();
312 foreach ($parameters as
$i => $param) {
313 $paramType =
'mixed';
314 if ($param->isArray()) {
315 $paramType =
'array';
317 $paramTypesTmp[
$i] = $paramType;
325 if (!isset($paramTypesTmp) && (0 < $paramCount)) {
326 $paramTypesTmp = array_fill(0, $paramCount,
'mixed');
327 }
elseif (!isset($paramTypesTmp)) {
328 $paramTypesTmp = array();
329 }
elseif (count($paramTypesTmp) < $paramCount) {
330 $start = $paramCount - count($paramTypesTmp);
332 $paramTypesTmp[
$i] =
'mixed';
337 if (!isset($paramDesc) && (0 < $paramCount)) {
338 $paramDesc = array_fill(0, $paramCount,
'');
339 }
elseif (!isset($paramDesc)) {
340 $paramDesc = array();
341 }
elseif (count($paramDesc) < $paramCount) {
342 $start = $paramCount - count($paramDesc);
348 if (count($paramTypesTmp) != $paramCount) {
349 #require_once 'Zend/Server/Reflection/Exception.php'; 351 'Variable number of arguments is not supported for services (except optional parameters). ' 352 .
'Number of function arguments in ' . $function->getDeclaringClass()->getName() .
'::' 353 . $function->getName() .
'() must correspond to actual number of arguments described in the ' 357 $paramTypes = array();
358 foreach ($paramTypesTmp as
$i => $param) {
359 $tmp = explode(
'|', $param);
360 if ($parameters[
$i]->isOptional()) {
361 array_unshift($tmp,
null);
363 $paramTypes[] = $tmp;
379 if (method_exists($this->_reflection,
$method)) {
380 return call_user_func_array(array($this->_reflection,
$method), $args);
383 #require_once 'Zend/Server/Reflection/Exception.php'; 398 if (isset($this->_config[$key])) {
399 return $this->_config[$key];
416 $this->_config[$key] =
$value;
427 if (empty($namespace)) {
428 $this->_namespace =
'';
432 if (!is_string($namespace) || !preg_match(
'/[a-z0-9_\.]+/i', $namespace)) {
433 #require_once 'Zend/Server/Reflection/Exception.php'; 437 $this->_namespace = $namespace;
458 if (!is_string($string)) {
459 #require_once 'Zend/Server/Reflection/Exception.php'; 463 $this->_description = $string;
507 if ($this->_reflection instanceof ReflectionMethod) {
508 $class =
new ReflectionClass($this->_class);
509 $this->_reflection =
new ReflectionMethod(
$class->newInstance(), $this->getName());
511 $this->_reflection =
new ReflectionFunction($this->getName());
elseif(isset( $params[ 'redirect_parent']))
_addTree(Zend_Server_Reflection_Node $parent, $level=0)
__construct(Reflector $r, $namespace=null, $argv=array())
$_option $_optionId $class
_buildSignatures($return, $returnDesc, $paramTypes, $paramDesc)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]