无论出于何种原因(对或错),我们都有一个函数声明,例如:
<cffunction name="findaccount" access="public" returntype="struct">
<cfargument name="roles" type="numeric" required="true" default="1">
...
</cffunction>
然后调用该函数
<cfinvoke method="findaccount" returnvariable="stAccountDetails">
<cfinvokeargument name="roles" value="1,2">
</cfinvoke>
不管将列表传递给期望数字的函数的初衷,这段代码已经在 CF9 中工作了很长时间。最近我们决定升级到CF11,代码抛出如下异常:
Detail: If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible.
Message: The ROLES argument passed to the findaccount function is not of type numeric.
搜索时,我在这里发现了类似的问题。我的问题是:考虑到有很多这样的调用,对我的案例进行类型检查(如 Adam Cameron 建议的那样)是不是最好的解决方法?