Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122064 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36836 invoked from network); 29 Dec 2023 23:37:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2023 23:37:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8057818004D for ; Fri, 29 Dec 2023 15:38:01 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 ; Fri, 29 Dec 2023 15:38:01 -0800 (PST) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-40d5b7b8adfso18266305e9.0 for ; Fri, 29 Dec 2023 15:37:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703893052; x=1704497852; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=KQ6nYO97gbI+LFVV4KLE0Z/ruhRvwpCPnwZm9S76sUM=; b=OHOLsjF3vA09QqeIiMNj3QMBwOBDk4p/2o1S0NXZJCnrDNnuz6JcZTWchPfh3RGCLI JRUcG/TC9GnfF1ZonLkJMoz1YJ4hf4cxz6GNpLOOshs+5BHalI2d7TLvlXjYLJh3tQR/ 8tVy0KHMd2Fksl2cdhU9Uik4v0jSEZ3+kriRPPGp5f8G7cAG3+bUALS1+O40Y+toPfnF /TPS5i968iIM10bBzjWWAn9bih3BbB0NyVm/DIID5hLOKwYZ6SWjDuKCMYRl/wCG4Ibc wINHpYsAcOEp1HccN/PA4kXHS+5oC3WYXqozSXFs7tAuJLA5p6dtN6BWMN1tgevpHBl7 wp4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703893052; x=1704497852; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KQ6nYO97gbI+LFVV4KLE0Z/ruhRvwpCPnwZm9S76sUM=; b=h4Udp1Nk9Q0d4q4HzvjIjEApeUyiQtj8N8kBemUo0QZnKB3PmiNfgDcCd6/qowTvRV xA+uaDIhDFx45eEYAuqVatya+iCUWZoGc/EJXP+nJ1qnV1W6aBL8JRD8FDGdaignNQZ4 k7P94SIO5sig6tPkYlD2r1tijq7JfiZFI0JUt0VpDhy40i4u6opQuhOg471pNv0WQuJV A5NEosotu1v3Mr51S56cRgMNUYtYDCcxA5M96V/YCxjHxDe1ffxYIK+AMGDktLqsn8K3 4zX0yLUmSqNKmXtGnvN4OsJF3f0PWw3dQLUYZDWHiBQGUDqR9QdgLR5zaoW6m4rmitgJ WTNw== X-Gm-Message-State: AOJu0YwDYCmDVv/S0eXle5cUpiZSPQ+zck4MKTpdcth+m34hzhZVFqyO lLbefaq5KPyty6478UIY570= X-Google-Smtp-Source: AGHT+IFhUwPcQ+XRD2Sy4sj8/ljXUjoMahczH36U8ZxCggEwIFaptpL9Nyom9QRXA9lEtDqhzFMFXA== X-Received: by 2002:a05:600c:3c94:b0:40d:62c4:3ea with SMTP id bg20-20020a05600c3c9400b0040d62c403eamr1651786wmb.6.1703893051845; Fri, 29 Dec 2023 15:37:31 -0800 (PST) Received: from ?IPV6:2a02:1811:cc83:ee30:8e76:2662:766d:ebaa? (ptr-dtfv04vjm7u23t23d7u.18120a2.ip6.access.telenet.be. [2a02:1811:cc83:ee30:8e76:2662:766d:ebaa]) by smtp.gmail.com with ESMTPSA id n42-20020a05600c502a00b0040b3d8907fesm32492056wmr.29.2023.12.29.15.37.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Dec 2023 15:37:31 -0800 (PST) Message-ID: Date: Sat, 30 Dec 2023 00:37:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: "G. P. B." Cc: PHP internals References: <756bcf2b-f98d-4203-9004-1cbfd402337a@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Pre-RFC: Fixing spec bugs in the DOM extension From: dossche.niels@gmail.com (Niels Dossche) Hi Gina On 29/12/2023 15:40, G. P. B. wrote: > Thank you for the work! > > I agree that making them proper classes instead of aliases is the better proposition here. > I'm not fully informed about the DOM spec, and I don't know if the current class/interface hierarchy is in the best shape, but maybe we should also consider having a look a this? > Yeah, our current class hierarchy is wrong, but not "overly wrong". The incorrectness comes from the design of the pre-HTML5 era. This is how it's supposed to be: CharacterData extends Node (Actually an interface, but PHP does not have interfaces with properties) Text extends CharacterData CDATASection extends Text ProcessingInstruction extends CharacterData Comment extends CharacterData However in the current implementation, the ProcessingInstruction class extends Node instead of CharacterData. Also CharacterData is a class instead of an interface in the current implementation. So nothing too bad, but not correct either. There's also some functionality that should be on the Element class instead of the Node class. > About making those new classes finals, this would require reconsidering the class hierarchy anyway, as nearly everything inherits from DOMNode, and other classes (namely Comment/Text/CData nodes) extend other classes. > However, I would not necessarily be against it, especially if we add the required interfaces, as the current mechanism of registering a custom class is not very powerful and rather cumbersome to use as the constructor is never called. I'm already reconsidering the class hierarchy :-). As for the constructor problem: I can fix that for the new classes, I can make sure the constructor is called which would already solve a pain point. > As such, I'm not sure if I would support adding the current mechanism to customize the node classes returned by the extension. Indeed, the current mechanism doesn't play nicely at all with static analysis and this is something I stopped trying to integrate when writing my DocBook renderer project. [1] I'm also not entirely sure, but in the JS world we do have custom elements that you can register and get an instance from back, so it has been done before at least. > > Best regards, > > Gina P. Banyard > > [1] https://gitlab.com/Girgias/docbook-renderer Kind regards Niels