V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
extreme
V2EX  ›  PHP

为何 PHP 有__callStatic(),没有__(get|set)Static()

  •  
  •   extreme · 2016 年 8 月 13 日 · 3519 次点击
    这是一个创建于 3439 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我就是不想加括号读写静态属性,太不美观了

    6 条回复    2016-09-08 13:50:04 +08:00
    hz251
        1
    hz251  
       2016 年 8 月 14 日
    ReflectionClass::getStaticPropertyValue
    AbrahamGreyson
        2
    AbrahamGreyson  
       2016 年 8 月 17 日
    本来就可以直接 Class::$property , 还要什么 setter 阿:)
    extreme
        3
    extreme  
    OP
       2016 年 8 月 19 日
    你为什么不说本来就可以 Class::method()。

    直接读写数据不符合 OOP 的思想。
    不同的属性需要经过不同的处理才能读写,不然我就不需要这个 Magical Method 了。
    extreme
        4
    extreme  
    OP
       2016 年 8 月 19 日
    @AbrahamGreyson
    看 3L
    而且为了避免外部随便读写和调用,属性和方法肯定就是 private 的了。
    还"::"什么。
    AbrahamGreyson
        5
    AbrahamGreyson  
       2016 年 8 月 22 日
    @extreme 如果这么说的话, getter 和 setter 也是破坏封装性的呀。问题是我们不是想方便么:)
    extreme
        6
    extreme  
    OP
       2016 年 9 月 8 日
    @AbrahamGreyson
    So fucking funny.
    从你的回复就能看出你的水平了,替招到你的公司默哀。
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1576 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 146ms · UTC 16:29 · PVG 00:29 · LAX 08:29 · JFK 11:29
    ♥ Do have faith in what you're doing.