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

From: Date: Tue, 12 Feb 2019 16:12:31 +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-104368@lists.php.net to get a copy of this message
On Tue, Feb 12, 2019 at 11:04 AM Rowan Collins <rowan.collins@gmail.com> 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. > Exactly. I hope we would adopt a long-vision, since migrating from resources to objects has been discussed as the desired future state of things. > 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. > I think gettype should return "resource" for BC, but get_resource_type would be free to add more context about the now-object nature.

« previous php.internals (#104368) next »