Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122067 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59588 invoked from network); 30 Dec 2023 09:25:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Dec 2023 09:25:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3E95018005C for ; Sat, 30 Dec 2023 01:26:05 -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=-3.1 required=5.0 tests=BAYES_00,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-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) (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 ; Sat, 30 Dec 2023 01:26:05 -0800 (PST) Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-35fe8a4b373so21790405ab.1 for ; Sat, 30 Dec 2023 01:25:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703928336; x=1704533136; 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=IVhbXZtVa+9U+gNb0jzV+xwrwvht6jWsf/ML4JfHjyk=; b=EOHDEwinXALcNBme5AB/spCwLRAXU47IJ2jooJfT2On3MWCZZ91fApQkSGWd1bgyCR wtkzHfCzJumgFsfzzGsAh1MLh7bX/d6in5HI3OE4I2eTmK64bpUPs3sDZv90ZN7bzMUQ 2t4cGCo4PWv7xFRMzko1ueXa7ZeUKDQDxyYm0zTBS5b1ghoq+nEBJHoWi2PD7Jufe5pW taAEXXNPwEtqZIlhQbLuBzEEo94PWa7qpjk4tDDgJ4geFMrXUAtBUhVNVXcqQvRiEgk4 FDKvq1igxr4G/VKmATPVxGjJZgL3Mb/ZO5U9O1F1ENRf6SUZdr9SwsxjHntf3osBX3eO 1uzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703928336; x=1704533136; 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=IVhbXZtVa+9U+gNb0jzV+xwrwvht6jWsf/ML4JfHjyk=; b=hnufKl9xL29QRZA3PJ82SxgM5c7XIrfFvpbEcYTZgIyRXM1u2cc4hkDqZEEL/n+efr v9s7br5qoMfHFV/RGNBFx/nmCNHI6UxhsBdo/XM1/kNAO+sV602NqJwxh84akQDOMfJc PSsD33MOK/i+GQC8U2QJi+rIKYc/7EbTIUh3ILtxjW8NZ5RZ+r59hBQ1yMifhd06Nc40 FNOfCkMjziSGHPBURCHdJUgFsKOBqJ3yHxjDb0uubfXfye6W3OnOht5f+IIxZDDW8IhL SX9920XGZfy5k/+xPfAzFp0LgJMz4agALCHnNr6MZRIXtSHjQ72eK4GqyLzvJAfsw5K8 +mHQ== X-Gm-Message-State: AOJu0Yy8pz7sPZ4CSRbOFtaf6hdaa5qcPOMaxrcCVGw1P5+giIOxmdNY NyJPHCVNXlLv4k9Z8fhuxH9ppox51+okL1W7dv2kMlj6R5JpjQ== X-Google-Smtp-Source: AGHT+IGVXGSIBondFRE8NzWjAuioxMpX/GfB5i+JteDTxOx3nfm1m2iMv8Xy64gvhjAl2Xps1QxPAPFWdw4Fva0EFjg= X-Received: by 2002:a05:6e02:2182:b0:35f:ea84:831b with SMTP id j2-20020a056e02218200b0035fea84831bmr12093605ila.62.1703928336373; Sat, 30 Dec 2023 01:25:36 -0800 (PST) MIME-Version: 1.0 References: <756bcf2b-f98d-4203-9004-1cbfd402337a@gmail.com> <8632ff2a-0169-4cbb-b5d8-3bafb841f1ee@app.fastmail.com> In-Reply-To: Date: Sat, 30 Dec 2023 10:25:23 +0100 Message-ID: To: Niels Dossche Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Pre-RFC: Fixing spec bugs in the DOM extension From: landers.robert@gmail.com (Robert Landers) Hi Niels, > They are indeed going to be very similar, but at least having better return types would be good to give one particular example. > e.g. we currently have a lot of methods that can return an object or false. The current living DOM spec always throws exceptions instead of returning false on error which is a much cleaner API. > Furthermore, we have the DOMNameSpaceNode that can be returned by some methods and has been a point of confusion for static analysis tools (I did a PR on psalm to fix one of those issues). > That node type won't be special cased in the new classes API so the (inconsistent use of the) union of DOMAttr|DOMNameSpaceNode will go away. Actually, I'm not sure it is supposed to be throwing exceptions (if we look at https://html.spec.whatwg.org/multipage/parsing.html#parse-errors); in fact, I'd argue there are three different ways to handle errors (from some experience in writing a parser from scratch): 1. Acting as a user-agent: in this case, errors should be handled as described in the spec for a user-agent, e.g., switching to Text-Mode in some cases and gobbling up the rest of the document. 2. Acting as a conformance checker: in this case, a list of errors should be available to the programmer instead of bailing when parsing (e.g., not switching to Text-Mode, but trying to continue parsing the document, as described in the parser spec for conformance checking). 3. Acting as a document builder: Putting the document into an invalid state should emit at least a warning. However, it's likely better to let the user-agent handle the invalid DOM (as this is probably more forward-thinking for new HTML that currently doesn't exist). This is actually one of the biggest draw-backs to the current implementation as it requires a number of "hacks" to build valid HTML.