]> granicus.if.org Git - php/commitdiff
work on #71428
authorJoe Watkins <krakjoe@php.net>
Mon, 28 Mar 2016 10:54:25 +0000 (11:54 +0100)
committerJoe Watkins <krakjoe@php.net>
Mon, 28 Mar 2016 10:54:25 +0000 (11:54 +0100)
Zend/tests/bug71428.1.phpt [new file with mode: 0644]
Zend/zend_inheritance.c

diff --git a/Zend/tests/bug71428.1.phpt b/Zend/tests/bug71428.1.phpt
new file mode 100644 (file)
index 0000000..b754687
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+bug #71428.1: inheritance with null default values
+--FILE--
+<?php
+class A {
+    public function m(array $a = null) {}
+}
+class B extends A {
+    public function m(array $a = []) {}
+}
+--EXPECTF--
+Warning: Declaration of B::m(array $a = Array) should be compatible with A::m(array $a = NULL) in %sbug71428.1.php on line 7
+
index 9eb7a0b9c98acedf6a60a633a6681df8ea93bd65..d904a587a160e8ff33d9734f73d4112184df308a 100644 (file)
@@ -238,6 +238,11 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
                zend_string_release(fe_class_name);
        }
 
+       if (proto_arg_info->allow_null && !fe_arg_info->allow_null) {
+               /* incompatible nullability */
+               return 0;
+       }
+
        if (fe_arg_info->type_hint != proto_arg_info->type_hint) {
                /* Incompatible type */
                return 0;