I'm working on creating object wrappers for native php types. With ZE2 and
the cast_object object handler, I am able to "unbox" the objects to their
native php types with simple casts, but as ZE2 currently stands, (to my
knowledge at least) there is no way to hook into the (object)native_type
cast. Currently, when you cast a native value to an object using
(object)$native_val, it calls convert_to_object which simply converts the
native type to an array. I was hoping some of you more familiar with the ZE
than I had some ideas of how it may be modified to allow an extension to
hook into the convert_to_object function. Looked around for some
implementation of an extension registering a callback inside the engine but
couldn't find any examples. Here is a userland example of what I am trying
to accomplish:

$intObj = new PInt32(5); // Int object wrapper
$phpInt = (int)$intObj; // Calls the cast_object handler for the PInt32 obj

This next part isn't currently possible
$intObjB = (object)$phpInt;

But if I could hook into the convert_to_object function, I could determine
what type of class to return based on the op->type being cast. It can be
done, just not sure 1) how it would be generic enough (without registering a
callback), and 2) whether you guys would be opposed to it, or 3) am I an
idiot for trying to do this.

Thanks

Bob Silva

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to