/** * 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); } }
public function createInstanceJail($instance, $typeOrAlias) { $type = $this->typeAliasManager->getType($typeOrAlias) ?: $typeOrAlias; return $this->jailFactory->createInstanceJail($instance, $type); }
public function testCreateProxyFromAProxy() { $proxy = $this->createMock(ProxyInterface::class); $this->assertSame($proxy, $this->factory->createInstanceJail($proxy, ProxyInterface::class)); }
public function testCreateProxyFromAProxy() { $proxy = $this->factory->createInstanceJail(new BaseClass(), BaseClass::class); $this->assertNotNull($proxy, $this->factory->createInstanceJail($proxy, BaseClass::class)); }