php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76700 false-positive "Error: Call to protected method" when using trait aliases
Submitted: 2018-08-03 15:36 UTC Modified: 2018-08-05 22:08 UTC
From: nicolas dot grekas+php at gmail dot com Assigned: pmmaga (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.3.0beta1 OS:
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: nicolas dot grekas+php at gmail dot com
New email:
PHP Version: OS:

 

 [2018-08-03 15:36 UTC] nicolas dot grekas+php at gmail dot com
Description:
------------
See test script, or https://3v4l.org/Tti7T
Works on PHP < 7.3

Test script:
---------------
<?php

trait T1
{
    protected function aa() { echo 123; }
}

trait T2
{
    use T1 {
        aa as public;
    }
}

class A
{
    use T1;
}

class B extends A
{
    use T2;
}

$b = new B();
$b->aa();

Expected result:
----------------
123

Actual result:
--------------
Fatal error: Uncaught Error: Call to protected method A::aa() from context ''

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-03 16:14 UTC] pmmaga@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: pmmaga
 [2018-08-05 22:08 UTC] cmb@php.net
For reference: <https://github.com/php/php-src/pull/3426>.
 [2018-08-07 06:24 UTC] laruence@php.net
Automatic comment on behalf of mail@pmmaga.net
Revision: http://git.php.net/?p=php-src.git;a=commit;h=887235773d1848108f842184c978ba37875768f2
Log: Fix #76700 - Methods with altered visibility need to be added again
 [2018-08-07 06:24 UTC] laruence@php.net
-Status: Verified +Status: Closed
 [2018-08-07 06:24 UTC] laruence@php.net
Automatic comment on behalf of mail@pmmaga.net
Revision: http://git.php.net/?p=php-src.git;a=commit;h=97b2558b760309e8fa99f4fcf45bc56a75598892
Log: Fix #76700 - Methods with altered visibility need to be added again
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 22 12:01:23 2021 UTC