extreme
V2EX  ›  PHP

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

  •  
  •   extreme · Aug 13, 2016 · 3703 views
    This topic created in 3565 days ago, the information mentioned may be changed or developed.

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

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

    直接读写数据不符合 OOP 的思想。
    不同的属性需要经过不同的处理才能读写,不然我就不需要这个 Magical Method 了。
    extreme
        4
    extreme  
    OP
       Aug 19, 2016
    @AbrahamGreyson
    看 3L
    而且为了避免外部随便读写和调用,属性和方法肯定就是 private 的了。
    还"::"什么。
    AbrahamGreyson
        5
    AbrahamGreyson  
       Aug 22, 2016
    @extreme 如果这么说的话, getter 和 setter 也是破坏封装性的呀。问题是我们不是想方便么:)
    extreme
        6
    extreme  
    OP
       Sep 8, 2016
    @AbrahamGreyson
    So fucking funny.
    从你的回复就能看出你的水平了,替招到你的公司默哀。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1054 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:37 · PVG 02:37 · LAX 11:37 · JFK 14:37
    ♥ Do have faith in what you're doing.