/** * @param \ReflectionMethod $method * @param array $args * @param callable $parameterFilter * @return array Of the injected arguments * @throws InjectionException */ public function injectMethodArguments(\ReflectionMethod $method, array $args, $parameterFilter) { $analyzer = new MethodAnalyzer($method); try { return $analyzer->fillParameters($args, $this->injector, $parameterFilter); } catch (\InvalidArgumentException $e) { throw new InjectionException("Cannot inject method [{$method->getDeclaringClass()->getName()}" . "::{$method->getName()}]: " . $e->getMessage(), 0, $e); } }
private function filter(\ReflectionMethod $method, $arguments) { $filters = new DefaultFilterRegistry(); $analyzer = new MethodAnalyzer($method); $args = $analyzer->normalize($arguments); foreach ($args as $name => $value) { $type = $analyzer->getTypeHint($analyzer->getParameter($name)); if ($type) { $args[$name] = $filters->getFilter($type)->filter($args[$name]); } } return $args; }
/** * @return string|null */ public function comment() { if ($this->getter) { $analyzer = new MethodAnalyzer($this->getter); return $analyzer->getReturnComment(); } else { if ($this->setter) { $analyzer = new MethodAnalyzer($this->setter); $comments = array_values($analyzer->getComments()); return $comments[0]; } } return null; }
/** * @param mixed[] $parameters Values indexed by name * @return mixed the result of the execution * @throws \Exception if Action cannot be executed */ public function execute(array $parameters) { $injector = function () { }; $filter = function () { return true; }; $analyzer = new MethodAnalyzer($this->method); $arguments = $analyzer->fillParameters($parameters, $injector, $filter); return $this->method->invokeArgs($this->object, $arguments); }
function testReadComment() { $method = new MethodAnalyzer(new \ReflectionMethod(MethodAnalyzerTest_Foo::$CLASS, 'fourth')); $this->assertEquals($method->getComments(), array('one' => null, 'two' => 'With Comment')); }
/** * @return string|null */ public function comment() { $analyzer = new MethodAnalyzer($this->constructor); return $analyzer->getComment($this->parameter); }
private function filter(MethodAnalyzer $analyzer, $arguments) { $args = $analyzer->normalize($arguments); foreach ($args as $name => $value) { $type = $analyzer->getTypeHint($analyzer->getParameter($name)); if ($type) { $args[$name] = $this->filters->getFilter($type)->filter($args[$name]); } } return $args; }