[PHP-DEV] is_subclass_of() patch

2002-01-29 Thread Andrei Zmievski

Right now is_subclass_of() will return false if the object is exactly of
the class you are trying to test for. I propose the following patch:

--- zend_builtin_functions.c2002/01/06 15:21:09 1.107
+++ zend_builtin_functions.c2002/01/29 21:02:05
@@ -553,5 +553,5 @@
zend_str_tolower(lcname, (*class_name)->value.str.len);
 
-   for (parent_ce = Z_OBJCE_PP(obj)->parent; parent_ce != NULL; parent_ce = 
parent_ce->parent) {
+   for (parent_ce = Z_OBJCE_PP(obj); parent_ce != NULL; parent_ce = 
+parent_ce->parent) {
if (!strcmp(parent_ce->name, lcname)) {
efree(lcname);

This should make it easy to use is_subclass_of() as a generic "is-a"
function.

I can go ahead and apply it if there are not objections. Please copy me
on the replies.

-Andrei

"When a man sits with a pretty girl for an hour, it seems like a minute.
But let him sit on a hot stove for a minute, and it's longer than any hour.
That's relativity."
-- Einstein, on relativity

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] is_subclass_of() patch

2002-01-30 Thread Andi Gutmans

Sounds OK to me although it might be confusing with the name of this
function.

Andi

On Tue, 29 Jan 2002, Andrei Zmievski wrote:

> Right now is_subclass_of() will return false if the object is exactly of
> the class you are trying to test for. I propose the following patch:
> 
> --- zend_builtin_functions.c2002/01/06 15:21:09 1.107
> +++ zend_builtin_functions.c2002/01/29 21:02:05
> @@ -553,5 +553,5 @@
> zend_str_tolower(lcname, (*class_name)->value.str.len);
>  
> -   for (parent_ce = Z_OBJCE_PP(obj)->parent; parent_ce != NULL; parent_ce = 
>parent_ce->parent) {
> +   for (parent_ce = Z_OBJCE_PP(obj); parent_ce != NULL; parent_ce = 
>parent_ce->parent) {
> if (!strcmp(parent_ce->name, lcname)) {
> efree(lcname);
> 
> This should make it easy to use is_subclass_of() as a generic "is-a"
> function.
> 
> I can go ahead and apply it if there are not objections. Please copy me
> on the replies.
> 
> -Andrei
> 
> "When a man sits with a pretty girl for an hour, it seems like a minute.
> But let him sit on a hot stove for a minute, and it's longer than any hour.
> That's relativity."
> -- Einstein, on relativity
> 
> 


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] is_subclass_of() patch

2002-01-30 Thread Andrei Zmievski

On Wed, 30 Jan 2002, Andi Gutmans wrote:
> Sounds OK to me although it might be confusing with the name of this
> function.

Yes. I have something in mind for ZE2 - I'll work up a patch and send it
to you.

-Andrei

Any sufficiently advanced bug is
indistinguishable from a feature.
-- Rich Kulawiec

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]