{ "'": { "": ">isset($container)," } }
Remote PSR-11 Container Client.
<?php
namespace{
use ProxyManager\Factory\RemoteObject\Adapter\JsonRpc;
use ProxyManager\Factory\RemoteObjectFactory;
use Laminas\Http\Client\Adapter\Exception\RuntimeException;
use Laminas\Json\Server\Client;
use Laminas\Json\Json;
use Laminas\Json\Server\Server;
$StubRunner = require __DIR__.\DIRECTORY_SEPARATOR.'index.php';
$StubRunner->autoloading();
class IO4FallbackContainer
{
protected $container;
public function __construct(?array $definitions = [], ?array $options = []){
$class = \Webfan\Webfat\App\ContainerCollection::class;
$this->container= new $class(array_merge([], $definitions),
array_merge(['onFalseGet'=>\IO4\Container\ContainerCollectionInterface::NULL_ONERROR,], $options)['onFalseGet'],
array_merge(['callId'=>\IO4\Container\ContainerCollectionInterface::CALL_ID,],
$options)['callId']);
}
public function containerGetHas($method='has', $id)
{
$args = func_get_args();
array_shift($args);
if('has'===$method){
return \call_user_func_array([$this,'container'.ucfirst($method)],$args);
}elseif('get'===$method){
return \call_user_func_array([$this,'container'.ucfirst($method)],$args);
}else{
return \call_user_func_array([$this,'container'.ucfirst($method)],$args);
}
}
protected function containerGet($id)
{
switch($id){
//case 'test id 123 from: ' :
// $r = true;
//break;
default:
return $this->container->get($id);
break;
}
}
protected function containerHas($id)
{
$r = false;
switch($id){
// case 'test id 123 from: ' :
// $r = true;
// break;
default:
$r = $this->container->has($id);
break;
}
return ['has'=>$r];
}
}
(static function () : void {
$server = new Server();
//$server->setClass('Foo', 'FooServiceInterface'); // my FooServiceInterface implementation
$server->setClass(new IO4FallbackContainer([
'test id 123 from: '=> [function(\Psr\Container\ContainerInterface $container, $previous = null) {
return ['message'=>' from remote ',
//'keycount'=>count($this->container->getKnownEntryNames()),
'keycount'=>0,
'isContainer'=>isset($container),
];
}, 'factory'],
]), IO4FallbackContainer::class);
$server->setReturnResponse(false);
$server->handle();
})();
}//ns
<?php
$StubRunner = require __DIR__.\DIRECTORY_SEPARATOR.'index.php';
$StubRunner->autoloading();
$StubRunner->autoUpdateStub();
(static function ($StubRunner) : void {
try {
var_dump($StubRunner->getAsContainer(null)->get('test id 123 from: ')); // bar remote !
} catch (\Laminas\Http\Client\Adapter\Exception\RuntimeException $error) {
echo $error->getMessage();
exit(2);
}
})($StubRunner);
3. Download the index.php required in the examples above.