Custom static function with parameter hints.
-
I’m trying to add some custom functions to the php.xml file so parameter hints can be available.
With normal functions it works fine:<KeyWord name=“myFunction” func=“yes”>
<Overload retVal=“string”>
<Param name=“string sValue”/>
<Param name=“bool bValue”/>
</Overload>
</KeyWord>if i type “myFunction(” in a php file, the parameter hints show up perfectly.
But when i add a static function:
<KeyWord name=“myClass::myStaticFunction” func=“yes”>
<Overload retVal=“string”>
<Param name=“string sValue”/>
<Param name=“bool bValue”/>
</Overload>
</KeyWord>It doesnt seem to work. I expected when i type “myClass::myStaticFunction(” parameter hints would show up… but they dont. Howcome?
-
@Martijn-Wieringa said:
they don’t. How come?
I believe it’s because
::
are not “word characters”. The Settings > Preferences > Delimiters is supposed to allow you to specify extra characters, but it doesn’t always work right. (I just tried in this case, but couldn’t get it to work.)It also might mess up the sorting: I know that when I was looking at the new copy of the auto-completion documentation, I learned that you must properly sort the
<KeyWord>
tags, otherwise they will not be recognized. But even when sorted correctly (as far as I could tell), I couldn’t get it to work with::
in it.Not tested, but you might want to try having a non-function auto-complete entry for the full
<KeyWord name="myClass::myStaticFunction" />
, and then a yes-function entry for thename="myStaticFunction"
with the complete overload/param definition. I don’t know if it will work, but it’s worth a try. Or just not include themyClass::
prefix at all (or make the non-function entry just bemyClass::
, and the full definition the yes-function version. (If your reason for not wanting to do that was that different classes uses different parameter lists for the same function, you may be able to use multiple<Overload>
tags for the same function. -
I thought it had something to do with ::
Based on your info, i now use this workaround:<KeyWord name=“myStaticFunction” func=“yes”>
<Overload retVal=“myClass | string”>
<Param name=“string sValue”/>
<Param name=“bool bSort”/>
</Overload>
<Overload retVal=“myClass2 | string”>
<Param name=“string sValue”/>
<Param name=“bool bSort”/>
</Overload>
<Overload retVal=“myClass3 | array”>
<Param name=“string sValue”/>
<Param name=“bool bSort”/>
</Overload>
</KeyWord>I’ve added "myClassName | " before each return value so i can easily find the parameter list i need for given class…
it’s not as perfect as it could/should be, but it will work for now. Hopefully they’ll make a fix in the future ;)Thanks for your help!