R
R
Rockman2015-05-23 22:24:58
PHP
Rockman, 2015-05-23 22:24:58

How to distinguish a static method from a non-static one?

There is a class with a method:

public function myMethod() {
   // do something
}

The method is not static, but when accessing it: ClassName::myMethod() it will be executed, more precisely, PHP will not give an error when accessed, but will give it later, when it finds $this in the implementation of the method or something else that cannot be in static method. That is, PHP does not distinguish between a non-static method and a static one.
The problem came to light when it became necessary to use the __callStatic() method. It is necessary to handle the moment when a non-existent static method is accessed, but at the same time, the class may well have a non-static method with the same name.
Can any setting in PHP be disabled?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
one pavel, 2015-05-23
@onepavel

A case from a derived class do not pull it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question