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
Look at this code, which is some kind of "default value initializer" for a property.
This is used in my development of a framework including some getters that read linked data on the fly : the property value is read from the DAO only when someone want to read it.
The example above is a simplified version of what I do, with a static initialization.
But now I replace my echo by something more complicated. In some cases I need call-by-reference. Remove the echo and replace it with it :
functionpropDisplay(&$prop)
{
echoprint_r($prop, true);
}
$object = newClassy();
propDisplay($object->prop);
// Should display the same :// array(0 => my, 1 => default, 2 => values)// Will display :// nothing !
In this case the advice is not called on propDisplay($object->prop) call, because the value of the property is not read by PHP, but it's reference is sent to the called function.
When inside the function, I do not access to a property but to a local variable, and the hook does not work. propInit() will never be called in this case.
My workaround :
$object->prop;
propDisplay($object->prop);
But I have to think about it each time I call a function that awaits references... not very transparent.
What answer should you provide ?
If possible, please make AOP joinpoints work when I call propDisplay($object->prop), even if the parameters are passed by reference. Could you do that ?
The text was updated successfully, but these errors were encountered:
Look at this code, which is some kind of "default value initializer" for a property.
This is used in my development of a framework including some getters that read linked data on the fly : the property value is read from the DAO only when someone want to read it.
The example above is a simplified version of what I do, with a static initialization.
But now I replace my echo by something more complicated. In some cases I need call-by-reference. Remove the echo and replace it with it :
In this case the advice is not called on propDisplay($object->prop) call, because the value of the property is not read by PHP, but it's reference is sent to the called function.
When inside the function, I do not access to a property but to a local variable, and the hook does not work. propInit() will never be called in this case.
My workaround :
But I have to think about it each time I call a function that awaits references... not very transparent.
What answer should you provide ?
If possible, please make AOP joinpoints work when I call propDisplay($object->prop), even if the parameters are passed by reference. Could you do that ?
The text was updated successfully, but these errors were encountered: