Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121087 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35683 invoked from network); 18 Sep 2023 06:47:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Sep 2023 06:47:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 195BB18005B for ; Sun, 17 Sep 2023 23:47:09 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS17378 206.123.64.0/18 X-Spam-Virus: No X-Envelope-From: Received: from mail1.25mail.st (mail1.25mail.st [206.123.115.54]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 17 Sep 2023 23:47:08 -0700 (PDT) Received: from smtpclient.apple (unknown [49.48.216.113]) by mail1.25mail.st (Postfix) with ESMTPSA id ADF04603CE; Mon, 18 Sep 2023 06:46:58 +0000 (UTC) Message-ID: <4C6FD028-4E34-4578-AF04-EDAC120E3E94@koalephant.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_587284E7-F3F1-4AAD-9C5D-1BCDF2386BE5" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Date: Mon, 18 Sep 2023 13:46:45 +0700 In-Reply-To: <29eb53a7-9aef-4e48-999e-97574f27a9df@gmail.com> Cc: =?utf-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= , PHP Internals To: Niels Dossche References: <29eb53a7-9aef-4e48-999e-97574f27a9df@gmail.com> X-Mailer: Apple Mail (2.3731.700.6) Subject: Re: [PHP-DEV] [RFC] [Discussion] DOM HTML5 parsing and serialization support From: php-lists@koalephant.com (Stephen Reay) --Apple-Mail=_587284E7-F3F1-4AAD-9C5D-1BCDF2386BE5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 17 Sep 2023, at 18:28, Niels Dossche = wrote: >=20 > Hi Alexandru >=20 > On 9/17/23 11:59, Alexandru P=C4=83tr=C4=83nescu wrote: >> On Sat, Sep 16, 2023, 02:17 Niels Dossche = wrote: >>=20 >>>=20 >>> We'll add a common abstract base class DOM\Document (name taken from = the >>> DOM spec & Javascript world). >>> DOM\Document contains the properties and abstract methods common to = both >>> HTML and XML documents. >>>=20 >>>=20 >> Hi, >>=20 >> Yes looks a lot better. >> Great work overall! And thank you for taking on this effort. >>=20 >> I would have a small suggestion: to make the abstract class an = interface. >> This will allow even more flexibility on how things can be build = further, >> suggesting composition over inheritance. >> In user land we cannot have interfaces with properties (yet) but in = php >> internal interfaces we have example with interface UnitEnum that has = name >> property, extendes by BackedEnum that adds value property. >>=20 >=20 > Right, we discussed the use of an interface internally too. > Indeed as you suggest, we chose an abstract class over an interface = because of the property limitation. > Looking at UnitEnum & BackedEnum = (https://github.com/php/php-src/blob/bae30682b896b26f177f83648bd58c77ba348= 0a8/Zend/zend_enum.stub.php) I don't see the properties defined on the = interface. In practice, all enums get the properties of course, just not = via the interface. > So as we cannot represent the properties on the interfaces (yet), = we'll stick with the abstract class for now. >=20 >=20 >> Thank you, >> Alex >>=20 >=20 > Kind regards > Niels >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php Hi Niels, Can you expand on the reasoning for two of the decisions in your = proposal? I'm not sure I really see the reason/benefit : 1. fromX() methods are on the individual classes, rather than the = parent, which as I understand it, you're using as a poor-mans interface = with properties. I'd have thought that at the very least the parent = should declare those methods as abstract 2. Why "fromEmptyDocument()" rather than just allowing `new = DOM\{XML,HTML}Document` via a public constructor? The only mention of 'constructor' I see in the email or the RFC is the = line below: > the properties set by DOMDocument's constructor are overridden by its = load methods, which is surprising But I don't really see how making the constructor private and forcing = use of a static method changes this aspect, at all - it just introduces = a different way to create an instance. Otherwise, it's great to see some activity on DOM handling classes. Cheers Stephen=20 --Apple-Mail=_587284E7-F3F1-4AAD-9C5D-1BCDF2386BE5--