You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you generate a AccessInterceptorValueHolder proxy, a E_USER_NOTICE is always triggered when a property is not defined on the class, even if the that class has a __get-method.
This is caused by the getPublicAccessSimulationCode call here:
And lastly the AccessInterceptorScopeLocalizer also doesn't give a notice about a undefined property (although it does cause, "Notice: Only variables should be assigned by reference")
useProxyManager\Factory\AccessInterceptorScopeLocalizerFactory;
useProxyManager\Factory\AccessInterceptorValueHolderFactory;
useProxyManager\Factory\LazyLoadingValueHolderFactory;
error_reporting(E_ALL);
class TestGet {
publicstring$notViaGet = 'not via __get';
publicfunction__get(string$name): string
{
return$name;
}
}
// Class directly// These don't give a noticeecho (newTestGet())->notViaGet, PHP_EOL;
echo (newTestGet())->thisShouldNotGiveANotice, PHP_EOL;
// LazyLoadingValueHolder$lazyProxy = (newLazyLoadingValueHolderFactory())->createProxy(TestGet::class,
function (&$wrappedObject, $proxy, $method, $parameters, &$initializer) {
$wrappedObject = newTestGet();
$initializer = null;
returntrue;
}
);
// Neither do theseecho$lazyProxy->notViaGet, PHP_EOL;
echo$lazyProxy->thisShouldNotGiveANotice, PHP_EOL;
// AccessInterceptorValueHolder$interceptorValueProxy = (newAccessInterceptorValueHolderFactory())->createProxy(
newTestGet(),
);
// No noticeecho$interceptorValueProxy->notViaGet, PHP_EOL;
// But this one does give a notice: "Notice: Undefined property: TestGet::$thisShouldNotGiveANotice"echo$interceptorValueProxy->thisShouldNotGiveANotice, PHP_EOL;
// AccessInterceptorScopeLocalizer$interceptorScopeProxy = (newAccessInterceptorScopeLocalizerFactory())->createProxy(
newTestGet(),
);
// This results in "Notice: Only variables should be assigned by reference"echo'$interceptorScopeProxy->thisDoesNotGiveANotice', PHP_EOL;
The text was updated successfully, but these errors were encountered:
When you generate a AccessInterceptorValueHolder proxy, a
E_USER_NOTICE
is always triggered when a property is not defined on the class, even if the that class has a__get
-method.This is caused by the
getPublicAccessSimulationCode
call here:ProxyManager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGet.php
Line 39 in dbcdf2c
And results in something like:
In contrast, the LazyLoadingValueHolder's
__get
-proxy does check for the parent and skips the call togetPublicAccessSimulationCode
ProxyManager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGet.php
Line 41 in dbcdf2c
And lastly the AccessInterceptorScopeLocalizer also doesn't give a notice about a undefined property (although it does cause, "Notice: Only variables should be assigned by reference")
ProxyManager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGet.php
Line 33 in dbcdf2c
Here is some test code:
The text was updated successfully, but these errors were encountered: