Edit report at https://bugs.php.net/bug.php?id=55086&edit=1

 ID:                 55086
 Patch added by:     pierr...@php.net
 Reported by:        andrey dot garbuz at gmail dot com
 Summary:            Namespace alias does not work inside trait's use
                     block
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Fedora 14
 PHP Version:        5.4SVN-2011-06-30 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2011-06-30 07:47:02] 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


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55086&edit=1

Reply via email to