関数リストのnotepad ++からの関数リストプラグインは正しく機能していますが、関数名はfor/while/ifで始まります。メモ帳++関数リスト関数名がreserverd wordsで始まる場合、PHPが動作しません。
たとえば、私はフォームクラスの関数を持っています。つまり、「フォーム」(form_informationなど)から始まります。 関数名は 'for'で始まるので、関数名は関数リストには表示されません。
誰かが同じ問題を抱えているのでしょうか、それともこの正規表現の解決策ですか?
これは、PHP関数リストの正規表現とxmlです。
<parser id="php_function" displayName="PHP" commentExpr="((/\*.*?\*)/|(//.*?$))">
<classRange
mainExpr="^[\s]*(class|abstract[\s]+class|final[\s]+class)[\t ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*([\s]*|[\s]*(extends|implements|(extends[\s]+(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+[\s]+implements))[\s]+(\,[\s]*|(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))+[\s]*)?\{"
openSymbole = "\{"
closeSymbole = "\}"
displayMode="node">
<className>
<nameExpr expr="(class|abstract[\s]+class|final[\s]+class)[\s]+[\w]+"/>
<nameExpr expr="[\s]+[\w]+\Z"/>
<nameExpr expr="[\w]+\Z"/>
</className>
<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 below node if want display method with parmas -->
<funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/>
</functionName>
</function>
</classRange>
<function
mainExpr="^[\s]*function[\s]+\w+\("
displayMode="$className->$functionName">
<functionName>
<nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
<nameExpr expr="(?!(if|while|for))[\w_]+"/>
</functionName>
<className>
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
</className>
</function>
お時間をいただき、ありがとうございます!
'(?if(while | for | switch))')を '(?while | forスイッチ)\ b)'に変更し、 '(? )) 'yo'(?!(while | for)\ b) '..それはあなたを助けるかもしれません。 – ClasG
ありがとうございました!それも私のために働いた:) –