-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing non-nullable properties for AccessInterceptorScopeLocalizer #683
Comments
@petr-buchin A runtime reflection call at instantiation, if needed, needs to be baked into the generated code. |
@Ocramius thanks for quick answer. Probably this logic may be baked into the generated code, if needed. But what do you think about the proposed solution? If you agree with the solution itself, I could try to implement it. |
Adding a runtime object to the Adding code to the generated named constructors is feasible, but we need an extensive integration test verifying that it works as expected. |
@Ocramius thanks, I'll try to implement it along with tests and create a PR |
@petr-buchin please do start from integration test and build a PoC starting from there, even if quick & dirty. Do not start from the sources, but really do start from the test suite, by adding a class that looks like what you are trying to proxy, and making it work from there (even by having other tests failing, as a start). |
@Ocramius no problems, I'll go with TDD here, thanks! |
This is a follow up on #682.
After doing some research, I realized that enabling AccessInterceptorScopeLocalizer to work with non-nullable properties is pretty straightforward.
For now checking for non-accessible properties looks like follows in class
Properties
:To fix this behavior and allow non-nullable properties on objects being proxied, this code can be changed to something like follows:
This code allows to proxy objects with non-nullable properties and moves responsibility of initializing properties to the user of this library.
However, the problem is that classes
Properties
andBindProxyProperties
does not have access to the object being proxied, thus cannot use methodReflectionProperty::isInitialized()
.It's possible to pass the instance of an object being proxied to this classes, but that would require changing signatures of some interface methods, and that would be a BC break.
I was thinking about using a temporary workaround (before next major release), such as
ProxyContext
class with static property, likeProxyContext::$objectBeingProxied
, that would allow classes likeBindProxyProperties
to have access to the object being proxied without changing interfaces, but that is admittedly clunky.@Ocramius do you have any thoughts on this?
The text was updated successfully, but these errors were encountered: