php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71426 Inheritance, signature verifications, type hints, pass by reference and NULL
Submitted: 2016-01-21 17:53 UTC Modified: 2017-01-09 19:16 UTC
From: dpa-bugs at aegee dot org Assigned: cmb (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.6.17 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dpa-bugs at aegee dot org
New email:
PHP Version: OS:

 

 [2016-01-21 17:53 UTC] 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            ) { echo "C.m";} };
$b = new B();
$b->m(new A(), $b);
$c = new C();
$c->m(new A(), $b);
?>

reports:

PHP Warning:  Declaration of C::m($a) should be compatible with B::m(A $a, &$n) on line 4

but shall report:

PHP Warning:  Declaration of C::m($a) should be compatible with B::m(A $a = NULL, &$n) on line 4

The same happens with php 5.6.17 .

Just removing &$n leads to the correct "PHP Warning:  Declaration of C::m($a) should be compatible with B::m(A $a = NULL) on line 4"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-09 19:16 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2017-01-09 19:16 UTC] cmb@php.net
That appears to have been fixed as of PHP 7.0.16, see
<https://3v4l.org/9C7DU>. Note that PHP 5.6 doesn't receive any
bugfixes (except security related) anymore, so this ticket can be
closed.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 14:00:02 2026 UTC