Re: [RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Rowan Collins | Date: | Sun, 13 Jul 2014 17:01:33 +0000 |
| Subject: | Re: [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75432@lists.php.net to get a copy of this message | ||
On 13/07/2014 17:36, Andrea Faulds wrote:
On 13 Jul 2014, at 17:29, Rowan Collins <rowan.collins@gmail.com> wrote:Oops, my bad, I thought that existed already! :| -- Rowan Collins [IMSoP]It's an interesting thought, but we currently have the object keyword for that particular use case. In some languages, having a base object is useful because functionality can be defined there, but PHP provides no way of altering existing classes, limiting that use too.There’s no such type hint though: $ php -r 'function foo(object $x) {} foo(new StdClass);’ PHP Catchable fatal error: Argument 1 passed to foo() must be an instance of object, instance of stdClass given, called in Command line code on line 1 and defined in Command line code on line 1 Perhaps one should be added? Not in this RFC though, obviously.