Re: Convert ext/xml to use an object instead of resource

From: Date: Tue, 12 Feb 2019 16:41:35 +0000
Subject: Re: Convert ext/xml to use an object instead of resource
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-104371@lists.php.net to get a copy of this message
On 12.02.2019 at 17:04, Rowan Collins wrote: > On Tue, 12 Feb 2019 at 15:30, Bishop Bettini <bishop@php.net> wrote: > >> +1 for movement away from resources, generally. >> >> Resources represent connections to external resources, in a manner that's >> opaque to userland [1]. Would it make sense to update is_resource (and >> friends) to be aware that "resources" returned from xml_parser_* are not >> resources proper, but rather resources nominal? > > While such a feature would have limited use in this case, as Johannes > points out, it might be a nice general pattern to establish for migrating > other resources in future. All such objects could implement an empty > "Resource" interface, which couldn't be implemented directly from userland, > and just triggered this magic behaviour. > > There would still be other BC impacts, though; for instance, gettype() > would return "object" instead of "resource", unless we overloaded that > based on the interface as well, which might be a bit confusing. And we must not forget that resource to int conversion is clearly defined, while object to int conversion is not. -- Christoph M. Becker

« previous php.internals (#104371) next »