I am hoping that someone can explain this behavior, as I find it pretty aggravating. I have a parent class with an OnMissingMethod implementation to provide implicit getters/setters (old CF8 application)
if I instantiate the child class as foo and call foo.getBar() from an external file, it successfully triggers OnMissingMethod, but if within the foo class itself I call getBar() it doesn't. The only way it will trigger OnMissingMethod is if I use this.getBar() which I don't like for aesthetic and code inconsistency reasons.
tldr; here is a code example... try it yourself.
Foo.cfc
<cfcomponent output="false" extends="Parent">
<cffunction name="init" output="false" returntype="Foo">
<cfreturn this />
</cffunction>
<cffunction name="getInternalBar_workie">
<cfreturn this.getBar() />
</cffunction>
<cffunction name="getInternalBar_noworkie">
<cfreturn getBar() />
</cffunction>
</cfcomponent>
Parent.cfc
<cfcomponent output="false">
<cffunction name="OnMissingMethod">
<!--- always return true for this example --->
<cfreturn true />
</cffunction>
</cfcomponent>
foobar.cfm
<cfset foo = CreateObject( "component", "Foo").init() />
<!--- this works --->
<cfdump var="#foo.getBar()#" /><br/>
<!--- this works --->
<cfdump var="#foo.getInternalBar_workie()#" /><br/>
<!--- this fails --->
<cfdump var="#foo.getInternalBar_noworkie()#" />
Can anyone explain why the 'this' scope must be used for OnMissingMethod to work properly when calling from the class itself? Is there a better workaround?