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
 [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-2019 The PHP Group
All rights reserved.
Last updated: Tue May 21 09:01:26 2019 UTC