Re: [RFC] Scalar Type Hinting With Casts (re-opening)

From: Date: Sun, 13 Jul 2014 15:56:31 +0000
Subject: Re: [RFC] Scalar Type Hinting With Casts (re-opening)
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-75423@lists.php.net to get a copy of this message
On 13 Jul 2014, at 16:51, Rowan Collins <rowan.collins@gmail.com> wrote:

> Well, the ability to cast to an object at all is pretty wacky, since PHP has no standard base
> class for objects, nor any mechanism to cast to or from specific classes, etc.

Somewhat off-topic, but maybe we should make StdClass be the actual base class? I mean, it’s
already used as a generic object, and you could then put StdClass as a type hint if you’re using
an object as a key/value store but want to allow sophisticated objects to be passed.

Also, we don’t have a mechanism to cast between classes mostly because we don’t need it; if Bar
extends Foo and a function takes a Foo, it can also take a Bar.
--
Andrea Faulds
http://ajf.me/






Thread (250 messages)

« previous php.internals (#75423) next »