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

From: Date: Tue, 12 Feb 2019 15:56:40 +0000
Subject: Re: Convert ext/xml to use an object instead of resource
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-104365@lists.php.net to get a copy of this message
On Di, 2019-02-12 at 10:29 -0500, Bishop Bettini wrote: > 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? > > If userland needed to strictly determine what was a resource proper > and what was a resource nominal, we could improve the signature: > is_resource(mixed $var, bool $strict = false). But, honestly, the > aforementioned opaqueness makes me think this wouldn't be necessary. How do you distinguish an object with a "resource" from one not representing such a thing? - Any object? - All internal ones? - Add a class_entry flag? - Hardcode a list? None of those really make sense to me. The is_* routines look at PHP's type system, the information for general use is limited (we don't have ReflectionResource as well ... while that couldn't do much anyways as a resource is only a void*) The only use case here seems to be    $foo = xml_*();    if (!s_resource($foo)) error(); Which is limited, since the only xml function returning a resource seems to be xml_parser_create() which will always succeed (except out of memory or similar) johannes

« previous php.internals (#104365) next »