Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created May 29, 2016 00:44
Show Gist options
  • Save Ocramius/0eb8f58679f2626fcef2f1f6d0c0c598 to your computer and use it in GitHub Desktop.
Save Ocramius/0eb8f58679f2626fcef2f1f6d0c0c598 to your computer and use it in GitHub Desktop.
Example of a piece of code that REQUIRES by-ref property copying (in a safe way)
/**
* @override constructor to setup interceptors
*
* @param \ProxyManagerTestAsset\ClassWithMixedTypedProperties $localizedObject
* @param \Closure[] $prefixInterceptors method interceptors to be used before
* method logic
* @param \Closure[] $suffixInterceptors method interceptors to be used before
* method logic
*/
private function bindProxyProperties(\ProxyManagerTestAsset\ClassWithMixedTypedProperties $localizedObject, array $prefixInterceptors = array(), array $suffixInterceptors = array())
{
$this->publicProperty0 = & $localizedObject->publicProperty0;
$this->publicProperty1 = & $localizedObject->publicProperty1;
$this->publicProperty2 = & $localizedObject->publicProperty2;
$this->protectedProperty0 = & $localizedObject->protectedProperty0;
$this->protectedProperty1 = & $localizedObject->protectedProperty1;
$this->protectedProperty2 = & $localizedObject->protectedProperty2;
\Closure::bind(function () use ($localizedObject) {
$this->privateProperty0 = & $localizedObject->privateProperty0;
}, $this, 'ProxyManagerTestAsset\\ClassWithMixedTypedProperties')->__invoke();
\Closure::bind(function () use ($localizedObject) {
$this->privateProperty1 = & $localizedObject->privateProperty1;
}, $this, 'ProxyManagerTestAsset\\ClassWithMixedTypedProperties')->__invoke();
\Closure::bind(function () use ($localizedObject) {
$this->privateProperty2 = & $localizedObject->privateProperty2;
}, $this, 'ProxyManagerTestAsset\\ClassWithMixedTypedProperties')->__invoke();
$this->methodPrefixInterceptors574a3ae5469d4737887248 = $prefixInterceptors;
$this->methodSuffixInterceptors574a3ae5469e2927605633 = $suffixInterceptors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment