MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / visit_for_calls_and_structure

Method visit_for_calls_and_structure

codegraph-kernel/src/php.rs:618–682  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

616 }
617
618 fn visit_for_calls_and_structure(&mut self, node: Node<'t>) {
619 stack_guard!();
620 let kind = node.kind();
621 self.maybe_capture_fn_refs(node);
622
623 // A `require`/`include` in a body includes its file there, so the
624 // function depends on it (#3296), as visitForCallsAndStructure does.
625 // Its children are still walked below.
626 if matches!(
627 kind,
628 "include_expression" | "include_once_expression" | "require_expression"
629 | "require_once_expression"
630 ) {
631 self.extract_import(node);
632 }
633
634 if matches!(
635 kind,
636 "function_call_expression" | "member_call_expression" | "scoped_call_expression"
637 ) {
638 self.extract_call(node);
639 } else if kind == "object_creation_expression" {
640 self.extract_instantiation(node);
641 if let Some(anon_body) = find_anonymous_class_body(node) {
642 self.extract_anonymous_class(node, anon_body);
643 return;
644 }
645 }
646
647 // Static value reads (`Cls::CONST`, `Cls::$prop`, `Cls::class`).
648 self.extract_static_member_ref(node);
649
650 // Nested NAMED functions; body-level class/trait/enum/interface
651 // declarations (the polyfill idiom). NOTE: no method_declaration
652 // branch — in-body anonymous-class methods vanish (delta #1), and the
653 // visitNode hook does NOT run here (a const_declaration in a body-level
654 // class still extracts via extractClass's own visitNode body walk).
655 if kind == "function_definition" {
656 let name = self.extract_name(node);
657 if name != "<anonymous>" {
658 self.extract_function(node);
659 return;
660 }
661 }
662 if kind == "class_declaration" {
663 self.extract_class(node, "class");
664 return;
665 }
666 if kind == "trait_declaration" {
667 self.extract_class(node, "trait");
668 return;
669 }
670 if kind == "enum_declaration" {
671 self.extract_enum(node);
672 return;
673 }
674 if kind == "interface_declaration" {
675 self.extract_interface(node);

Callers 1

visit_function_bodyMethod · 0.45

Calls 13

maybe_capture_fn_refsMethod · 0.45
extract_importMethod · 0.45
extract_callMethod · 0.45
extract_instantiationMethod · 0.45
extract_nameMethod · 0.45
extract_functionMethod · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45
extract_interfaceMethod · 0.45

Tested by

no test coverage detected