开发者

Is there an equivalent to $this for static classes? ( kind of super but for the current class where it is used )

开发者 https://www.devze.com 2022-12-10 21:45 出处:网络
I know it wouldn\'t be exactly equivalent to $this, but is there a way to reference a static class from within itself without using the name of the class its开发者_开发百科elf?( like super but for its

I know it wouldn't be exactly equivalent to $this, but is there a way to reference a static class from within itself without using the name of the class its开发者_开发百科elf? ( like super but for itself ) This is just a way to avoid having to refactor all the class references if the class is renamed.

Example:

class foo {
    function bar() {
        static_this::method();
        // instead of:
        foo::method();
    }
 }


self::method();
0

精彩评论

暂无评论...
验证码 换一张
取 消