sebastian/code-unit-reverse-lookup
Looks up which function or method a given line of code belongs to, a small utility from the PHPUnit ecosystem by Sebastian Bergmann. Install it via Composer as a project or dev dependency. Now a low maintenance project.
File.php:412 belong to?" Writing and maintaining that logic in-house is pure cost with no differentiation. Adopt it or inherit it transitively; don't staff it.OrderService::calculateTotal() instead of src/OrderService.php:412 in PR annotations and dashboards.Wizard API yourself) or treat it as invisible infrastructure (default).Adopt (or accept transitively) when:
--dev.Look elsewhere when:
nikic/php-parser, roave/better-reflection, or phpDocumentor instead. This package scans source lines; it is not an AST.Dependents: 0 figure in metadata is misleading (real usage is via php-code-coverage); don't use it as a signal either way, but do verify your own lockfile rather than trusting registry stats.To executives: This is a zero-cost, BSD-licensed utility that's already sitting in our dependency tree via PHPUnit. Its only job is turning a raw file-and-line reference into a named function or method, which makes our CI output and coverage reports readable and triage-able. No procurement, no license fees, no vendor relationship, no product differentiator — it's infrastructure, and it's already paid for. The one governance note: the maintainer has marked it low-maintenance, so we pin the version and keep it isolated behind a thin wrapper so it's replaceable in an afternoon.
To engineering: One class, one method: give it a file and a line, get back the enclosing callable. It's a transitive dependency of php-code-coverage, so don't add it to composer.json unless you're calling it directly — and if you are, add it as --dev. Don't fork it, don't vendor it, don't build a service around it. Do put a tiny adapter in front of it if the output ends up in anything user-facing, so that when you eventually need AST-grade precision for closures and anonymous classes we can swap in a PHP-Parser-based implementation without touching call sites. It's line-scanning, not parsing — treat its answers as "good enough for reports," not "correct for refactoring." Cost to wire up: hours.
How can I help you explore Laravel packages today?