Expand description
phplang — PHP as a fusevm frontend.
Pipeline: lexer → parser builds a PHP AST → compiler lowers it to a
fusevm::Chunk (plus a table of function sub-chunks) → fusevm executes it,
calling back into the host (through registered builtins and the strict
numeric hook) for every PHP-specific operation. There is no bespoke VM or
JIT here — execution and codegen live in fusevm.
Re-exports§
pub use embed::run_program;
Modules§
- argsig
- Declared arity and parameter NAMES for the standard library, and the two checks PHP 8 runs against them before a builtin sees its arguments: the argument COUNT, and the binding of PHP 8.0 named arguments.
- argtypes
- Declared parameter types for the standard library, and the check PHP 8 runs against them before a builtin sees its arguments.
- ast
- The PHP abstract syntax tree produced by
parserand consumed bycompiler. - ast_
export zend_ast_export(Zend/zend_ast.c) for the constant expressions a parameter or property default may hold: whatReflection*::__toStringprints for a default the reference keeps as an AST because it could not evaluate it while compiling (self::A,N\UC + 1,new \N\Foo()).- banner
- The REPL banner (shown only for the interactive
php -a, never for script execution). - builtins
- Te phplang builtins: the
CallBuiltinhandlers the compiler emits, the strict numeric hook, and the PHP standard-library functions reached throughCALL. - bytes
- PHP strings are byte strings;
fusevm::Value::Strholds a RustString, which must be valid UTF-8. This module is the bridge. - cli
- Command-line interface for the
phpbinary. - compiler
- Lower the PHP AST to
fusevm::Chunk. - corpus
- The language corpus: the exact
(name, chapter, signature, description, example)table that documents every name the current phplang build recognizes. - dap
- Debug Adapter Protocol over stdio (
php --dap). - embed
- The embedding entry point: run a whole PHP program with a given standard input and get back what it wrote to standard output.
- errlevel
- PHP’s
E_*error levels and theerror_reportingmask. - host
- The PHP object heap and runtime, reached from fusevm through registered
builtins (
builtins::install) and the strict numeric hook. - intercepts
- Function-call intercepts (aspect-oriented advice) — a glob-matched registry of before/after/around hooks keyed by function-name pattern.
- internal_
interfaces - GENERATED by
scripts/gen-internal-interfaces.phpfrom PHP 8.5.12 — do not edit. - lexer
- The PHP lexer.
- lsp
- The Language Server (
php --lsp): a self-contained, read-only server (run) that answers completion and hover from the language corpus and publishes diagnostics from the runtime’s ownparser::parse. No output ever reaches the terminal — JSON-RPC on stdio only. Structure follows the sibling-rsfrontends’lsp.rs(seepythonrs/src/lsp.rs). - parser
- Recursive-descent parser:
lexertokens → PHP AST (ast::Stmt). - promote
- Which locals may live in a fusevm FRAME SLOT instead of the host scope.
- repl
- The interactive REPL (
php -a). - rust_
ffi - PHP wiring for inline Rust FFI (
rust { ... }blocks). - stdlib
- The extended PHP standard library, one module per category. Each module
exposes
dispatch(name, args) -> Option<Result<Value, String>>, returningNonewhen the name is not one of its functions.builtins::call_libraryconsults this chain for every name its own core match does not handle, so categories can be developed independently without touching a shared table. - tiers
- Which fusevm execution tier a program’s bytecode actually reaches.
- timelib
- A port of the parts of timelib (the date library bundled with the reference
interpreter,
ext/date/lib, version 2022.17) thatstrtotime,date_parseand theDateTimeclasses stand on: the free-form date scanner (parse_date.re),timelib_parse_from_format, the relative-time resolution oftm2unixtime.c, the calendar helpers ofdow.candunixtime2tm.c, and the interval arithmetic ofinterval.c.
Enums§
- Value
- Core value type — what lives on the stack and in variables.
Constants§
- FROM_
CALLABLE_ FORWARDER - The function-table key the
ClosureaClosure::fromCallable($c)builds runs out of: a variadic forwarder holding the callable it was made from.
Functions§
- compile
- Compile a PHP source string to a runnable program.
- compile_
debug - Compile with per-statement DAP line markers enabled (
php --dap). - eval_
capture - Evaluate
srcand return the captured program output. The convenience entry point for tests: installs an output buffer, runs, and returns whatechowrote (PHP is output-oriented — its observable result is stdout, not a value). - eval_
capture_ with - Evaluate
srcwithvarsbound and return the captured program output —eval_capturefor an embedder that has input to hand the program. - eval_
cli eval_strfor the CLI: identical, except a syntax error is displayed in PHP’s shape rather than left to the caller to print tersely, and the trailing command-line arguments reach the program as$argv.- eval_
file - Read and run a
.phpfile on a fresh host. - eval_
file_ cli eval_filefor the CLI — seeeval_cli.- eval_
file_ debug - Read and run a
.phpfile under the DAP debugger (per-statement line markers, tracing JIT disabled so the markers fire). - eval_
stdin_ cli eval_clifor a script read from standard input (php < script.php).- eval_
str - Parse, compile, load, and run a PHP source string on a fresh host; return the value of the last top-level expression.
- load_
merged - Merge an already-compiled program onto the current host (install the exception prelude, then the program’s user functions/classes/try-defs) and return the main chunk for the caller to run.
- run_
compiled - Run an already-compiled program on the current host.