Skip to content

Commit 96b8314

Browse files
authored
Merge branch 'php:master' into feature/atomic-utf8-flag-update
2 parents 20771e2 + 37e90b9 commit 96b8314

162 files changed

Lines changed: 3659 additions & 1081 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/download-bundled/jit-ir.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cd "$(dirname "$0")/../../.."
55
tmp_dir=/tmp/php-src-download-bundled/jit-ir
66
rm -rf "$tmp_dir"
77

8-
revision=4a1208ccbfc8ca32a5103baf9820ad3cbb6ff06e
8+
revision=281a66a87aedc4444ca09f696b9b8e9dab89ad32
99

1010
git clone --depth 1 --revision="$revision" https://github.com/dstogov/ir.git "$tmp_dir"
1111

‎NEWS‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ PHP NEWS
99

1010
- Curl:
1111
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
12-
. curl_multi_exec() now throws a TypeError when still_running is not an int.
12+
. curl_multi_exec() now throws a TypeError when $still_running cannot be
13+
converted to an int.
1314
(arshidkv12)
1415
. Uploading multiple files with the same field name is now possible by
1516
passing an array of CURLFile or CURLStringFile objects to
@@ -24,6 +25,7 @@ PHP NEWS
2425
throwing a ValueError. (Marc Bennewitz)
2526

2627
- Intl:
28+
. Added Collator::getRules() and collator_get_rules(). (Weilin Du)
2729
. Added IntlRelativeDateTimeFormatter for locale-aware relative date and time
2830
formatting, with enums for styles, capitalization contexts, and units.
2931
(Weilin Du)
@@ -188,6 +190,11 @@ PHP NEWS
188190
especially UTF-8. (Nicolas Grekas)
189191
. Improved performance of htmlspecialchars() when nothing needs encoding.
190192
(Nicolas Grekas)
193+
. bindec(), octdec(), hexdec() and base_convert() now throw an Exception
194+
when the passed string contains characters that are invalid for the
195+
specified number base. (Sjoerd Langkemper)
196+
. Improved performance of in_array() and array_search() in strict mode when
197+
searching for a string. (Alexander Danilov)
191198

192199
- URI:
193200
. Fix casing of enum cases in UriHostType and UrlHostType to match the RFC

‎UPGRADING‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ PHP 8.7 UPGRADE NOTES
2424
did not function properly.
2525

2626
- Curl:
27-
. curl_multi_exec() now throws a TypeError when still_running is not an int.
27+
. curl_multi_exec() now throws a TypeError when $still_running cannot be
28+
converted to an int.
2829
. Nested arrays in CURLOPT_POSTFIELDS now throw a TypeError, instead of being
2930
silently converted to the string "Array".
3031

@@ -56,6 +57,9 @@ PHP 8.7 UPGRADE NOTES
5657
application terminate one attribute and append further ones.
5758

5859
- Standard:
60+
. bindec(), octdec(), hexdec() and base_convert() now throw an Exception
61+
when the passed string contains characters that are invalid for the
62+
specified number base.
5963
. The number of filters that can be chained in a php://filter URL is limited
6064
to 16 by default. Set the stream context option max_filter_count to change
6165
this.
@@ -120,6 +124,11 @@ PHP 8.7 UPGRADE NOTES
120124
. Added Transliterator::toRules() and transliterator_to_rules() to export
121125
rules that can be used to recreate a transliterator. The optional
122126
$escapeUnprintable argument escapes unprintable characters when true.
127+
. Added Collator::getRules() and collator_get_rules() to retrieve collation
128+
tailoring rules as a UTF-8 string. These describe locale-specific adjustments
129+
to the root collation order; the full root/UCA rules are not included. An
130+
empty string is returned if no tailoring rules are available, or false if
131+
the rules cannot be converted to UTF-8.
123132

124133
========================================
125134
7. New Classes and Interfaces
@@ -197,6 +206,8 @@ PHP 8.7 UPGRADE NOTES
197206
UTF-8.
198207
. htmlspecialchars() returns its input without copying it when nothing needs
199208
encoding.
209+
. Improved performance of in_array() and array_search() in strict mode when
210+
searching for a string.
200211

201212
- MBString:
202213
. Improved performance of mb_strlen for UTF-8 strings.

‎UPGRADING.INTERNALS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ PHP 8.7 INTERNALS UPGRADE NOTES
9191
- Standard:
9292
. php_explode() now takes a HashTable* instead of a zval* to store the
9393
resulting parts. It already expected the zval* to be IS_ARRAY.
94+
. _php_math_basetozval() now returns zend_result instead of void. It throws
95+
an exception and returns FAILURE if the input contains invalid characters
96+
for the given base.
9497

9598
========================
9699
4. OpCode changes

‎Zend/Optimizer/zend_inference.c‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4938,6 +4938,9 @@ ZEND_API zend_result zend_ssa_inference(zend_arena **arena, const zend_op_array
49384938
}
49394939
/* }}} */
49404940

4941+
/* Key types whose conversion to an array offset may emit a diagnostic */
4942+
#define MAY_BE_THROWING_KEY (MAY_BE_NULL|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)
4943+
49414944
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa, uint32_t t1, uint32_t t2)
49424945
{
49434946
if (opline->op1_type == IS_CV) {
@@ -5220,7 +5223,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52205223
return 1;
52215224
}
52225225
return (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_TRUE|MAY_BE_FALSE|MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE)) || opline->op2_type == IS_UNUSED ||
5223-
(t2 & (MAY_BE_UNDEF|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
5226+
(t2 & (MAY_BE_UNDEF|MAY_BE_THROWING_KEY));
52245227
case ZEND_ASSIGN_OBJ:
52255228
if (t1 & (MAY_BE_ANY-MAY_BE_OBJECT)) {
52265229
return 1;
@@ -5285,9 +5288,9 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52855288
case ZEND_ROPE_END:
52865289
return t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT);
52875290
case ZEND_INIT_ARRAY:
5288-
return (opline->op2_type != IS_UNUSED) && (t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
5291+
return (opline->op2_type != IS_UNUSED) && (t2 & MAY_BE_THROWING_KEY);
52895292
case ZEND_ADD_ARRAY_ELEMENT:
5290-
return (opline->op2_type == IS_UNUSED) || (t2 & (MAY_BE_NULL|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
5293+
return (opline->op2_type == IS_UNUSED) || (t2 & MAY_BE_THROWING_KEY);
52915294
case ZEND_STRLEN:
52925295
return (t1 & MAY_BE_ANY) != MAY_BE_STRING;
52935296
case ZEND_COUNT:
@@ -5314,9 +5317,9 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53145317
case ZEND_FETCH_IS:
53155318
return (t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT));
53165319
case ZEND_ISSET_ISEMPTY_DIM_OBJ:
5317-
return (t1 & MAY_BE_OBJECT) || (t2 & (MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT));
5320+
return (t1 & MAY_BE_OBJECT) || (t2 & MAY_BE_THROWING_KEY);
53185321
case ZEND_FETCH_DIM_IS:
5319-
return (t1 & MAY_BE_OBJECT) || (t2 & (MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
5322+
return (t1 & MAY_BE_OBJECT) || (t2 & MAY_BE_THROWING_KEY);
53205323
case ZEND_CAST:
53215324
switch (opline->extended_value) {
53225325
case IS_LONG:
@@ -5338,7 +5341,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53385341
if ((t2 & MAY_BE_ANY) != MAY_BE_ARRAY) {
53395342
return 1;
53405343
}
5341-
if ((t1 & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
5344+
if (t1 & MAY_BE_THROWING_KEY) {
53425345
return 1;
53435346
}
53445347
return 0;
@@ -5363,7 +5366,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53635366
if (t1 & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) {
53645367
return 1;
53655368
}
5366-
if (t2 & (MAY_BE_RESOURCE|MAY_BE_ARRAY|MAY_BE_OBJECT)) {
5369+
if (t2 & MAY_BE_THROWING_KEY) {
53675370
return 1;
53685371
}
53695372
if (opline->op2_type == IS_UNUSED) {
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
--TEST--
2+
array_map(): foreach optimization resolves the function name of an FCC
3+
--FILE--
4+
<?php
5+
6+
namespace {
7+
function label($x) { return "global:$x"; }
8+
function only_global($x) { return "only_global:$x"; }
9+
}
10+
11+
namespace Lib {
12+
function fmt($x) { return "Lib\\fmt:$x"; }
13+
}
14+
15+
namespace App {
16+
function label($x) { return "App\\label:$x"; }
17+
function strtoupper($x) { return "App\\strtoupper:$x"; }
18+
function pad($x, $y) { return "App\\pad:$x$y"; }
19+
20+
use function Lib\fmt;
21+
use function App\label as lbl;
22+
23+
echo "namespaced function:\n";
24+
var_dump(\array_map(label(...), [1]));
25+
echo "namespaced function shadowing an internal one:\n";
26+
var_dump(\array_map(strtoupper(...), ['a']));
27+
echo "use function:\n";
28+
var_dump(\array_map(fmt(...), [2]));
29+
echo "use function with alias:\n";
30+
var_dump(\array_map(lbl(...), [3]));
31+
echo "namespace-relative name:\n";
32+
var_dump(\array_map(namespace\label(...), [4]));
33+
echo "fully qualified name:\n";
34+
var_dump(\array_map(\label(...), [5]));
35+
echo "fallback to the global function:\n";
36+
var_dump(\array_map(only_global(...), [6]));
37+
echo "fallback to an internal function:\n";
38+
var_dump(\array_map(ucfirst(...), ['b']));
39+
echo "partial application:\n";
40+
var_dump(\array_map(pad(?, '!'), [7]));
41+
42+
if (true) {
43+
function declared_at_runtime($x) { return "App\\declared_at_runtime:$x"; }
44+
}
45+
echo "function declared at runtime:\n";
46+
var_dump(\array_map(declared_at_runtime(...), [8]));
47+
}
48+
49+
namespace {
50+
use function Lib\fmt;
51+
use function Lib\fmt as libfmt;
52+
53+
echo "global namespace, use function:\n";
54+
var_dump(array_map(fmt(...), [9]));
55+
echo "global namespace, use function with alias:\n";
56+
var_dump(array_map(libfmt(...), [10]));
57+
echo "global namespace, unqualified:\n";
58+
var_dump(array_map(label(...), [11]));
59+
}
60+
61+
?>
62+
--EXPECT--
63+
namespaced function:
64+
array(1) {
65+
[0]=>
66+
string(11) "App\label:1"
67+
}
68+
namespaced function shadowing an internal one:
69+
array(1) {
70+
[0]=>
71+
string(16) "App\strtoupper:a"
72+
}
73+
use function:
74+
array(1) {
75+
[0]=>
76+
string(9) "Lib\fmt:2"
77+
}
78+
use function with alias:
79+
array(1) {
80+
[0]=>
81+
string(11) "App\label:3"
82+
}
83+
namespace-relative name:
84+
array(1) {
85+
[0]=>
86+
string(11) "App\label:4"
87+
}
88+
fully qualified name:
89+
array(1) {
90+
[0]=>
91+
string(8) "global:5"
92+
}
93+
fallback to the global function:
94+
array(1) {
95+
[0]=>
96+
string(13) "only_global:6"
97+
}
98+
fallback to an internal function:
99+
array(1) {
100+
[0]=>
101+
string(1) "B"
102+
}
103+
partial application:
104+
array(1) {
105+
[0]=>
106+
string(10) "App\pad:7!"
107+
}
108+
function declared at runtime:
109+
array(1) {
110+
[0]=>
111+
string(25) "App\declared_at_runtime:8"
112+
}
113+
global namespace, use function:
114+
array(1) {
115+
[0]=>
116+
string(9) "Lib\fmt:9"
117+
}
118+
global namespace, use function with alias:
119+
array(1) {
120+
[0]=>
121+
string(10) "Lib\fmt:10"
122+
}
123+
global namespace, unqualified:
124+
array(1) {
125+
[0]=>
126+
string(9) "global:11"
127+
}

‎Zend/tests/gh25299.phpt‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-25299 (Exception string code is lost after unserialize())
3+
--CREDITS--
4+
tacman
5+
--FILE--
6+
<?php
7+
8+
class MyException extends Exception {
9+
protected $code = 'HY000';
10+
}
11+
12+
$e = unserialize(serialize(new MyException()));
13+
var_dump($e->getCode());
14+
15+
$e = unserialize('O:9:"Exception":1:{s:7:"' . "\0*\0" . 'code";a:0:{}}');
16+
var_dump($e->getCode());
17+
18+
?>
19+
--EXPECTF--
20+
string(5) "HY000"
21+
22+
Warning: Undefined property: Exception::$code in %s on line %d
23+
NULL

‎Zend/tests/gh25299_ref.phpt‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-25299: Exception::__wakeup() keeps message and code held by reference
3+
--FILE--
4+
<?php
5+
6+
class MyException extends Exception {
7+
public $m = 'm';
8+
public $c = 5;
9+
10+
public function __construct() {
11+
$this->message = &$this->m;
12+
$this->code = &$this->c;
13+
}
14+
}
15+
16+
$e = unserialize(serialize(new MyException()));
17+
var_dump($e->getMessage(), $e->getCode());
18+
19+
?>
20+
--EXPECT--
21+
string(1) "m"
22+
int(5)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
PFA can be made from never function
3+
--FILE--
4+
<?php
5+
6+
function neverReturns($msg): never {
7+
throw new Error($msg);
8+
}
9+
10+
var_dump(neverReturns(?) instanceof Closure);
11+
12+
?>
13+
--EXPECT--
14+
bool(true)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
GH-25265 (Hooked property in a subclass of an internal class with virtual properties)
3+
--CREDITS--
4+
YuanchengJiang
5+
--EXTENSIONS--
6+
dom
7+
--FILE--
8+
<?php
9+
10+
class Test extends DOMDocument {
11+
public int $prop { set => $value; }
12+
}
13+
14+
$doc = new Test;
15+
$doc->prop = 42;
16+
var_dump(get_object_vars($doc));
17+
foreach ($doc as $key => $value) {
18+
var_dump($key, $value);
19+
}
20+
21+
?>
22+
--EXPECT--
23+
array(1) {
24+
["prop"]=>
25+
int(42)
26+
}
27+
string(4) "prop"
28+
int(42)

0 commit comments

Comments
 (0)