CodeIgniter Forums
Is there a way to see all methods in a class? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Is there a way to see all methods in a class? (/showthread.php?tid=16674)



Is there a way to see all methods in a class? - El Forum - 03-13-2009

[eluser]tdktank59[/eluser]
So im working on creating a script and I need to be able to see all methods within a said class.

Is there a way to do this while in the script? Or is this something I have to manual do for each class?


Is there a way to see all methods in a class? - El Forum - 03-13-2009

[eluser]pistolPete[/eluser]
How about get_class_methods()?


Is there a way to see all methods in a class? - El Forum - 03-13-2009

[eluser]tdktank59[/eluser]
that would be it lol...

I looked through the whole OOP section couldn't find this.
I was looking in the wrong section

Thanks for the fast reply!


Is there a way to see all methods in a class? - El Forum - 12-30-2009

[eluser]Brandon Jackson[/eluser]
Let's say you only want a list of the public methods in a class... this code will help by using the Reflection class.

Code:
foreach (get_class_methods($c) as $key => $val)
            {
                  /* Get a reflection object for the class method */
                       $reflect = new ReflectionMethod($c, $val);

                /* For private, use isPrivate().  For protected, use isProtected() */
                
                if($reflect->isPublic())
                {
                      if (!in_array($val,$this->invalid_methods))
                    {
                        // Put the methods we care about into an array
                        $method[$c][] = $val;
                    }
                }
            }