Category
Language: · php-src-strict · compile-time typed property default
Problem
public int $x = null; (and other non-nullable typed properties defaulting to null) must be a compile fatal. Zend’s message tells the user to use the nullable form; the compiler’s parseAndCompile failure uses a shorter, different string.
Probed 2026-08-17 — host Zend PHP 8.2 vs php bin/vm.php.
| Repro |
Zend 8.2+ |
VM / compile (2026-08-17) |
class T { public int $x = null; } |
Fatal error: Default value for property of type int may not be null. Use the nullable type ?int to allow null default value |
parseAndCompile failure: … Cannot use null as default value for property $x of type int |
class T {
public int $x = null;
}
php-src reference
PHP implementation target
lib/Compiler.php / property default type check — emit Zend’s fatal wording (include “Use the nullable type ?T …”)
- Prefer matching Zend’s
E_COMPILE_ERROR / Fatal presentation used elsewhere for compile fatals
- php-in-PHP — no new C runtime branch
Repro
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_null_default_typed_prop.php' ; true
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_null_default_typed_prop.php' ; true
Done when
Category
Language:· php-src-strict · compile-time typed property defaultProblem
public int $x = null;(and other non-nullable typed properties defaulting tonull) must be a compile fatal. Zend’s message tells the user to use the nullable form; the compiler’sparseAndCompilefailure uses a shorter, different string.Probed 2026-08-17 — host Zend PHP 8.2 vs
php bin/vm.php.class T { public int $x = null; }Fatal error: Default value for property of type int may not be null. Use the nullable type ?int to allow null default valueparseAndCompile failure: … Cannot use null as default value for property $x of type intphp-src reference
Zend/zend_compile.c— typed property default null check / error message (“Use the nullable type ?%s …”)PHP implementation target
lib/Compiler.php/ property default type check — emit Zend’s fatal wording (include “Use the nullable type ?T …”)E_COMPILE_ERROR/ Fatal presentation used elsewhere for compile fatalsRepro
Done when
public T $prop = nullon non-nullableT(at leastint/string/float/bool/ class types)?int $x = nullstill accepted.phptguard undertest/compliance/cases/language/