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.
This commit is contained in:
Dmitry Stogov 2023-11-02 08:21:36 +03:00
commit 110cdd336a
4 changed files with 36 additions and 10 deletions

View File

@ -2547,6 +2547,7 @@ static zend_always_inline zend_result _zend_update_type_info(
* code may assume that operands have at least one type. */
if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
|| (ssa_op->result_use >= 0 && !(RES_USE_INFO() & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS)))
|| ((opline->opcode == ZEND_ASSIGN_DIM_OP
|| opline->opcode == ZEND_ASSIGN_OBJ_OP
|| opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP

View File

@ -113,8 +113,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
locale = Locale::createFromName(locale_str);
/* get*Name accessors being set does not preclude being bogus */
if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid locale", 0);
return FAILURE;
goto error;
}
/* process calendar */

View File

@ -5,18 +5,18 @@ intl
--FILE--
<?php
try {
new IntlDateFormatter(
var_dump(new IntlDateFormatter(
'xx',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
null,
null,
'w'
);
} catch (\IntlException $e) {
echo $e->getMessage();
}
?>
));
Locale::setDefault('xx');
var_dump(new IntlDateFormatter(Locale::getDefault()));
--EXPECT--
datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR
object(IntlDateFormatter)#1 (0) {
}
object(IntlDateFormatter)#1 (0) {
}

View File

@ -0,0 +1,26 @@
--TEST--
GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT
--INI--
opcache.enable=1
opcache.enable_cli=1
--EXTENSIONS--
opcache
--FILE--
<?php
function test()
{
$bool_or_int = true;
while (a()) {
if ($bool_or_int !== true) {
// The following line triggers narrowing during type inference of ZEND_ADD_ARRAY_ELEMENT.
$string_key = "a";
$array = ["bool_or_int" => $bool_or_int, $string_key => 123];
}
$bool_or_int = 0;
}
}
?>
DONE
--EXPECT--
DONE