added support to retrieve parameter php type form type hint
Conflicts: ServiceDefinition/Loader/AnnotationClassLoader.php
This commit is contained in:
parent
0126cd4221
commit
62e07ba43c
@ -66,6 +66,7 @@ class AnnotationClassLoader implements LoaderInterface
|
||||
|
||||
$class = new \ReflectionClass($class);
|
||||
$definition = new ServiceDefinition();
|
||||
|
||||
foreach ($class->getMethods() as $method) {
|
||||
$serviceArguments = array();
|
||||
$serviceMethod =
|
||||
@ -75,7 +76,7 @@ class AnnotationClassLoader implements LoaderInterface
|
||||
if ($annotation instanceof ParamAnnotation) {
|
||||
$serviceArguments[] = new Argument(
|
||||
$annotation->getValue(),
|
||||
new Type($annotation->getPhpType(), $annotation->getXmlType())
|
||||
$this->getArgumentType($method, $annotation)
|
||||
);
|
||||
} elseif ($annotation instanceof MethodAnnotation) {
|
||||
if ($serviceMethod) {
|
||||
@ -122,6 +123,30 @@ class AnnotationClassLoader implements LoaderInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionMethod $method
|
||||
* @param ParamAnnotation $annotation
|
||||
*
|
||||
* @return \Bundle\WebServiceBundle\ServiceDefinition\Type
|
||||
*/
|
||||
private function getArgumentType(\ReflectionMethod $method, ParamAnnotation $annotation)
|
||||
{
|
||||
$phpType = $annotation->getPhpType();
|
||||
$xmlType = $annotation->getXmlType();
|
||||
|
||||
if (null === $phpType) {
|
||||
foreach ($method->getParameters() as $param) {
|
||||
if ($param->name === $annotation->getName()) {
|
||||
$phpType = $param->getClass()->name;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Type($phpType, $xmlType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this class supports the given resource.
|
||||
*
|
||||
@ -152,4 +177,4 @@ class AnnotationClassLoader implements LoaderInterface
|
||||
public function getResolver()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user