---- En vie, 26 feb 2021 11:08:33 +0100 Glash Gnome <glash.gn...@gmail.com> 
escribió ----
 > Hola Manuel,
 > "Don't you think the same ?"
 > I was thinking of something more generi, maybe : 
 > ```
 > namespace Foo\Bar;
 > 
 > class A {
 >     static function getNamespace() {
 >         static $ns = __NAMESPACE__;// 
 > https://wiki.php.net/rfc/static_variable_inheritance
 >         return $ns;
 >     }
 > }
 > 
 > namespace My\Baz;
 > class B extends \Foo\Bar\A { }
 > 
 > echo \Foo\Bar\A::getNamespace(), PHP_EOL;// Foo\Bar
 > echo \My\Baz\B::getNamespace(), PHP_EOL;// Foo\Bar  Ho no !```
 > Unfortunately it doesn't work ...
 > 
 > Best regards,Serge
 > 

Hola, Glash,

I sometimes use:

class Foo {
    const NAMESPACE = __NAMESPACE__;
}

Foo::NAMESPACE;

However, this doesn't work:

class Bar extends Foo {

}

Bar::NAMESPACE; // == Foo::NAMESPACE

Regards
--
Manuel Canga

Zend Certified PHP Engineer 
Websites: https://manuelcanga.dev | https://trasweb.net
Linkedin: https://es.linkedin.com/in/manuelcanga

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to