forked from ircmaxell/php-compiler
-
Notifications
You must be signed in to change notification settings - Fork 1
Language: Typed properties, union types, and readonly (PHP 8+) #169
Copy link
Copy link
Closed
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language features
Description
Activity
Metadata
Metadata
Assignees
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language features
Category
languageProblem
class C { public string $name; public int|string $id; public readonly string $code; }parses, but VM does not enforce property types on write. Assigninginttostring $xsucceeds silently (verified May 2026). This blocks Zend parity for Router/config objects and self-host code using typed properties throughoutlib/.php-src reference
Zend/zend_compile.c— typed property flags onzend_property_infoZend/zend_execute.c—ZEND_ASSIGN_OBJ, type checks +readonlyguardZend/zend_type.c— union assignabilityRepro (failure today)
Typed property write
Readonly second assign
Union accept/reject
Zend: first assign ok, second
TypeError.Scope (this repo)
lib/Compiler.php— persistTypeonTYPE_DECLARE_PROPERTYlib/VM.php—TYPE_PROPERTY_ASSIGNenforce + readonlylib/Type.phpor php-types assignability helperstest/compliance/cases/language/typed_property_*.phptDone when
TypeErroron VM (message subset ok)Error(or compile-time fatal where Zend does)int|stringacceptsintandstring, rejectsarray./script/ci-fast.sh --filter typed_propertygreenVerification
./script/ci-fast.sh --filter typed_property php script/bootstrap-inventory.php --check # typed props in lib/ should stop warning-only assignsLinks
private array $config· Language: Visibility, constructors, and destructors #145 visibility · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492 self-host