Hi!

> So, what do you think of a set of interfaces that allow userland objects to
> be used as scalar types?
> 
> Some simple examples in PHP here:
> https://gist.github.com/guiwoda/5d16c8fb97d29e476d20

We already have CastToString, it's __toString. I'm not sure we need a
named interface for that, as checking for the method would be basically
the same, and practically I do not see anybody wanting to type against
such type (i.e. you'd do foo(int $a) but not foo(CastToInt $a)). As for
others, we in fact have cast_object handler for the objects, so
extensions can already do that. Giving user functions access to it would
be not hard, though I'm not sure it won't complicate some things. But I
think if enough people need it, enabling full user-space access to
cast_object should not be a problem. Definitely needs a good RFC though
with good convincing examples of use cases.

-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to