Skip to content

Commit 555e8f8

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fixed type inference
2 parents b46ee53 + 731734d commit 555e8f8

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

Diff for: Zend/Optimizer/zend_inference.c

+14
Original file line numberDiff line numberDiff line change
@@ -2828,8 +2828,15 @@ static zend_always_inline zend_result _zend_update_type_info(
28282828
/* DOUBLE may be auto-converted to LONG */
28292829
tmp |= MAY_BE_LONG;
28302830
tmp &= ~MAY_BE_DOUBLE;
2831+
} else if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING)) == MAY_BE_STRING
2832+
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
2833+
/* LONG/DOUBLE may be auto-converted to STRING */
2834+
tmp |= MAY_BE_STRING;
2835+
tmp &= ~(MAY_BE_LONG|MAY_BE_DOUBLE);
28312836
}
28322837
tmp &= t1;
2838+
} else {
2839+
tmp |= MAY_BE_LONG | MAY_BE_STRING;
28332840
}
28342841
} else if (opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP) {
28352842
/* The return value must also satisfy the property type */
@@ -2840,8 +2847,15 @@ static zend_always_inline zend_result _zend_update_type_info(
28402847
/* DOUBLE may be auto-converted to LONG */
28412848
tmp |= MAY_BE_LONG;
28422849
tmp &= ~MAY_BE_DOUBLE;
2850+
} else if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING)) == MAY_BE_STRING
2851+
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
2852+
/* LONG/DOUBLE may be auto-converted to STRING */
2853+
tmp |= MAY_BE_STRING;
2854+
tmp &= ~(MAY_BE_LONG|MAY_BE_DOUBLE);
28432855
}
28442856
tmp &= t1;
2857+
} else {
2858+
tmp |= MAY_BE_LONG | MAY_BE_STRING;
28452859
}
28462860
} else {
28472861
if (tmp & MAY_BE_REF) {

Diff for: Zend/Optimizer/zend_optimizer.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,9 @@ zend_class_entry *zend_optimizer_get_class_entry(
799799
}
800800

801801
ce = zend_hash_find_ptr(CG(class_table), lcname);
802-
if (ce && ce->type == ZEND_INTERNAL_CLASS) {
802+
if (ce
803+
&& (ce->type == ZEND_INTERNAL_CLASS
804+
|| (op_array && ce->info.user.filename == op_array->filename))) {
803805
return ce;
804806
}
805807

Diff for: ext/opcache/tests/jit/assign_static_prop_op_001.phpt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
JIT ASSIGN_STATIC_PROP_OP: 001
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--EXTENSIONS--
9+
opcache
10+
--FILE--
11+
<?php
12+
function ref () {
13+
}
14+
class Foo {
15+
static $i;
16+
static string $s;
17+
}
18+
Foo::$i = 1;
19+
Foo::$s = Foo::$i;
20+
var_dump(Foo::$s -= ref());
21+
?>
22+
--EXPECT--
23+
string(1) "1"

0 commit comments

Comments
 (0)