In a lot of controller classes lately, people are using the first segment of the URI as the method, and testing with something like this:

I wanted a way to only allow direct access to public members, not private (or protected).

Neither is_callable nor get_class_methods would solve this, if invoked from within the scope of the class itself (although either would be fine if invoking against an instance that isn’t $this – outside the scope of the class definition).

The solution I used was to employ the ReflectionMethod class, and it’s isPublic method: