Skip to content

Commit a1911ad

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix parent hook call with named args
2 parents 6bcc4e2 + b150eb3 commit a1911ad

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.5.0RC4
44

5+
- Core:
6+
. Fixed bug GH-20270 (Broken parent hook call with named arguments). (ilutov)
7+
58
- Reflection:
69
. Fixed bug GH-20217 (ReflectionClass::isIterable() incorrectly returns true
710
for classes with property hooks). (alexandre-daubois)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
GH-20270: Parent hook call with named arguments
3+
--CREDITS--
4+
Viet Hoang Luu (@vi3tL0u1s)
5+
--FILE--
6+
<?php
7+
8+
class A {
9+
public mixed $prop1;
10+
public mixed $prop2 {
11+
set(mixed $custom) => $custom;
12+
}
13+
}
14+
15+
class B extends A {
16+
public mixed $prop1 {
17+
set {
18+
parent::$prop1::set(value: 42);
19+
parent::$prop1::set(unknown: 43);
20+
}
21+
}
22+
public mixed $prop2 {
23+
set {
24+
parent::$prop2::set(custom: 42);
25+
parent::$prop2::set(value: 43);
26+
}
27+
}
28+
}
29+
30+
$b = new B();
31+
32+
try {
33+
$b->prop1 = 0;
34+
} catch (Error $e) {
35+
echo $e->getMessage(), "\n";
36+
}
37+
var_dump($b->prop1);
38+
39+
try {
40+
$b->prop2 = 0;
41+
} catch (Error $e) {
42+
echo $e->getMessage(), "\n";
43+
}
44+
var_dump($b->prop2);
45+
46+
?>
47+
--EXPECT--
48+
Unknown named parameter $unknown
49+
int(42)
50+
Unknown named parameter $value
51+
int(42)

Zend/zend_object_handlers.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,9 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
17871787
const zend_property_info *prop_info,
17881788
zend_property_hook_kind kind, zend_string *prop_name)
17891789
{
1790-
static const zend_arg_info arg_info[1] = {{0}};
1790+
static const zend_internal_arg_info arg_info[2] = {
1791+
{ .name = "value" }
1792+
};
17911793
zend_function *func;
17921794
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
17931795
func = &EG(trampoline);

0 commit comments

Comments
 (0)