Skip to content

Language record

PHP

PHP is read as the namespaced class diagram it actually is: classes, interfaces, traits, enums and functions each get an identity, `extends`, `implements` and trait `use` resolve between them, and a `use App\Domain\Invoice;` at the top of a file is an import edge to a symbol the index already owns.

.php, .phpt · 1 registry id · 12 of 14 relationship types

The registry row this page is generated from

Read at render time from the same family row the register reads, so nothing in this block can disagree with it.

Extensions
.php, .phpt
Registry names
php
Recorded symbols
classes · namespaces · methods · enums

Relationship types this analyzer constructs

12 of 14 constructed, read from this analyzer's source and re-derived by the languages gate. Each row below is one of the engine's types, in the engine's own order.

Relationship typeConstructed
callsconstructed by this analyzer
extendsconstructed by this analyzer
implementsconstructed by this analyzer
usesconstructed by this analyzer
importsconstructed by this analyzer
exportsconstructed by this analyzer
containsconstructed by this analyzer
referencesconstructed by this analyzer
overridesconstructed by this analyzer
instantiatesconstructed by this analyzer
decoratesruled absent
rendersruled absent
mixes_inconstructed by this analyzer
part_ofconstructed by this analyzer

12 constructed, 2 not constructed. All 2 absent types are recorded as ruled absent: the written reason and the corpus measurement behind each are in this family's completeness record. The register explains what each label means.

What this analyzer does not resolve

  • A callee named by a variable has no target to resolve to. $service->$method() and $handler('x') are refused, and a first-class callable written foo(...) is recorded as a member read with isTearOff rather than as a call, because it names a callable without invoking it. A braced member ($box->{'quoted'}) is refused for the same reason — it published a string literal as a symbol name on both ends.
  • The 218 core global functions are held as a bare-name list and filtered out of call edges, but method calls are not, because $obj->persist() is user code. That bare-name test had a measured hole: a fully qualified \is_file(...) did not match the set, and 12 such edges were counted on one phpunit revision before the leaf was taken before the filter rather than after.
  • exports is absent, and the reason is stated rather than assumed — a PHP file has no module surface, measured at 0 exports across the corpora. Separately, a private method is never the target of an overrides edge; phpunit ships a fixture asserting exactly that rule, because a defect with no corpus footprint is only catchable by hand.

Every line above was written against PHP’s own analyzer module and is named against a construct in it, so it can be checked against the source. Nothing here is inherited from a template, or from another language’s page.

Where you meet it in a repository

Recognised by extension — .php, .phpt. Everything below is about where those files actually sit in a working repository.

  • Composer and PSR-4 put one namespace per directory, so a file's namespace, its class's owner and its path on disk all agree — which is why the import at the top of the file resolves to something the index already owns.
  • Traits are the interesting half: use Money; inside a class body is recorded as composition, so "which classes get this behaviour" is answerable while the trait's own methods stay owned by the trait.
  • Declared types are a graph of their own. A property type, a parameter type, a return type and a typed class constant each publish a reference edge, and the distinction between a declared type and a return type survives in the edge metadata — the primitive types are excluded because they name no declaration.

Questions this index answers

Phrased as retrievals, because that is what an index can honestly do: it holds the symbols and the edges between them, and hands them back with the evidence attached.

  1. Which classes implement this interface, and which traits does this class compose?
  2. What does this method call, and who calls it?
  3. Which classes does this namespace declare?
  4. Which method overrides its parent's, and where is the parent declared?

What the analyzer sees in code like this

A namespaced final class, its trait, and the edge its parent call makes
<?php
namespace App\Domain;                             // bb records: namespace App\Domain

final class Invoice extends Document implements Payable {   // class + extends + implements
    use Money;                            // bb records: trait Money composed into Invoice

    public function settle(): void        // bb records: method settle on Invoice
    {
        $this->ledger->post($this->total);   // bb records: calls -> post, the leaf member name
    }
}

Symbols are stored with the file they came from and the bytes they span, so a hit points at a line rather than at a guess. The annotations in the sample are commentary for the reader, not strings the index would store.

Languages that turn up in the same repository

Scripting & shell — the count beside each name is how many relationship types that family’s analyzer constructs.

The extensions, registry names, recorded symbols and relationship types above are the parser registry row for PHP, read while the page rendered — the same row the register reads, so the two surfaces cannot tell two stories. Every relationship type listed as constructed appears in src/ast/real-*, the analyzer modules bb ships. bb 0.1.0 answers from a local store over 50 languages (53 registry ids, three of them aliases). There is no benchmark on this page: every claim here is one you can go and read in the source.