Skip to content
docsv0.24.0

DeclarationScanner

Reads the class, interface, and enum declarations out of one PHP file by tokenizing it — never by requiring it — so asking «what does this file declare» cannot run top-level code or static initializers. Shared by every read-only introspection operation that inventories source it must not execute: {@see \Milpa\DevTools\Operations\ArtifactListHandler}, {@see \Milpa\DevTools\Operations\ContractSearchHandler}, and {@see \Milpa\DevTools\Operations\PackageArtifactsHandler}.

DeclarationScanner::scan()

public static function scan(string $file): array

The named type declarations in the file: each one's short name, FQCN (from the file's own `namespace` statement), and kind (`class`, `interface`, or `enum`). A file that cannot be read scans as declaring nothing.

Parameters

Parameters of scan()
NameTypeDescription
$filestring