rfc:object_cast_to_types
Differences
This shows you the differences between two versions of the page.
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/12/03 06:59] – addvilz | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Request for Comments: Scalar Type Casting Magic Methods ===== | ===== Request for Comments: Scalar Type Casting Magic Methods ===== | ||
- | * Version: 0.1 | + | * Version: 0.2 |
* Date: 2012-03-03 | * Date: 2012-03-03 | ||
* Author: Anthony Ferrara < | * Author: Anthony Ferrara < | ||
+ | * Maintainer: Matiss Treinis < | ||
* Status: In Draft | * Status: In Draft | ||
* Patch: https:// | * Patch: https:// | ||
Line 8: | Line 9: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Currently, the Zend Engine exposes several methods to PECL extensions and internal classes to control how internal objects behave when casting to primitives. | + | Currently, the Zend Engine exposes several methods to PECL extensions and internal classes to control how internal objects behave when casting to primitives. |
===== Use Cases ===== | ===== Use Cases ===== | ||
Line 18: | Line 19: | ||
* Creating strict-typing functionality with entirely user-land code (having a variable that until unset cannot be assigned to with anything except an integer for example) | * Creating strict-typing functionality with entirely user-land code (having a variable that until unset cannot be assigned to with anything except an integer for example) | ||
* Having object code be compatible with existing scalar-typed code. An example would be SplFixedArray would be enabled to be passed to any function (including internal functions) that expect arrays which are not passed by reference. | * Having object code be compatible with existing scalar-typed code. An example would be SplFixedArray would be enabled to be passed to any function (including internal functions) that expect arrays which are not passed by reference. | ||
+ | * Allows for objects to carry a Boolean state (to be truthy and falsy) | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 25: | Line 27: | ||
This RFC and patch introduces 4 new magic methods: | This RFC and patch introduces 4 new magic methods: | ||
- | * '' | + | |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
+ | * '' | ||
==== Handler Behavior ==== | ==== Handler Behavior ==== | ||
- | When the cast_object handler is called, the type parameter is switched against to determine which magic method to call. The four possibilities include '' | + | When the cast_object handler is called, the type parameter is switched against to determine which magic method to call. The four possibilities include '' |
When the get handler is called, the '' | When the get handler is called, the '' | ||
Line 45: | Line 48: | ||
| | ||
| | ||
+ | | ||
==== Backwards Compatibility Breaks ==== | ==== Backwards Compatibility Breaks ==== | ||
Line 57: | Line 61: | ||
This means that an object implementing '' | This means that an object implementing '' | ||
+ | |||
+ | ===== Todo ===== | ||
+ | |||
+ | * Patch could use an update. | ||
+ | * How could and will this interact with comparison and control structures like, '' | ||
===== Further reading ===== | ===== Further reading ===== | ||
Line 65: | Line 74: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
- |
rfc/object_cast_to_types.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1