Is it possible to overuse late static binding in PHP?

前端 未结 3 1886
说谎
说谎 2020-12-31 07:04

Starting with version 5.3, PHP supports late binding for static methods. While it\'s an undoubtedly useful feature, there are only several cases where its use is really nece

3条回答
  •  温柔的废话
    2020-12-31 08:03

    Where I find a need to use late static binding is to allow mocking of static methods for unit testing with PHPUnit. The problem I have is that I don't like changing code strictly to allow mocking, but I can get over that.

    To answer your question, however, I would bet that whatever performance cost this carries, it will pale in comparison to most program runtimes. In other words, it won't make a noticeable difference.

提交回复
热议问题