Hello Internals, I had requested a wiki account (mwillbanks) as I would like to propose an RFC on Object casts to scalar types. This has previously been discussed prior to scalar type hints and since we have those now coming into PHP 7, I believe it would be a great time to take a look at this for 7.1 (Discussion will not be immediate as focus needs to be put into 7.0)
The last RFC had gone inactive back from 2012: https://wiki.php.net/rfc/object_cast_to_types and I have talked with ircmaxell about doing something similar but making it more inline with STH as well as supporting a generalized __cast. The general cruft of it is to have objects have the ability to support: + __toInt + __toFloat + __toBool + __toArray + __cast Removing the existing having __toScalar as it would no longer make sense in this context. __cast would be utilized more or less as function((int) constant_type) where as it may mean PHP_TYPE_* as initial feedback on the idea showed that it would be the most generalist approach and might be useful in that context. Regards, Mike