In a recent discussion on the PHP internals list Andi asked why ReflectionClass::getMethod() throws an exception when the requested method doesn’t exist instead of returning NULL. During the discussion it came out that it brings advantages to throw an exception when doing things like $class->getMethod(‚foo‘)->isInternal(); or if you really like exceptions. In addition it brings consistency with ReflectionMethod’s constructor which throws an exception too when a method can not be found. But since exceptions aren’t a good instrument just to check wether a method does (not) exist the conclusion was to add a ReflectionClass::hasMethod() method which simply returns a bool. Since I’m currently learning how this PHP stuff works I wrote a patch which was committed by Marcus this morning.
Kurze Unterbrechung
DAS IST DEIN ALLTAG?
Keine Sorge – Hilfe ist nah! Melde Dich unverbindlich bei uns und wir schauen uns gemeinsam an, ob und wie wir Dich unterstützen können.
Schreibe einen Kommentar