/** * Build method signatures * * Builds method signatures using the array of return types and the array of * parameters types * * @param array $return Array of return types * @param string $returnDesc Return value description * @param array $paramTypes Array of arguments (each an array of types) * @param array $paramDesc Array of parameter descriptions * @return array */ protected function buildSignatures($return, $returnDesc, $paramTypes, $paramDesc) { $this->return = $return; $this->returnDesc = $returnDesc; $this->paramDesc = $paramDesc; $this->sigParams = $paramTypes; $this->sigParamsDepth = count($paramTypes); $signatureTrees = $this->buildTree(); $signatures = array(); $endPoints = array(); foreach ($signatureTrees as $root) { $tmp = $root->getEndPoints(); if (empty($tmp)) { $endPoints = array_merge($endPoints, array($root)); } else { $endPoints = array_merge($endPoints, $tmp); } } foreach ($endPoints as $node) { if (!$node instanceof Node) { continue; } $signature = array(); do { array_unshift($signature, $node->getValue()); $node = $node->getParent(); } while ($node instanceof Node); $signatures[] = $signature; } // Build prototypes $params = $this->reflection->getParameters(); foreach ($signatures as $signature) { $return = new ReflectionReturnValue(array_shift($signature), $this->returnDesc); $tmp = array(); foreach ($signature as $key => $type) { $param = new ReflectionParameter($params[$key], $type, isset($this->paramDesc[$key]) ? $this->paramDesc[$key] : null); $param->setPosition($key); $tmp[] = $param; } $this->prototypes[] = new Prototype($return, $tmp); } }
/** * get/setPosition() test */ public function testSetPosition() { $r = new Reflection\ReflectionParameter($this->_getParameter()); $this->assertEquals(null, $r->getPosition()); $r->setPosition(3); $this->assertEquals(3, $r->getPosition()); }