Closed marcelloh closed 7 years ago
What do you mean by incomplete code? I can refactor to the code bellow:
$response = $this->resolve('response');
$class = new \ReflectionClass($namespace.'\\'.$className);
if (!$class->isInstantiable() || !$class->hasMethod($methodName)) {
$handler = $this->getContainer()['notFoundHandler'];
return $handler($this->getContainer()['request'], $this->getContainer()['response']);
}
$method = $class->getMethod($methodName);
$constructorArgs = $this->resolveDependencies($class->getConstructor()->getParameters());
$methodArgs = $this->resolveDependencies($method->getParameters(), $requestParams);
$ret = $method->invokeArgs($class->newInstanceArgs($constructorArgs), $methodArgs);
incomplete code: completely my fault: somehow (when I copy-pasted some code, one of the end-tags was missing, resulting in some strange format in my phpstorm.
The resolve function does also do a part that you do in the resolveRoute function, that's what I noticed.
I was wondering how you solved "Dynamic routing" and saw incomplete code. My advice is to have codeception tests, or phpunit tests to check ever part of the program
I also think there is things double:
with the line that follow: