PDF rausgenommen
This commit is contained in:
38
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php
vendored
Normal file
38
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* This example demonstrates how an access interceptor scope localizer
|
||||
* (which is a specific type of smart reference) is safe to use to
|
||||
* proxy fluent interfaces.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory;
|
||||
|
||||
class FluentCounter
|
||||
{
|
||||
public $counter = 0;
|
||||
|
||||
/** @return FluentCounter */
|
||||
public function fluentMethod()
|
||||
{
|
||||
$this->counter += 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
$factory = new AccessInterceptorScopeLocalizerFactory();
|
||||
$foo = new FluentCounter();
|
||||
|
||||
/* @var $proxy FluentCounter */
|
||||
$proxy = $factory->createProxy(
|
||||
$foo,
|
||||
array('fluentMethod' => function ($proxy) { echo "pre-fluentMethod #{$proxy->counter}!\n"; }),
|
||||
array('fluentMethod' => function ($proxy) { echo "post-fluentMethod #{$proxy->counter}!\n"; })
|
||||
);
|
||||
|
||||
$proxy->fluentMethod()->fluentMethod()->fluentMethod()->fluentMethod();
|
||||
|
||||
echo 'The proxy counter is now at ' . $proxy->counter . "\n";
|
||||
echo 'The real instance counter is now at ' . $foo->counter . "\n";
|
46
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/ghost-object.php
vendored
Normal file
46
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/ghost-object.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use ProxyManager\Factory\LazyLoadingGhostFactory;
|
||||
|
||||
class Foo
|
||||
{
|
||||
private $foo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
public function setFoo($foo)
|
||||
{
|
||||
$this->foo = (string) $foo;
|
||||
}
|
||||
|
||||
public function getFoo()
|
||||
{
|
||||
return $this->foo;
|
||||
}
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$factory = new LazyLoadingGhostFactory();
|
||||
|
||||
for ($i = 0; $i < 1000; $i += 1) {
|
||||
$proxy = $factory->createProxy(
|
||||
'Foo',
|
||||
function ($proxy, $method, $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$proxy->setFoo('Hello World!');
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var_dump('time after 1000 instantiations: ' . (microtime(true) - $startTime));
|
||||
|
||||
echo $proxy->getFoo() . "\n";
|
||||
|
||||
var_dump('time after single call to doFoo: ' . (microtime(true) - $startTime));
|
36
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/remote-proxy.php
vendored
Normal file
36
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/remote-proxy.php
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use ProxyManager\Factory\RemoteObject\Adapter\XmlRpc;
|
||||
use ProxyManager\Factory\RemoteObjectFactory;
|
||||
use Zend\XmlRpc\Client;
|
||||
|
||||
if (! class_exists('Zend\XmlRpc\Client')) {
|
||||
echo "This example needs Zend\\XmlRpc\\Client to run. \n In order to install it, "
|
||||
. "please run following:\n\n"
|
||||
. "\$ php composer.phar require zendframework/zend-xmlrpc:2.*\n\n";
|
||||
|
||||
exit(2);
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function bar()
|
||||
{
|
||||
return 'bar local!';
|
||||
}
|
||||
}
|
||||
|
||||
$factory = new RemoteObjectFactory(
|
||||
new XmlRpc(new Client('http://localhost:9876/remote-proxy/remote-proxy-server.php'))
|
||||
);
|
||||
$proxy = $factory->createProxy('Foo');
|
||||
|
||||
try {
|
||||
var_dump($proxy->bar()); // bar remote !
|
||||
} catch (\Zend\Http\Client\Adapter\Exception\RuntimeException $error) {
|
||||
echo "To run this example, please following before:\n\n\$ php -S localhost:9876 -t \"" . __DIR__ . "\"\n";
|
||||
|
||||
exit(2);
|
||||
}
|
20
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php
vendored
Normal file
20
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Zend\XmlRpc\Server;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function bar()
|
||||
{
|
||||
return 'bar remote!';
|
||||
}
|
||||
}
|
||||
|
||||
$server = new Server();
|
||||
|
||||
$server->setClass(new Foo(), 'Foo');
|
||||
$server->setReturnResponse(false);
|
||||
|
||||
$server->handle();
|
23
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/smart-reference.php
vendored
Normal file
23
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/smart-reference.php
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use ProxyManager\Factory\AccessInterceptorValueHolderFactory;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function doFoo()
|
||||
{
|
||||
echo "Foo!\n";
|
||||
}
|
||||
}
|
||||
|
||||
$factory = new AccessInterceptorValueHolderFactory();
|
||||
|
||||
$proxy = $factory->createProxy(
|
||||
new Foo(),
|
||||
array('doFoo' => function () { echo "pre-foo!\n"; }),
|
||||
array('doFoo' => function () { echo "post-foo!\n"; })
|
||||
);
|
||||
|
||||
$proxy->doFoo();
|
39
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/virtual-proxy.php
vendored
Normal file
39
msd2/phpBB3/vendor/ocramius/proxy-manager/examples/virtual-proxy.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
public function doFoo()
|
||||
{
|
||||
echo "Foo!";
|
||||
}
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$factory = new LazyLoadingValueHolderFactory();
|
||||
|
||||
for ($i = 0; $i < 1000; $i += 1) {
|
||||
$proxy = $factory->createProxy(
|
||||
'Foo',
|
||||
function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrappedObject = new Foo();
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var_dump('time after 1000 instantiations: ' . (microtime(true) - $startTime));
|
||||
|
||||
$proxy->doFoo();
|
||||
|
||||
var_dump('time after single call to doFoo: ' . (microtime(true) - $startTime));
|
Reference in New Issue
Block a user