note 10549 deleted from function.method-exists by aidan
| From: | aidan@php.net | Date: | Sun, 21 Nov 2004 11:12:37 +0000 |
| Subject: | note 10549 deleted from function.method-exists by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80820@lists.php.net to get a copy of this message | ||
Note Submitter: gateschris at yahoo dot com
----
this function tests the name of a member to see if that member is inherited...
function is_parent_member ($name, $thisclass) {
// this function makes alot of assumptions:
// first: return array is a list not a set (i.e. is ordered)
// second: parent_class exists
// fourth: parent_class has a constructor
// third: class has not overriden the name of the parent_class constructor
$arr = get_class_methods(get_class($thisclass));
$arr2 = get_class_methods(get_parent_class($thisclass));
$started = false;
$copy1 = array ();
while (list($key, $val) = each ($arr)) {
if ($started == false) {
if ($val == get_parent_class($thisclass)) {
$started = true;
}
} else {
$copy1[] = $val;
}
}
$copy2 = array();
$started = false;
while (list($key, $val) = each ($arr2)) {
if ($started == false) {
if ($val == get_parent_class($thisclass)) {
$started = true;
}
} else {
$copy2[] = $val;
}
}
foreach ($copy2 as $val2) {
$found = false;
foreach ($copy1 as $val1) {
if ($val1 == $val2) {
$found = true;
}
}
if ($found == false) {
if ($name == $val2) {
return true;
}
}
}
return false;
}