Skip to content

Commit 110cdd3

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fixed GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT ext/intl: change when the locale is invalid for the 8.1/8.2 serie.
2 parents 95c8ad2 + 22735b3 commit 110cdd3

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,7 @@ static zend_always_inline zend_result _zend_update_type_info(
25472547
* code may assume that operands have at least one type. */
25482548
if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
25492549
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
2550+
|| (ssa_op->result_use >= 0 && !(RES_USE_INFO() & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS)))
25502551
|| ((opline->opcode == ZEND_ASSIGN_DIM_OP
25512552
|| opline->opcode == ZEND_ASSIGN_OBJ_OP
25522553
|| opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP

ext/intl/dateformat/dateformat_create.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
113113
locale = Locale::createFromName(locale_str);
114114
/* get*Name accessors being set does not preclude being bogus */
115115
if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) {
116-
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid locale", 0);
117-
return FAILURE;
116+
goto error;
118117
}
119118

120119
/* process calendar */

ext/intl/tests/gh12282.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ intl
55
--FILE--
66
<?php
77

8-
try {
9-
new IntlDateFormatter(
8+
var_dump(new IntlDateFormatter(
109
'xx',
1110
IntlDateFormatter::FULL,
1211
IntlDateFormatter::FULL,
1312
null,
1413
null,
1514
'w'
16-
);
17-
} catch (\IntlException $e) {
18-
echo $e->getMessage();
19-
}
20-
?>
15+
));
16+
Locale::setDefault('xx');
17+
var_dump(new IntlDateFormatter(Locale::getDefault()));
2118
--EXPECT--
22-
datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR
19+
object(IntlDateFormatter)#1 (0) {
20+
}
21+
object(IntlDateFormatter)#1 (0) {
22+
}

ext/opcache/tests/opt/gh10008.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--EXTENSIONS--
7+
opcache
8+
--FILE--
9+
<?php
10+
function test()
11+
{
12+
$bool_or_int = true;
13+
while (a()) {
14+
if ($bool_or_int !== true) {
15+
// The following line triggers narrowing during type inference of ZEND_ADD_ARRAY_ELEMENT.
16+
$string_key = "a";
17+
$array = ["bool_or_int" => $bool_or_int, $string_key => 123];
18+
}
19+
20+
$bool_or_int = 0;
21+
}
22+
}
23+
?>
24+
DONE
25+
--EXPECT--
26+
DONE

0 commit comments

Comments
 (0)