Why PHP uses static methods in object context?

前端 未结 3 1909
日久生厌
日久生厌 2021-01-01 22:41

I have the following code (like, for real, this is my real code) :



        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-01 23:14

    Since PHP is quite a forgiving language you could prevent this default behavior by overloading __callStatic and maybe use reflections to validate the method scope.

    http://php.net/manual/en/language.oop5.overloading.php#object.call

    http://php.net/ReflectionClass

提交回复
热议问题