如果尝试获取所有方法/函数,并在必需参数之前分配可选参数,请尝试使用此正则表达式(单行)
<?php
function\s+[a-z][a-zA-Z0-9_]*\((?:\$[a-z][a-zA-Z0-9_]*\s*,\s*)*
(?:\$[a-z][A-Za-z0-9_]*\s*=[^\$\)]+)+\$[a-z][a-zA-Z0-9_]*\)
?>
for
<?php
public function test($a, $b) {
$a = [];
$b = [$abc => $ss[],
];
}
private function too($c, $a = true, $b) {
}
protected function bar($a = []) {
}
public function foo($a, $b = true) {
}
public function fooBar32($a=true, $b = [], $c) {
}
private function oo_bAr($a = []) {
}
?>
它将匹配 too() 和 fooBar32()
祝您迁移愉快!;)