Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104365 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19573 invoked from network); 12 Feb 2019 19:13:50 -0000 Received: from unknown (HELO mail.experimentalworks.net) (84.19.169.162) by pb1.pair.com with SMTP; 12 Feb 2019 19:13:50 -0000 Received: from kuechenschabe.fritz.box (ppp-188-174-113-86.dynamic.mnet-online.de [188.174.113.86]) by mail.experimentalworks.net (Postfix) with ESMTPSA id A07715318C; Tue, 12 Feb 2019 16:56:44 +0100 (CET) Message-ID: <1549987000.2902.28.camel@schlueters.de> To: bishop@php.net, Nikita Popov Cc: PHP internals Date: Tue, 12 Feb 2019 16:56:40 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Convert ext/xml to use an object instead of resource From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) 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