mirror of
https://github.com/safishamsi/graphify.git
synced 2026-10-13 23:49:14 +00:00
fix(php): prevent closure fallback leak and support fluent routing prefixes
This commit is contained in:
1 parent
9d592e6996
commit
b8e2033e3c
1 file changed
+16
-1
@@ -3500,6 +3500,21 @@ def _php_get_route_name(closure_node, src: bytes) -> str | None:
|
||||
if path_text is not None and path_text.startswith("/"):
|
||||
prefixes.append(path_text)
|
||||
|
||||
# Process any fluent method chain prefixes on the same statement
|
||||
fluent = call.child_by_field_name("object")
|
||||
while fluent is not None and fluent.type == "member_call_expression":
|
||||
f_args = fluent.child_by_field_name("arguments")
|
||||
if f_args:
|
||||
for c in f_args.children:
|
||||
if c.type == "argument":
|
||||
for cc in c.children:
|
||||
if cc.type in ("string", "encapsed_string"):
|
||||
f_path = _read_text(cc, src).strip("'\"")
|
||||
if f_path.startswith("/"):
|
||||
prefixes.append(f_path)
|
||||
break
|
||||
fluent = fluent.child_by_field_name("object")
|
||||
|
||||
curr = call.parent
|
||||
continue
|
||||
|
||||
@@ -4995,7 +5010,7 @@ def _extract_generic(
|
||||
func_name = _read_text(name_node, source) if name_node else None
|
||||
|
||||
if not func_name:
|
||||
if t in ("anonymous_function", "arrow_function"):
|
||||
if config.ts_module == "tree_sitter_php" and t in ("anonymous_function", "arrow_function"):
|
||||
route_name = _php_get_route_name(node, source)
|
||||
if route_name:
|
||||
func_name = route_name
|
||||
|
||||
Reference in new issue
Block a user