/**
* Replaces the parameters within the given $methodInvocation with type-safe interface jails, whenever applicable
*
* @param AbstractMethodInvocation $methodInvocation
*
* @return void
*
* @throws ExceptionInterface
* @throws HierarchyException
*/
public function __invoke(AbstractMethodInvocation $methodInvocation)
{
$method = $methodInvocation->getMethod();
$arguments =& Closure::bind(function &(AbstractMethodInvocation $methodInvocation) {
return $methodInvocation->arguments;
}, null, AbstractMethodInvocation::class)->__invoke($methodInvocation);
foreach ($arguments as $parameterIndex => &$argument) {
if (null === $argument) {
continue;
}
if (!($interface = $this->getParameterInterfaceType($parameterIndex, $method))) {
continue;
}
$argument = $this->jailFactory->createInstanceJail($argument, $interface);
}
}