(&mut self, v: Node<'t>, from: u32, depth: u32)
| 1394 | } |
| 1395 | |
| 1396 | fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32) { |
| 1397 | stack_guard!(); |
| 1398 | if depth > 4 { |
| 1399 | return; |
| 1400 | } |
| 1401 | match v.kind() { |
| 1402 | "argument" => { |
| 1403 | for c in v.named_children(&mut v.walk()) { |
| 1404 | self.normalize_fn_ref_value(c, from, depth + 1); |
| 1405 | } |
| 1406 | } |
| 1407 | // String callable — trustworthy ONLY as an argument to a known |
| 1408 | // callable-taking core function; skipGate (resolution's |
| 1409 | // unique-or-drop rule takes over). Namespaced strings drop. |
| 1410 | "string" | "encapsed_string" => { |
| 1411 | let Some(callee) = php_enclosing_call_name(v).map(|f| self.text(f)) else { |
| 1412 | return; |
| 1413 | }; |
| 1414 | if !is_php_callable_hof(callee) { |
| 1415 | return; |
| 1416 | } |
| 1417 | let Some(content) = self.php_string_content(v) else { return }; |
| 1418 | if simple_callable_re().is_match(&content) || qualified_callable_re().is_match(&content) |
| 1419 | { |
| 1420 | self.push_fn_ref_cand(from, &content, v, true); |
| 1421 | } |
| 1422 | } |
| 1423 | // Array callables in ANY call's arguments: `[$this, 'm']` → |
| 1424 | // this.m; `[Foo::class, 'm']` → Foo::m; `['Cls', 'm']` → nothing. |
| 1425 | "array_creation_expression" => { |
| 1426 | if v.named_child_count() != 2 { |
| 1427 | return; |
| 1428 | } |
| 1429 | let recv = v.named_child(0).and_then(|e| e.named_child(0)); |
| 1430 | let str_el = v.named_child(1).and_then(|e| e.named_child(0)); |
| 1431 | let (Some(recv), Some(str_el)) = (recv, str_el) else { return }; |
| 1432 | if !matches!(str_el.kind(), "encapsed_string" | "string") { |
| 1433 | return; |
| 1434 | } |
| 1435 | let Some(member) = self.php_string_content(str_el) else { return }; |
| 1436 | if !simple_callable_re().is_match(&member) { |
| 1437 | return; |
| 1438 | } |
| 1439 | if recv.kind() == "variable_name" && self.text(recv) == "$this" { |
| 1440 | let name = format!("this.{member}"); |
| 1441 | self.push_fn_ref_cand(from, &name, str_el, false); |
| 1442 | } else if recv.kind() == "class_constant_access_expression" { |
| 1443 | let cls = recv.named_child(0); |
| 1444 | let kw = recv.named_child(1); |
| 1445 | if let (Some(cls), Some(kw)) = (cls, kw) { |
| 1446 | if self.text(kw) == "class" { |
| 1447 | let name = format!("{}::{member}", self.text(cls)); |
| 1448 | self.push_fn_ref_cand(from, &name, str_el, false); |
| 1449 | } |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | _ => {} |
no test coverage detected