Re: [RFC] [Discussion] Add openStream() to XML{Reader,Writer}
| From: | Niels Dossche | Date: | Wed, 22 May 2024 17:47:36 +0000 |
| Subject: | Re: [RFC] [Discussion] Add openStream() to XML{Reader,Writer} | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123404@lists.php.net to get a copy of this message | ||
On 21/05/2024 21:58, Claude Pache wrote:
>
>
>> Le 21 mai 2024 Ã 21:00, Matthew Weier O'Phinney <mweierophinney@gmail.com> a
>> écrit :
>>
>> (But again, I prefer that all those methods work on instances, as it was the case
>> before PHP 8. They shouldn’t have been switched to static-but-broken-for-subclasses without
>> discussion.)
>>
>>
>> Fixing the existing ones would be a potential BC break, depending on whether or not
>> instance usage is completely eliminated.
>
> Yes, of course. But there exist options that don’t make the API even more inconsistent than
> it already is. I hereby propose:
>
> *
XMLReader::fromUrl() as replacement for (new
> XMLReader)->open()
> * XMLReader::fromString() as replacement for ‚”©Y
> ØU¿k¬‰Â¢(new XMLReader)->xml()
>
> … which would make me happy. (The old, inconsistently-named, instance-and-semi-broken-static
> methods could be kept for BC and marked as soft-deprecated in the manual.)
>
> —ClaudeÂ
Okay, that seems reasonable to me and I can do that.
I'll make them return static and do "new static()" like I proposed with the new
static method.
For XMLWriter, I suppose we also want the static counterparts:
* XMLWriter::toMemory() for (new XMLWriter)->openMemory()
* XMLWriter::toUri() for (new XMLWriter)->openUri()
If that sounds good I'll update the RFC.
Niels