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
Advice: handling dynamically created instance var values #1753
Comments
#805 would need to be done first. After it was completed, it might be possible to write a plugin to type check the inner body of the template. |
I'm not really bothered about the type safety of the values passed to the template engine because the templates themselves aren't php, I'd just prefer not to have (lots of!) warnings about references to undeclared properties on this one particular class which is the 'view' class. |
You can also write your own plugin to just suppress undeclared property issues for the given issues. Resources:
An alternative would be to add a way to specify that user-defined classes have arbitrary dynamic properties and to give up on warning about them (Phan does this if |
Interestingly, my view class inherits from a parent that does have |
It's been a while since I've looked at the magic property code. It turns out that \Phan\Language\Element\Clazz->getPropertyByNameInContext() only checks for __get() (unconditionally). There was a TODO for that.
Checking if the parent node was an assignment (to determine if __get()/__set() should be checked for) would be the proper way to do this check |
thanks for your reply :) Adding a |
Closing this and opening #1756 to track the code fixes I mentioned |
I'm updating some existing code to allow it to be checked with Phan and I have a template engine which allows you to set (using magic methods) values on, effectively, dynamically created instance vars. e.g.
Where
foo
andbaa
are then used in the template and are not pre-defined anywhere.Is there a way to effectively tell Phan about this kind of behaviour on a class?
Thanks!
The text was updated successfully, but these errors were encountered: