php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55086 Namespace alias does not work inside trait's use block
Submitted: 2011-06-30 07:47 UTC Modified: 2011-07-02 13:12 UTC
From: andrey dot garbuz at gmail dot com Assigned: gron (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.4SVN-2011-06-30 (SVN) OS: Fedora 14
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: andrey dot garbuz at gmail dot com
New email:
PHP Version: OS:

 

 [2011-06-30 07:47 UTC] andrey dot garbuz at gmail dot com
Description:
------------
Namespace aliases do not work only inside trait's use block. If provide fully 
qualified namespace then example works fine:
class A {
  use T1, T2 {
    \N1\T1::hello insteadof \N1\T2;
  }
}

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

namespace N1 {

    trait T1 {
      public function hello() { return 'hello from t1'; }
    }

    trait T2 {
      public function hello() { return 'hello from t2'; }
    }

}

namespace N2 {

    use N1\T1;
    use N1\T2;
    
    class A {
      use T1, T2 {
        T1::hello insteadof T2;
      }
    }

    $a = new A;
    echo $a->hello(), PHP_EOL;
    
}

Expected result:
----------------
hello from t1

Actual result:
--------------
PHP Fatal error:  Trait 'T1' not found in test_script.php on line 24

Patches

bug55086.phpt (last revision 2011-07-01 20:33 UTC by pierrick@php.net)
55086-v1.diff (last revision 2011-06-30 17:30 UTC by pierrick at webstart dot fr)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-01 16:33 UTC] pierrick@php.net
The following patch has been added/updated:

Patch Name: bug55086.phpt
Revision:   1309552383
URL:        https://bugs.php.net/patch-display.php?bug=55086&patch=bug55086.phpt&revision=1309552383
 [2011-07-01 16:49 UTC] bjori@php.net
-Assigned To: +Assigned To: stef
 [2011-07-01 16:51 UTC] bjori@php.net
-Assigned To: stef +Assigned To: gron
 [2011-07-02 13:12 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=312817
Log: - Fixed bug #55086 (Namespace alias does not work inside trait's use block)
  patch by: Pierrick
 [2011-07-02 13:12 UTC] felipe@php.net
-Status: Assigned +Status: Closed
 [2011-07-02 13:12 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks for the patch!
 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0124c28610ace0814720821060142b3309cd5f87
Log: - Fixed bug #55086 (Namespace alias does not work inside trait's use block)   patch by: Pierrick
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0124c28610ace0814720821060142b3309cd5f87
Log: - Fixed bug #55086 (Namespace alias does not work inside trait's use block)   patch by: Pierrick
 [2013-11-17 09:37 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0124c28610ace0814720821060142b3309cd5f87
Log: - Fixed bug #55086 (Namespace alias does not work inside trait's use block)   patch by: Pierrick
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 22:01:33 2025 UTC