Skip to content

Commit ee9a78a

Browse files
committed
work on #71428
1 parent 28f6676 commit ee9a78a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Zend/tests/bug71428.1.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
bug #71428.1: inheritance with null default values
3+
--FILE--
4+
<?php
5+
class A {
6+
public function m(array $a = null) {}
7+
}
8+
class B extends A {
9+
public function m(array $a = []) {}
10+
}
11+
--EXPECTF--
12+
Warning: Declaration of B::m(array $a = Array) should be compatible with A::m(array $a = NULL) in %sbug71428.1.php on line 7
13+

Zend/zend_inheritance.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
238238
zend_string_release(fe_class_name);
239239
}
240240

241+
if (proto_arg_info->allow_null && !fe_arg_info->allow_null) {
242+
/* incompatible nullability */
243+
return 0;
244+
}
245+
241246
if (fe_arg_info->type_hint != proto_arg_info->type_hint) {
242247
/* Incompatible type */
243248
return 0;

0 commit comments

Comments
 (0)