P
P
p4s8x2011-10-19 22:03:20
PHP
p4s8x, 2011-10-19 22:03:20

PHP how to know if a method has been overridden?

Is it possible to somehow find out whether a method was declared in a particular class or not, without taking into account the parents?
Those. if it was declared on the parent, but this child does not, then - false, otherwise - true.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ano, 2011-10-19
@p4s8x

Not overloaded, but overridden.
I think it could be something like this:

  (new ReflectionClass($className))->getMethod($methodName)->getDeclaringClass()->name == $className

(disclaimer: I don't remember if it's possible to do in php (new X)->y)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question