Category
language · php-src-strict · traits · compile-time error text
Problem
Using a parent class name in a trait insteadof clause is a compile-time error in php-src. This compiler emits a generic Could not find trait P message instead of Zend's explicit "Class P is not a trait, Only traits may be used in 'as' and 'insteadof' statements".
| Repro |
Zend 8.2+ |
VM/JIT compile (2026-08-18 @ 2f0c85a98d) |
class P{}; trait T{}; class C extends P { use T { T::m insteadof P; } } |
Fatal: Class P is not a trait… |
Could not find trait P |
Workers/compliance diff on error text, not just failure presence.
php-src reference
PHP implementation target
lib/ trait compilation / conflict resolution — when insteadof/as operand resolves to a class that is not a trait, emit Zend message verbatim
- Keep logic in PHP compile pipeline; no new C runtime branches
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_trait_insteadof_parent.php 2>&1 | head -1'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_trait_insteadof_parent.php 2>&1 | head -1'
Done when
Category
language· php-src-strict · traits · compile-time error textProblem
Using a parent class name in a trait
insteadofclause is a compile-time error in php-src. This compiler emits a genericCould not find trait Pmessage instead of Zend's explicit "Class P is not a trait, Only traits may be used in 'as' and 'insteadof' statements".2f0c85a98d)class P{}; trait T{}; class C extends P { use T { T::m insteadof P; } }Workers/compliance diff on error text, not just failure presence.
php-src reference
Zend/zend_compile.c—zend_compile_traits(),zend_trait_method_compatibility_check()PHP implementation target
lib/trait compilation / conflict resolution — wheninsteadof/asoperand resolves to a class that is not a trait, emit Zend message verbatimRepro
Done when
is not a traitwith class namePon VM and JIT.phptguard undertest/compliance/cases/language/trait_insteadof_parent*.phptasserting%is not a trait%