Skip to content

[Feature]: Class/method scoping for trace command in PHP (other OOP languages) #212

@dzmitry-vasileuski

Description

@dzmitry-vasileuski

Problem Statement

The trace callees and trace callers commands work at the symbol name level only, with no way to scope a symbol to a class, namespace, or file. This makes the feature nearly unusable for PHP where:

  • Almost all code lives inside classes
  • Common method names like execute, handle, run, boot exist across dozens of unrelated classes
  • Targeting a class name returns 0 callees — the class is found, but its methods are not walked

Reproduction with a PHP codebase:

Finds the class but returns 0 callees
grepai trace callees "CreateDiscountAction" --mode precise

Returns 640 results across completely unrelated classes
grepai trace callees "execute" --mode precise

Not recognized — no qualified symbol syntax supported
grepai trace callees "CreateDiscountAction::execute" --mode precise
grepai trace callees "CreateDiscountAction@execute" --mode precise

Proposed Solution

Support qualified symbol syntax using Class::method:

grepai trace callees "CreateDiscountAction::execute"
grepai trace callers "DiscountService::create"

This is the most natural fit — :: is already how PHP refer to class methods. No new flags needed, just symbol name parsing that splits on :: and scopes the method lookup to the matching class.

Alternatives Considered

--file flag — scope the symbol to a specific file or glob:

grepai trace callees "index" --file "app/Http/Controllers/UserController.php"
grepai trace callees "handle" --file "app/Jobs/**"

Works, but requires knowing the file path upfront and is more verbose. Would still be a useful complementary addition.

--class flag — explicit class scoping:

grepai trace callees "execute" --class "CreateUserAction"
or with full namespace:
grepai trace callees "execute" --class "App\Actions\CreateUserAction"

Clean, but adds a new flag. The inline Class::method syntax feels more natural for day-to-day use.

Category

Search / Indexing

Additional Context

For Go or Python with uniquely named top-level functions, trace works great. The limitation only surfaces in OOP-heavy codebases where method names are scoped to classes by design. Supporting Class::method (or Class@method for languages that use @) would make trace as useful for PHP/Java projects as it currently is for Go.

Contribution

  • I would be willing to contribute this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions