Augmentation vers version 3.3.0

This commit is contained in:
Gauvain Boiché
2020-03-31 15:31:03 +02:00
parent d926806907
commit a1864c0414
2618 changed files with 406015 additions and 31377 deletions

View File

@@ -1,3 +1,7 @@
---
title: Access Interceptor Value Holder Proxy
---
# Access Interceptor Value Holder Proxy
An access interceptor value holder is a smart reference proxy that allows you to dynamically
@@ -35,8 +39,8 @@ $factory = new Factory();
$proxy = $factory->createProxy(
new Foo(),
array('doFoo' => function () { echo "PreFoo!\n"; }),
array('doFoo' => function () { echo "PostFoo!\n"; })
['doFoo' => function () { echo "PreFoo!\n"; }],
['doFoo' => function () { echo "PostFoo!\n"; }]
);
$proxy->doFoo();
@@ -54,10 +58,8 @@ PostFoo!
A proxy produced by the
[`ProxyManager\Factory\AccessInterceptorValueHolderFactory`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Factory/AccessInterceptorValueHolderFactory.php)
implements both the
[`ProxyManager\Proxy\ValueHolderInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/ValueHolderInterface.php)
and the
[`ProxyManager\Proxy\AccessInterceptorInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/ValueHolderInterface.php).
implements the
[`ProxyManager\Proxy\AccessInterceptorValueHolderInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/AccessInterceptorValueHolderInterface.php).
Therefore, you can set an access interceptor callback by calling:
@@ -68,7 +70,7 @@ $proxy->setMethodSuffixInterceptor('methodName', function () { echo 'post'; });
You can also listen to public properties access by attaching interceptors to `__get`, `__set`, `__isset` and `__unset`.
A prefix interceptor (executed before method logic) should have following signature:
A prefix interceptor (executed before method logic) should have the following signature:
```php
/**
@@ -85,7 +87,7 @@ A prefix interceptor (executed before method logic) should have following signat
$prefixInterceptor = function ($proxy, $instance, $method, $params, & $returnEarly) {};
```
A suffix interceptor (executed after method logic) should have following signature:
A suffix interceptor (executed after method logic) should have the following signature:
```php
/**
@@ -103,6 +105,13 @@ A suffix interceptor (executed after method logic) should have following signatu
$suffixInterceptor = function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) {};
```
## Known limitations
* methods using `func_get_args()`, `func_get_arg()` and `func_num_arg()` will not function properly
for parameters that are not part of the proxied object interface: use
[variadic arguments](http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list)
instead.
## Tuning performance for production
See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md).
See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md).