mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Ignore ReflectionException for "magic" JMS\Accessor methods (#1715)
* Update JMSModelDescriber.php Ignore ReflectionException thrown when getter or setter from JMS\ Accessor are "magic" methods. * Add tests to avoid future regressions * CS Co-authored-by: Guilhem Niot <guilhem.niot@gmail.com>
This commit is contained in:
parent
d9f1611f72
commit
429d809f41
@ -93,11 +93,14 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
$reflections[] = new \ReflectionProperty($item->class, $item->name);
|
$reflections[] = new \ReflectionProperty($item->class, $item->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $item->getter) {
|
try {
|
||||||
$reflections[] = new \ReflectionMethod($item->class, $item->getter);
|
if (null !== $item->getter) {
|
||||||
}
|
$reflections[] = new \ReflectionMethod($item->class, $item->getter);
|
||||||
if (null !== $item->setter) {
|
}
|
||||||
$reflections[] = new \ReflectionMethod($item->class, $item->setter);
|
if (null !== $item->setter) {
|
||||||
|
$reflections[] = new \ReflectionMethod($item->class, $item->setter);
|
||||||
|
}
|
||||||
|
} catch (\ReflectionExceptions $ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups = $this->computeGroups($context, $item->type);
|
$groups = $this->computeGroups($context, $item->type);
|
||||||
|
@ -37,9 +37,26 @@ class VirtualProperty
|
|||||||
*/
|
*/
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Serializer\Accessor(getter="getFoo", setter="setFoo")
|
||||||
|
* @Serializer\Type("string")
|
||||||
|
*
|
||||||
|
* Ensures https://github.com/nelmio/NelmioApiDocBundle/issues/1708 is fixed.
|
||||||
|
*/
|
||||||
|
private $virtualprop;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->user = new User();
|
$this->user = new User();
|
||||||
$this->user->setEmail('dummy@test.com');
|
$this->user->setEmail('dummy@test.com');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __call(string $name, array $arguments)
|
||||||
|
{
|
||||||
|
if ('getFoo' === $name || 'setFoo' === $name) {
|
||||||
|
return 'Success';
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \LogicException(sprintf('%s::__call does not implement this function.', __CLASS__));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user