diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 883983800d1..0a13918976a 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2191,7 +2191,7 @@ static zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, z if (opline->op2_type == IS_CONST) { zend_class_entry *ce = NULL; - if (opline->op1_type == IS_UNUSED) { + if (opline->op1_type == IS_UNUSED && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) { ce = op_array->scope; } else if (ssa_op->op1_use >= 0) { ce = ssa->var_info[ssa_op->op1_use].ce; diff --git a/ext/opcache/tests/jit/gh12262.phpt b/ext/opcache/tests/jit/gh12262.phpt new file mode 100644 index 00000000000..66ac918a520 --- /dev/null +++ b/ext/opcache/tests/jit/gh12262.phpt @@ -0,0 +1,43 @@ +--TEST-- +GH-12262: Tracing JIT assertion crash when using phpstan +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_hot_func=2 +--FILE-- +value === $type->value; + } +} +class C1 extends C { + use T; + public function __construct(private int $value) { + } +} +class C2 extends C { + use T; + public function __construct(private string $value) { + } +} +$x = new C1(1); +var_dump($x->equal($x)); +var_dump($x->equal($x)); +var_dump($x->equal($x)); + +$a = new C2("aaa"); +var_dump($a->equal($a)); +var_dump($a->equal($a)); +var_dump($a->equal($a)); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true)