/** * Creates a new Descriptor from the given Reflector. * * @param MethodTag $data * * @return MethodDescriptor */ public function create($data) { $descriptor = new MethodDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setMethodName($data->getMethodName()); $response = new ReturnDescriptor('return'); $response->setTypes($this->builder->buildDescriptor(new Collection($data->getTypes()))); $descriptor->setResponse($response); foreach ($data->getArguments() as $argument) { $argumentDescriptor = $this->createArgumentDescriptorForMagicMethod($argument); $descriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor); } return $descriptor; }
/** * Creates a new Descriptor from the given Reflector. * * @param MethodTag $data * * @return MethodDescriptor */ public function create($data) { $descriptor = new MethodDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setMethodName($data->getMethodName()); $response = new ReturnDescriptor('return'); $response->setTypes($data->getTypes()); $descriptor->setResponse($response); foreach ($data->getArguments() as $argument) { if (count($argument) > 1) { list($argumentType, $argumentName) = $argument; } else { $argumentName = current($argument); $argumentType = 'mixed'; } $argumentDescriptor = new ArgumentDescriptor(); $argumentDescriptor->setTypes(array($argumentType)); $argumentDescriptor->setName($argumentName); $descriptor->getArguments()->set($argumentName, $argumentDescriptor); } return $descriptor; }
/** * @param DocBlock\Tag\MethodTag $tag * @return array */ private function getTypesBy(DocBlock\Tag\MethodTag $tag) { $types = array(); $args = $tag->getArguments(); foreach ($args as $strings) { if (count($strings) > 1) { foreach ($strings as $string) { $string = trim($string); if (strpos($string, '$') === false && !in_array(strtolower($string), $this->ignoredMethodArgumentTypes)) { $types[] = '\\' . trim($string, '\\'); } } } } return $types; }