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

From: Date: Tue, 12 Feb 2019 22:13:33 +0000
Subject: Re: Convert ext/xml to use an object instead of resource
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-104375@lists.php.net to get a copy of this message
On Tue, Feb 12, 2019 at 11:21 AM Sara Golemon <pollita@php.net> wrote: > On Tue, Feb 12, 2019 at 10:18 AM Nikita Popov <nikita.ppv@gmail.com> > wrote: > > Very much opposed to any kind of special handling for is_resource(). We > > used to do this for is_object() and __PHP_Incomplete_Class and I'm very > > happy to be rid of this special behavior. Let's not add is back in a new > > place. > > > Agreed. This is something that we discuss every time a resource->object > conversion comes up and we always agree that special-casing lies the way of > madness and the tiny fraction of user code that actually checks this can > adapt if (is_resource($x) || $x instanceof NewClassName) > Done and > sorted. Let's skip this repeat of the past and move forward with the > killing all resources with fire. > Ok. Thinking longer range, perhaps we should prepare users for these transitions by improving the documentation. For example, xml_parser_create returns false on failure, but the manual <http://php.net/manual/en/function.xml-parser-create.php> makes no mention of this. If we had this documented, we might see more if (false == $x) in the wild than the (worse IMO) if (is_resource($x)). It might also help to comment on resource factories that working with the return value as a resource proper is discouraged. I'll do this for xml_parser_create*.

« previous php.internals (#104375) next »