Skip to content

Language: Magic constants __DIR__, __FILE__, __LINE__ for multi-file apps #85

@PurHur

Description

@PurHur

Problem

Multi-file PHP apps rely on magic constants for portable includes:

require __DIR__ . '/../config.php';

The compiler may not lower __DIR__ / __FILE__ / __LINE__ consistently across VM, JIT, and AOT—especially when combined with include (#54).

Goal

Compile-time or runtime-correct magic constants in all execution modes.

Tasks

  • Audit PHPCfg handling of magic constants in lib/Compiler.php
  • VM: set __FILE__ from current script path in Runtime::parseAndCompileFile
  • VM: __DIR__ = dirname(__FILE__) during include stack walks
  • JIT/AOT: embed compile unit path as global string constants
  • __LINE__: map to CFG line info or fixed per-opcode metadata
  • PHPT: include chain with __DIR__-relative path resolves correctly
  • Document interaction with AOT (binary path vs source path)

Acceptance criteria

examples/003-MiniWebApp can load config.php via require __DIR__ . '/../config.php' from public/index.php in VM and AOT.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions