Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1870aa6289
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Extends the internal PhoundPlugin SQLite output to include symbol signature metadata (signatures + parameter details) so external tools can do offline/instant lookups without requiring the Phan daemon.
Changes:
- Adds
signaturesandparameterstables (plus indexes) to the Phound SQLite schema. - Updates finalization to accept
CodeBaseand writes signature/parameter rows at finalization time. - Inserts user-defined function/method/property/constant signature data (skipping PHP-internal elements).
| if (!self::$db->exec('CREATE INDEX signatures_name ON signatures (name)')) { | ||
| throw new Exception("Failed to create index signatures_name"); | ||
| } | ||
| if (!self::$db->exec('CREATE INDEX signatures_class ON signatures (class_fqsen)')) { | ||
| throw new Exception("Failed to create index signatures_class"); | ||
| } | ||
| if (!self::$db->exec('CREATE INDEX signatures_filepath ON signatures (filepath)')) { |
There was a problem hiding this comment.
finalizeProcess() creates the signatures_* indexes unconditionally. In daemon mode (or any scenario where finalizeProcess() runs more than once in the same PHP process) the static DB handle is reused without dropping tables, so these CREATE INDEX statements will fail with "index already exists" and abort the request. Use CREATE INDEX IF NOT EXISTS ..., or move index creation to the same place tables are (re)created/dropped so it only runs once per DB rebuild.
| if (!self::$db->exec('CREATE INDEX signatures_name ON signatures (name)')) { | |
| throw new Exception("Failed to create index signatures_name"); | |
| } | |
| if (!self::$db->exec('CREATE INDEX signatures_class ON signatures (class_fqsen)')) { | |
| throw new Exception("Failed to create index signatures_class"); | |
| } | |
| if (!self::$db->exec('CREATE INDEX signatures_filepath ON signatures (filepath)')) { | |
| if (!self::$db->exec('CREATE INDEX IF NOT EXISTS signatures_name ON signatures (name)')) { | |
| throw new Exception("Failed to create index signatures_name"); | |
| } | |
| if (!self::$db->exec('CREATE INDEX IF NOT EXISTS signatures_class ON signatures (class_fqsen)')) { | |
| throw new Exception("Failed to create index signatures_class"); | |
| } | |
| if (!self::$db->exec('CREATE INDEX IF NOT EXISTS signatures_filepath ON signatures (filepath)')) { |
| /** | ||
| * Write function/method signatures and parameters to the database. | ||
| * Includes inherited/trait members so FQSENs for user-defined elements in callsites generally have a matching signature row. | ||
| * @throws Exception |
There was a problem hiding this comment.
The PR description says inherited elements are skipped (based on getDefiningFQSEN()), but writeSignatures() is documented/implemented to include inherited/trait-provided members via get*MapByFullyQualifiedClassName(). Please reconcile this (update the PR description or change writeSignatures() to match the described behavior).
Extends the PhoundPlugin's SQLite database with two new tables:
signaturesandparametersThese store function/method signatures, property types, constant types, and parameter details for all user-defined code elements.
This enables external tools to perform instant signature lookups from the Phound database without requiring the Phan daemon to be running.
See #5459 for one such external tool.
Changes
signaturestable: Stores FQSEN, kind (function/method/property/constant), class FQSEN, name, return/property type, static flag, visibility, file path, line number, and docblockparameterstable: Stores FQSEN, parameter index, name, type, variadic/reference/optional flags, and default value representationsignatures_name(for name-based search) andsignatures_class(for class-scoped queries)finalizeProcess()now acceptsCodeBaseparameter and callswriteSignatures()after relationship flatteningWhat gets stored
getFunctionMap())isPHPInternal()elementsgetDefiningFQSEN()class differs from current class)Example queries