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
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: 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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC