Static methods: are they still bad considering PHP 5.3 late static binding?

后端 未结 3 1387
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 16:19

If you search on the reasons why static methods are bad the first thing you find it is because you can\'t override it when you are unit testing.

So is this still tru

3条回答
  •  迷失自我
    2021-01-17 17:25

    If you have a static member function, it could usually be a free function. The usual reaction is then that the coder has opted for a static member function only because of the myth that "everything must be in an object".

    That's why people discourage them.

    And, because it's not a very convincing argument, those people pointed to unit testing instead. Not sure what they'll do now.

提交回复
热议问题