Is there a way to block or intercept setting `this...
# cfml-general
n
Is there a way to block or intercept setting
this
-scoped variables in a component from outside the component (in ACF2023)? I want to enable implicit accessors on the component, but it would be nice to enforce some protection against something like
MyComponent.MisspelledProperty = "xyz"
from working. By default, CF just sets
this.MisspelledProperty = "xyz"
in this situation. (Of course, well-written functions and unit testing will help.)
b
Those are two different scopes, aren't they? Access to the
this
scope is public. Whereas
MyComponent.MisspelledProperty = "xyz
defines a static variable. It is your choice to use variables defined in these scopes. Surely, rather than block or intercept them, the best option is to choose not to use them at all. 🙂 It can also be that I don't understand what you mean.
👍 1