Extension: "Castable" (name not definitive)

From: Date: Sun, 23 Nov 2008 09:14:23 +0000
Subject: Extension: "Castable" (name not definitive)
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-5908@lists.php.net to get a copy of this message
Hello, This is an extension I wrote to answer bug #46128 ( http://bugs.php.net/46128 ) on PHP's bugtracker. This extension provides a new interface named "Castable". All classes implementing this interface must provide a __cast() function which receives one argument. The values accepted by __cast() have been changed from my initial patch against the ZendEngine to match values accepted/returned by settype()/gettype(). Cast to array() is still not possible as it's handled in a completly different way by the Zend Engine itself, however work will be done in this direction. Casts to other types of classes are not possible either as there's currently no way in PHP to explicitly cast a value in something else than a native type. (basically, only casts to scalar types will work) Install process on linux: svn co http://ookoo.org/svn/snip/phpcastable/ cd phpcastable phpize ./configure --enable-castable make make install And add a line to your php.ini to load castable.so Some example PHP code is available: http://ookoo.org/svn/snip/phpcastable/test.php http://ookoo.org/svn/snip/phpcastable/test2.php Mark Le lundi 27 octobre 2008 à 23:31 +0100, Netmosfera.it a écrit : > hello Mark, -131.php- > > @Mark > i've really appreciated your contribution about this php feature > i'm wondering an improved version > > please read > -- > http://bugs.php.net/bug.php?id=46404 > about > type hinting > native user implementation > -- > > it is the same thing you made! > > but the magic method should be automatically called without casting > > $myobject = new Collector(); > implode($myobject, ...); // arg0 requires array... so the patch > should try to call "__cast" and check the return result > > new Number(22) * new Number(2) // same thing > > how can make pressure to php team in order to get this feature built in > with php? > > thank you for your time, and excuse me for my english > > bye!

« previous php.pecl.dev (#5908) next »