note 51795 added to function.get-class-methods
| From: | OliFilth at osu1 dot php dot net | Date: | Mon, 11 Apr 2005 15:21:21 +0000 |
| Subject: | note 51795 added to function.get-class-methods | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87843@lists.php.net to get a copy of this message | ||
As an extension to onesimus's code below for finding inherited methods, in PHP 5 you can use
the Reflection API to find which of these are overriden.
e.g.
<?php
function get_overriden_methods($class)
{
$rClass = new ReflectionClass($class);
$array = NULL;
foreach ($rClass->getMethods() as $rMethod)
{
try
{
// attempt to find method in parent class
new ReflectionMethod($rClass->getParentClass()->getName(),
$rMethod->getName());
// check whether method is explicitly defined in this class
if ($rMethod->getDeclaringClass()->getName()
== $rClass->getName())
{
// if so, then it is overriden, so add to array
$array[] .= $rMethod->getName();
}
}
catch (exception $e)
{ /* was not in parent class! */ }
}
return $array;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.get-class-methods.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51795
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51795&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51795&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51795&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51795&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51795&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51795&report=yes
Search -- http://master.php.net/manage/user-notes.php