accuracy(PHP): measure import graph accuracy and close gaps below 90%
Part of #237.
Starting estimate: 50-70% recall. This is an unmeasured guess.
Measure
Run codemap on real PHP repositories at pinned commits and compare it to ground truth.
- Suggested ground truth: Composer classmap plus use statements.
- Report: recall, precision, and whether the coverage status was honest for each file.
Likely gaps to check
Composer PSR-4 autoloading, use statements, whether coverage wrongly reads complete.
Done when
- Repositories, commits, method and numbers are recorded here.
- Each miss has a root cause.
- Recall is at or above 90%, or the remaining gap is one codemap cannot close and its coverage status says so.
codemap 4.6.3 import graph accuracy: PHP (#245)
Repos (shallow clones, never executed; only includes php):
- Seldaek/monolog @ 3bed304b1905fed5c30d172872f4d890cbb03c6a (Composer PSR-4
Monolog\ => src/Monolog, 228 .php) - PHPMailer/PHPMailer @ c0b5268a626d6ddbe71333cc1c60c5ae37e44e0d (PSR-4
PHPMailer\PHPMailer\ => src/, 131 .php)
Method (php is not installed): SAMPLE of 40 files per repo (seeded shuf over src/ and test/). GT = regex extraction (comments and strings stripped) of use imports (incl. group use and aliases), new X, X::, extends/implements/instanceof/catch and type-position names, resolved with a class map built from every file's namespace+declaration (current namespace for unqualified names), plus literal require paths. This is a script, not hand-reading; I spot-checked 4 edges by grep (FlowdockFormatter use Monolog\LogRecord, OAuth implements OAuthTokenProvider, POP3 catch (Exception). Samples only.
Codemap edges = inverse of --importers over all indexed files (201 and 54).
| repo | GT edges (sample) | codemap edges from sample | true pos | recall | precision | coverage_status |
|---|---|---|---|---|---|---|
| monolog | 165 | 0 | 0 | 0% | undefined | complete on 201/201 |
| PHPMailer | 49 | 0 | 0 | 0% | undefined | complete on 54/54 |
| Whole-repo importer count is 0 in both: the PHP file graph is empty. |
Honesty: worst case. Every queried file says complete with zero importers.
Root causes:
use Namespace\Classcaptured as a raw import (sg-rules/php.ymlnamespace_use_declaration, e.g. FlowdockFormatter.php:14 -> 'Monolog\LogRecord') but never resolved to a file: no PSR-4 / composer.json autoload mapping, and backslash names do not hit the exact or suffix strategies in scanner/filegraph.go (inference). Explicit-use edges: 106 of 165 monolog misses, 47 of 49 PHPMailer. Fix: medium (read composer.json autoload psr-4/psr-4-dev, map namespace prefix to dir).- Same-namespace unqualified references (no
useneeded): 59 monolog misses (e.g. src/Monolog/ErrorHandler.php:294instanceof Logger), 2 PHPMailer. php.yml has no rule for them. Fix: large (needs a reference extractor plus the namespace class map). - Coverage honesty:
completewith an empty graph. Fix: small (partial for php until resolution exists). Also note: literalrequire __DIR__ . '/x.php'forms are captured by the rule; none of my samples depended on them.
Measured with codemap 4.6.3. Sampled numbers are samples, not a census.