]> granicus.if.org Git - php/commitdiff
fix bug #71428: Validation type inheritance with = NULL
authorJoe Watkins <krakjoe@php.net>
Tue, 29 Mar 2016 08:57:51 +0000 (09:57 +0100)
committerJoe Watkins <krakjoe@php.net>
Tue, 29 Mar 2016 08:57:51 +0000 (09:57 +0100)
Zend/tests/bug71428.3.phpt [new file with mode: 0644]
Zend/zend_inheritance.c

diff --git a/Zend/tests/bug71428.3.phpt b/Zend/tests/bug71428.3.phpt
new file mode 100644 (file)
index 0000000..2f400e5
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+bug #71428: Validation type inheritance with = NULL
+--FILE--
+<?php
+class A { }
+class B           {  public function m(A $a = NULL, $n) { echo "B.m";} };
+class C extends B {  public function m(A $a       , $n) { echo "C.m";} };
+?>
+--EXPECTF--
+Warning: Declaration of C::m(A $a, $n) should be compatible with B::m(A $a = NULL, $n) in %sbug71428.3.php on line 4
+
index b52f45487cb0e3eefd9a4658b4c78afdc35dd75d..1ea38a16af9c2c279490e10ba54bb3e89fefe5ca 100644 (file)
@@ -488,6 +488,8 @@ static ZEND_COLD zend_string *zend_get_function_declaration(const zend_function
                                } else {
                                        smart_str_appends(&str, "NULL");
                                }
+                       } else if (arg_info->type_hint && arg_info->allow_null) {
+                               smart_str_appends(&str, " = NULL");
                        }
 
                        if (++i < num_args) {