Skip to content

Commit 54452b4

Browse files
committed
Fixed GH-12262: Tracing JIT assertion crash when using phpstan
1 parent 6cf76d5 commit 54452b4

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Zend/Optimizer/zend_inference.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ static zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, z
21772177
if (opline->op2_type == IS_CONST) {
21782178
zend_class_entry *ce = NULL;
21792179

2180-
if (opline->op1_type == IS_UNUSED) {
2180+
if (opline->op1_type == IS_UNUSED && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
21812181
ce = op_array->scope;
21822182
} else if (ssa_op->op1_use >= 0) {
21832183
ce = ssa->var_info[ssa_op->op1_use].ce;

ext/opcache/tests/jit/gh12262.phpt

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
GH-12262: Tracing JIT assertion crash when using phpstan
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_hot_func=2
8+
--FILE--
9+
<?php
10+
class C {
11+
}
12+
trait T {
13+
public function equal(C $type): bool {
14+
return $type instanceof self && $this->value === $type->value;
15+
}
16+
}
17+
class C1 extends C {
18+
use T;
19+
public function __construct(private int $value) {
20+
}
21+
}
22+
class C2 extends C {
23+
use T;
24+
public function __construct(private string $value) {
25+
}
26+
}
27+
$x = new C1(1);
28+
var_dump($x->equal($x));
29+
var_dump($x->equal($x));
30+
var_dump($x->equal($x));
31+
32+
$a = new C2("aaa");
33+
var_dump($a->equal($a));
34+
var_dump($a->equal($a));
35+
var_dump($a->equal($a));
36+
?>
37+
--EXPECT--
38+
bool(true)
39+
bool(true)
40+
bool(true)
41+
bool(true)
42+
bool(true)
43+
bool(true)

0 commit comments

Comments
 (0)