Bug #71428 [Opn]: Validation type inheritance with = NULL

From: Date: Thu, 21 Jan 2016 21:23:19 +0000
Subject: Bug #71428 [Opn]: Validation type inheritance with = NULL
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198827@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71428&edit=1 ID: 71428 Updated by: nikic@php.net Reported by: dpa-bugs at aegee dot org Summary: Validation type inheritance with = NULL Status: Open Type: Bug Package: Class/Object related PHP Version: 7.0.2 Block user comment: N Private report: N New Comment: Another example that does not rely on optional-before-required arguments: class A { public function m(array $a = null) {} } class B extends A { public function m(array $a = []) {} } Previous Comments: ------------------------------------------------------------------------ [2016-01-21 18:52:48] dpa-bugs at aegee dot org Description: ------------ <?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";} }; $b = new B(); $b->m(new A(), $b); $c = new C(); $c->m(new A(), $b); ?> reports nothing, but shall report: PHP Warning: Declaration of C::m(A $a, $n) should be compatible with B::m(A $a = NULL, $n) on line 4 Removing on both places $n reports correctly: PHP Warning: Declaration of C::m(A $a) should be compatible with B::m(A $a = NULL) on line 4 Same with php 5.6.17. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71428&edit=1

« previous php.bugs (#198827) next »