Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
rfc:object_cast_to_types [2012/03/04 01:23] – [Handler Behavior] ircmaxell | rfc:object_cast_to_types [2013/09/03 12:28] – Withdrawn ircmaxell |
---|
* Date: 2012-03-03 | * Date: 2012-03-03 |
* Author: Anthony Ferrara <ircmaxell@php.net> | * Author: Anthony Ferrara <ircmaxell@php.net> |
* Status: In Draft | * Status: Withdrawn |
* Patch: https://gist.github.com/1966809 | * Patch: https://gist.github.com/1966809 |
| |
This RFC and patch introduces 4 new magic methods: | This RFC and patch introduces 4 new magic methods: |
| |
* ''__toInt()'' - Called when casting an object explicitly to an integer (or passing it to an internal function which expects an integer) | * ''_ _toInt()'' - Called when casting an object explicitly to an integer (or passing it to an internal function which expects an integer) |
* ''__toFloat()'' - Called when casting an object explicitly to a float (or passing it to an internal function which expects a float) | * ''_ _toFloat()'' - Called when casting an object explicitly to a float (or passing it to an internal function which expects a float) |
* ''__toArray()'' - Called when casting an object explicitly to an array (or passing it to an internal function which expects an array) | * ''_ _toArray()'' - Called when casting an object explicitly to an array (or passing it to an internal function which expects an array) |
* ''__toScalar()'' - Called when using an object in an implicit scalar scope without type information (for example: ''$obj + 1''). | * ''_ _toScalar()'' - Called when using an object in an implicit scalar scope without type information (for example: ''$obj + 1''). |
| |
==== Handler Behavior ==== | ==== Handler Behavior ==== |
* https://wiki.php.net/internals/engine/objects#set | * https://wiki.php.net/internals/engine/objects#set |
* https://wiki.php.net/internals/engine/objects#cast_object | * https://wiki.php.net/internals/engine/objects#cast_object |
| |