Commit Graph
5 Commits
Author SHA1 Message Date
safishamsiandClaude Opus 4.8 793aca6714 test(php): cover file-scope, no-duplicate, and method-scope closures (#3409/#3461 follow-up)
#3461 fixes #3409 (PHP closures produce no nodes / inner calls lost). Adds the
coverage its tests omitted:
- the reporter's exact repro — a FILE-SCOPE argument-position closure — asserting
  the closure node exists AND its inner call resolves to the closure (not the file);
- a no-duplicate-node assertion guarding the walk partition against double-walk;
- a method-scope closure asserting its inner call attributes to the closure, not
  the enclosing method (pins the function_boundary_types behavior).

Verified end-to-end: closure->handler() edges attribute to {closure#N} nodes with
no duplicates.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-09-23 19:45:40 +01:00
nikhil2004 95dd8cf9a0 fix(php): allow relative prefixes in route groups and correctly fail tests on extractor error
(cherry picked from commit 29ed19f1e4)
2026-09-23 19:42:04 +01:00
nikhil2004 8227c468c2 fix(extract): robust PHP nested routing closure extraction (#3409)
Address edge cases identified in review:
- Nested route closures (e.g., inside group() or prefix()) now correctly compose their full path by walking up the AST across closure boundaries.
- Non-routing closures passed to methods that share verbs (like ->get('user:42')) are no longer misidentified as routes. A route path must begin with '/' to qualify, otherwise it correctly falls back to an ordinal name.

(cherry picked from commit 38861aa1c4)
2026-09-23 19:34:18 +01:00
nikhil2004 2c172e4969 fix(extract): stable closure naming for PHP (#3409)
Address reviewer feedback:
- Replace line-based {closure@N} names with stable ordinal {closure#N}
  names scoped per enclosing class or file. Ordinals are unaffected by
  line insertions/deletions above a closure; only reordering closures
  or inserting one earlier in the same scope shifts later ordinals,
  which is a much rarer edit.
- Route closures passed to routing verbs (get/post/put/patch/delete/
  options/any/match/map) receive a semantic 'VERB /path' label that
  is both stable and directly meaningful to graph queries (the primary
  use-case from the issue).

Note: adding anonymous_function_creation_expression and arrow_function
to function_boundary_types (introduced in the first commit) means calls
inside a closure now attribute to the closure rather than the enclosing
named function. This is the correct behaviour; existing codebases with
closures inside named functions will see those edges move on next
incremental update.

(cherry picked from commit 5400b9cbd7)
2026-09-23 19:34:18 +01:00
nikhil2004 cd3fd9436e feat(extract): support PHP closures (#3409)
The bug:
PHP closures (`anonymous_function_creation_expression` and `arrow_function`)
were invisible to the graph, disconnecting API routes and callbacks from
the backend code.

The fix:
- Added closure syntax node types to _PHP_CONFIG's `function_types`.
- Updated engine.py to synthesize line-bound names (e.g., `{closure@42}`)
  for unnamed closures matching these AST node types, enabling them to be
  extracted as linkable nodes in the graph without ID collisions.

(cherry picked from commit c8c3af1960)
2026-09-23 19:34:18 +01:00