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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 16:01:29 2024 UTC