Function list with PHP with abstract functions
-
I use function list with PHP files with abstract class.
But abstract functions are not shown in the tree view.
I have try to fix the functionList.xml file but a round bracket left in each class member in the treeview like : “GetPresentation(” instead of “GetPresentation”
Sample of abstract class and function in php
abstract class PageZZZ extends PageAAA { abstract public function GetPresentation(); function MetaCSS() { return '<link rel="stylesheet" type="text/css" href="zzz.css" media="all" >'; } }in order to view GetPresentation in the function list i have done that in function list :
In the parser php_function > classRange > function
I replace
<function mainExpr="^\s*((static|public|protected|private|final)*(\s+(static|public|protected|private|final))+\s+)?(function\s+)+(\w+(\s+\w+)?(\s+|\*\s+|\s+\*|\s+\*\s+))?(\w+\s*::)?(?!(if|while|for|switch))[\w~]+\s*\([^\{]*\{" > <functionName> <funcNameExpr expr="(?!(if|while|for|switch))\w+\s*\([^\{]*" /> <!-- comment out the following node to display the method with parameters --> <funcNameExpr expr="(?!(if|while|for|switch))\w+" /> </functionName> </function>by
<function mainExpr="^[\s]*((abstract|static|public|protected|private|final)\s+)*(function)\s+([\w]+[\w\d_]*)\s*\(" > <functionName> <funcNameExpr expr="(?!(abstract|static|public|protected|private|final)function)[\w_]+[\s]*\(" /> <!-- comment below node if want display method with parmas <funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/> --> </functionName> </function>it’s seem to work but an additionnal “(” appear.
-
Hello, Florent,
The solution consists to change the end of the
exprattribute but a positive look-ahead ,(?=\(), instead of the\(form !So expr=
"(?!(abstract|static|public|protected|private|final)function)[\w_]+[\s]*(?=\()"
Secondly, I try to simplify, a bit, your two regexes :
-
The
\s,\d,\wcan be written, outside a class character. So, for instance, the syntax\s*is strictly equivalent to the[\s]*one ! -
The
\wsyntax is a single word character, and is equivalent to the class character[\d_\u\l. That is to say it represents any single digit OR the underscore character OR any upper-case letter, accentuated or not OR any lower-case letter, accentuated or not -
I also deleted some round brackets couples as they create groups, which are not used later on, anyway !
-
Finally, I suppose, like in most languages, that the first character of a function name must be a letter or an underscore ( Thanks to MAPJe71 ) and all the other characters, of the name, are, simply, word characters
If so, the mainExpr attribute can be simplified into :
^\s*((abstract|static|public|protected|private|final)\s+)*function\s+[\u\l_]\w*\s*\(And the expr attribute is, simply :
(?!(abstract|static|public|protected|private|final)function)\w+\s*(?=\()Best Regards,
guy038
-
-
First character of a function name can also be an underscore.
-
Thanks guy038 and MAPJe71 for this precious help.
It’s works geat.
In addition,
constructors are like :
function __construct() { ... }So MAPJe71 is right a function can start with “_”
According to that remark, i change [\u\l] to [\u\l_] in mainExpr :
mainExpr="^\s*((abstract|static|public|protected|private|final)\s+)*function\s+[\u\l_]\w*\s*\("REM : The functionListxml in the 7.2.2 zip file containts really different RE
<function mainExpr="^\s*((static|public|protected|private|final)*(\s+(static|public|protected|private|final))+\s+)?(function\s+)+(\w+(\s+\w+)?(\s+|\*\s+|\s+\*|\s+\*\s+))?(\w+\s*::)?(?!(if|while|for|switch))[\w~]+\s*\([^\{]*\{" > <functionName> <funcNameExpr expr="(?!(if|while|for|switch))\w+\s*\([^\{]*" /> <!-- comment out the following node to display the method with parameters --> <funcNameExpr expr="(?!(if|while|for|switch))\w+" /> </functionName> </function> -
The functionListxml in the 7.2.2 zip file containts really different RE
That’s correct and it will change in the near future.
-
Florent and MAPJe71,
Thanks to you, both, for this this precision ! So, I’ve just updated my previous mail !
And, after added your last example function __construct() { … }, in a new PHP file, the
__constructfunction does appear, too, in the FunctionList panel :-)Cheers,
guy038
BTW, I don’t know the PHP language, at all, but, about regexes, up to now, I can manage ;-))
-
Nice!
RE seem to be so powerful.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login