From:             
Operating system: Linux
PHP version:      5.3.6
Package:          *General Issues
Bug Type:         Feature/Change Request
Bug description:Late static binding effect for __NAMESPACE__

Description:
------------
I've been chilling around with the latest PHP features and noticed that
there is 

something missing - there is no way to get the current namespace if
inheriting 

some implementation, which limit us on some implementations.



For example, we have an abstract class in one namespace and adapter for the
very 

same class in another namespace. If we try to use the __NAMESPACE__ within
the 

abstract class, it uses its own one and not the one of the inheriting
class. I've 

checked the documentation to find some notes on this one to no avail.

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

namespace SomeNamespace {

        abstract class SomeAdapterAbstract {

                public function getNamespace() { 

                        return __NAMESPACE__;

                }

        }

}



namespace SomeNamespace\Adapters {

        use \SomeNamespace\SomeAdapterAbstract;



        class SomeAdapter extends SomeAdapterAbstract {};



        $adapter = new SomeAdapter;



        var_dump($adapter->getNamespace());

}

Expected result:
----------------
nikola@nikola-pc:~$ php test2.php 

string(13) "SomeNamespace\Adapters"



Actual result:
--------------
nikola@nikola-pc:~$ php test2.php 

string(13) "SomeNamespace"



-- 
Edit bug report at http://bugs.php.net/bug.php?id=54555&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=54555&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=54555&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=54555&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=54555&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54555&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=54555&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=54555&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=54555&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=54555&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=54555&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=54555&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=54555&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=54555&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=54555&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54555&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54555&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=54555&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=54555&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=54555&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=54555&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=54555&r=mysqlcfg

Reply via email to