Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123385 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 23B531A009C for ; Tue, 21 May 2024 19:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716318095; bh=31YdhBBGye6jY1nzMnvCBGQP0GEozvvw59XgWGFYXJA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=c5cTufgsbo98N9tLl0KeusoU0HOdIKOnvfvwow5prU6kTHBn73p4BUEjSFl8rbpvi /XqWtjfoLpfaeZ2BdMS71yq4pRDE3zmWGuT2qXvua/UnRx1gK4tnG5NbnbmQks762S RUpTD3hUgpFmqOq51Yd/iu0w2RW6T2Z4Hz1F/06UzUBI5sf5UPdl6L9NfnCT5/0beH iFoRp0zTf7VeJWxuHL6t4ayciZo/dKEM4PKG3fBEehLo05RQ5jCFxlsXh+Cdf2QQJ6 gvlQDC1Iby/WVokPAj58qbkcdZZD36NV3u9EuuNnje/2aGZlBvECORv6PFrQd7J1hn RvM7zWc5pM4fA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F3B3618067A for ; Tue, 21 May 2024 19:01:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 May 2024 19:01:31 +0000 (UTC) Received: by mail-vk1-f176.google.com with SMTP id 71dfb90a1353d-4df9b81502eso1803075e0c.2 for ; Tue, 21 May 2024 12:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716318035; x=1716922835; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hZz1IUdh0VMirpeBd8aWJqSmfgn0+2+c0EFpcQSh7Mc=; b=LAjUVIrXyORqMilPehQWMmSBFkCoueLnuSuklTQutq8KYzvHzxIajqSR2oBLpU+MtU 6mytPDHTG1ZAyY8ATDDQJgk4dOH2xYYcVIsF9VMK89aMVjj3dPwQCiK4/Klp9ae7PVS+ uueGdDGWEdWYbf5CU8tJTp8z8ymOob7GWO+z9hR8MxmzN+eg8Hg34XrSfPqILq8euGnU YNjlkeXuYs+YEMgNO8JTtWtlybXQDISb9oM0N0Si2nSBBBSmjNIUE9HRHw5+WhQfL22R iQiNC2gBpFHrGdX7EyG7JClC+LnkPGl8SHuo5rSMof0/YJG7EFr8Gyi7X4zRBcbvRxD2 NqtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716318035; x=1716922835; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hZz1IUdh0VMirpeBd8aWJqSmfgn0+2+c0EFpcQSh7Mc=; b=LpUt9nSbOPQRuG8qTLlf7joCKix+25uTZucpTJYM2ALJAii/3ukcwGjXmhB5CttpX8 WIkSiu9g20aEFuHQFD5Q7eOZ17J+aVbTyqvlR7Vbf8+4rDcYa1d2X9+ro3AObuE07Vbv Z3/PrbPM53/wVJNjTzm/46XBeyIEWnaQ7jGQJkDxnrcI+WLJKUnnPaz9iHC8g3PL8JSN /UghPmig+h+T3wv9f9zyUYul8TPjQvNhh7Ics7Y5DPXcP47ooOtn/A2d301KBq8suOvs ZCAQl1v5kLAT6UJZuNHjEOHYLzFsatsjPe7hEZjpp6tzd1hfiek4T/wEGG1odA1+sJIS 2Zcg== X-Forwarded-Encrypted: i=1; AJvYcCXCcbKLG+0jH7iLQuJzFgoSyLvifwgMRqI5cTCKCZdi5FDeeQFZsfWIcjq7XO27DQh3E7GQ+nwhAp3UTCV6pcuzOnQJBDmd2g== X-Gm-Message-State: AOJu0YwRAR6HEsRO3+bdGv6QxcKHBMyPMP8rvcbQ6p541wrBClQz9f05 wIWADIqjClTf1aaktwl8k1M7EoUwVmHE10g94LY7DptODddY2xlsaVtti5eXBCTb8q2Yr59cuH9 ycK6lssftUnZ4bqD0nWpyC6YF5BvSue/1 X-Google-Smtp-Source: AGHT+IGt5RbKbKMmlx8FkPPhimzEZuMeWniF71Uic6littpXvujyGIIRONq3aX2xGqW/c2rGdakfl+Q9+O/Xj+36UCI= X-Received: by 2002:a05:6122:1693:b0:4d4:3ec6:421e with SMTP id 71dfb90a1353d-4df882a870fmr30639075e0c.4.1716318032933; Tue, 21 May 2024 12:00:32 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <37BF3748-4A18-4046-8CCD-4198094FE059@gmail.com> In-Reply-To: <37BF3748-4A18-4046-8CCD-4198094FE059@gmail.com> Date: Tue, 21 May 2024 14:00:21 -0500 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Add openStream() to XML{Reader,Writer} To: Claude Pache Cc: Niels Dossche , PHP internals Content-Type: multipart/alternative; boundary="000000000000acba920618fb6e4f" From: mweierophinney@gmail.com ("Matthew Weier O'Phinney") --000000000000acba920618fb6e4f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 21, 2024 at 12:58=E2=80=AFPM Claude Pache wrote: > > > > Le 18 mai 2024 =C3=A0 01:13, Niels Dossche a = =C3=A9crit > : > > > > On 22/04/2024 20:41, Niels Dossche wrote: > >> Hi internals > >> > >> I'm opening the discussion for my RFC "Add openStream() to > XML{Reader,Writer}". > >> RFC link: https://wiki.php.net/rfc/xmlreader_writer_streams > >> > >> Kind regards > >> Niels > > > > Hi internals > > > > The main complaint that kept coming up in internal communication was th= e > choice of instance methods instead of static methods. > > This has been brought up in this thread too. > > Hi, > > Now you have a complaint because of the choice of static methods instead > of instance methods... :-) > > You are introducing an inconstancy for subclasses, because: > > * As noted in an earlier message, the existing open-like methods > (XMLReader::XML() and XMLReader::open()) don=E2=80=99t work statically on > subclasses (they create an instance of the base class, not of the > subclass). You must use them as instance methods. > > * On the other hand, the method you are going to introduce won=E2=80=99t = work as > instance method. You must use it statically. > > Please, if you want to make the new method static only, fix first the > existing ones, so that they also work statically (on subclasses). > > (But again, I prefer that all those methods work on instances, as it was > the case before PHP 8. They shouldn=E2=80=99t 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. The reason why many of us recommended static methods here is that they would act as named constructors, and reduce the potential for cases where a new stream is read from or written to mid-flight. Essentially, the usage becomes: $reader =3D XMLReader::fromStream($streamHandle); // read the stream and $writer =3D XMLWriter::toStream($streamHandle); // write to the stream My understanding is that the implementations will allow for subclassing. Having these as instance methods means that subclasses would need to potentially add handling to ensure the instance is not in an invalid state (e.g., by switching streams mid-flight), which would add far more edge cases to handle. --=20 Matthew Weier O'Phinney mweierophinney@gmail.com https://mwop.net/ he/him --000000000000acba920618fb6e4f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, May 21, 2024 at 12:58=E2=80= =AFPM Claude Pache <claude.pac= he@gmail.com> wrote:


> Le 18 mai 2024 =C3=A0 01:13, Niels Dossche <dossche.niels@gmail.com> a =C3= =A9crit :
>
> On 22/04/2024 20:41, Niels Dossche wrote:
>> Hi internals
>>
>> I'm opening the discussion for my RFC "Add openStream() t= o XML{Reader,Writer}".
>> RFC link: https://wiki.php.net/rfc/xmlread= er_writer_streams
>>
>> Kind regards
>> Niels
>
> Hi internals
>
> The main complaint that kept coming up in internal communication was t= he choice of instance methods instead of static methods.
> This has been brought up in this thread too.

Hi,

Now you have a complaint because of the choice of static methods instead of= instance methods... :-)

You are introducing an inconstancy for subclasses, because:

* As noted in an earlier message, the existing open-like methods (XMLReader= ::XML() and XMLReader::open()) don=E2=80=99t work statically on subclasses = (they create an instance of the base class, not of the subclass). You must = use them as instance methods.

* On the other hand, the method you are going to introduce won=E2=80=99t wo= rk as instance method. You must use it statically.

Please, if you want to make the new method static only, fix first the exist= ing ones, so that they also work statically (on subclasses).

(But again, I prefer that all those methods work on instances, as it was th= e case before PHP 8. They shouldn=E2=80=99t have been switched to static-bu= t-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.

The reason why many of us recommended static methods here is that the= y would act as named constructors, and reduce the potential for cases where= a new stream is read from or written to mid-flight. Essentially, the usage= becomes:

=C2=A0 =C2=A0 $reader =3D XMLReader::fro= mStream($streamHandle);
=C2=A0 =C2=A0 =C2=A0// read the stream

and

=C2=A0 =C2=A0 $writer = =3D XMLWriter::toStream($streamHandle);
=C2=A0 =C2=A0 // write to= the stream

My understanding is that the implement= ations will allow for subclassing.

Having these as= instance methods means that subclasses would need to potentially add handl= ing to ensure the instance is not in an invalid state (e.g., by switching s= treams mid-flight), which would add far more edge cases to handle.

--
he/him
--000000000000acba920618fb6e4f--