Re: Invokation on __toString() for object used as array key
| From: | Stas Malyshev | Date: | Wed, 24 Sep 2014 19:59:42 +0000 |
| Subject: | Re: Invokation on __toString() for object used as array key | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77590@lists.php.net to get a copy of this message | ||
Hi!
> I already figured out how to solve the
is_resource() issue.
> Create
> an almost-useless, uninstantiatable class called Resource which any
> new resource-replacing classes inherit from. Then, make
> is_resource() check whether something is an instance of that
> class.
This is a nice idea, but maybe interface would be even better?
> Of course, 3rd-party extensions are still a problem, but this should
> mostly fix it. Of course, gettype() is still going to return “object”
> not “resource”, but I suspect people are more likely to use
> is_resource().
yeah, I don't think I've seen many examples of something like checking
gettype() of fopen() return. I've definitely seen checking it for
is_resource.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/