static:: vs. self:: - are there any downsides?

隐身守侯 提交于 2019-12-06 00:42:04

Actually it depends only on the use you need. If you need to access the constant of the class in which you are calling it, use self. If you need late static binding use static.

From the point of view of performances, self and static are pretty equivalent.

Also be aware that extensive usage of static combined to override/inheritance is not a great idea.

For a direct answer to your question, I would always prefer the use of static for testing purpose (altho now PHPUnit 4 removed the support for mocking static methods).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!