Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124066 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 5AB961A009C for ; Sat, 29 Jun 2024 22:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719701022; bh=GjLWzAW2dJ7gbcr54RzXF1DB9KP+h+qaDv5SClAJV9A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MGyFRF7oVqumiEfL2WBBkgVvLPoo8TclsLo+HXHQ0CUlPYlfLSzHpUhDGpYhdRm3i Bxm4zLxW/vIwFC6HtbD6wUIP7rS5iHy/sKBXht3lGw7xTQB9qodj3nADNlDGju74y8 tAGhu6CviFsibPATn3acpiTlKzbzWBAy9owO4w3p8aKxXmg+LsvByujLg0zq1fUADJ JsbkYZM2C+jr31ZUlKuRszBSo6tx1/T3V6HcpOAU2Oo4F6iLOj6sBShevVSNKvlfK6 7mW1jTIGXtBfm0k9VlTacJzHVPk0ggo1+S+LzhNxpw6GoX4wAOrvytF7gdWbi/tbhT f8IIteSaAWy6A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2E3A1180B29 for ; Sat, 29 Jun 2024 22:43:40 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,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-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (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, 29 Jun 2024 22:43:37 +0000 (UTC) Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6b4ffc2a7abso14051756d6.1 for ; Sat, 29 Jun 2024 15:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719700937; x=1720305737; 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=JcvmYJvvfkfHir6W0wimcQi712Cd282IA/xK+e3zvXA=; b=cGJaRY6gkRDF41oBhknVinYlMZn+JnfQxGOZvnngvRJiaSZ8VGX+CMaRAfNon0YYL5 MuHxZSr8pTnESpkORtSg46lCyxWx0c2+bvEPOB2+e+INNUAmsEG3SYAFLjdcXKXZSR53 I4Ls/9z+5Rjyde5JlzAJPTUWivH3+ggIobCH9SXLOQQ7CZyLIS/eQ5ZcMOPD94QRpUZv sVZdmzNA3BKdw9JYnlhEXQhN54Ss2R9mFutRrJ56XedQi6jZLkHIrJYJ8dWBXcgfPCpv OLzbFhbLISEx1af1af+mJ1WGw/BIJAX/kWAzydUOLxHtMhgK/55/q8OCyNz78QEIEB0r nIkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719700937; x=1720305737; 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=JcvmYJvvfkfHir6W0wimcQi712Cd282IA/xK+e3zvXA=; b=nPv28/wpaD5dnRWEIz7fRlX0PAhFnmw6XWtUZXRDtbYuqveZgzrhyXkXC+/68+bRJd AfP7f9zcxHDazNxPsuoidMXDuCog3y4DXir68BHFUsdFdgBNgpWzJFoYIrh29Ctf03tG tbq4iTDF3dpSh/LNSFjeL/Y0lyocPGIB9k4zCWuX7JfYXsh0JeHonkhgzTAA/L2NbI9f nOY5AgcWzYHbszoegsjw4qzapvt9YDZhN/Gkf/7RhJDi9nWMRI+WIQo6QY4E61MWCogD y72hHt1JHdm+8O89E6gUnp+CbrM/HxgO0+P8/HS1KNi/GaeZvG3ABWWdJpvrNqpiuirF 2sDQ== X-Gm-Message-State: AOJu0YwdbGLeDye6pXncEm0guGP6Hu7yxRmbXDzS8bm1hZnGKCl3w1dP qI5DNg/e3OGgvNwnNFd8RxJ9y3w2sxH8lond0DsPTQbtpFrzyCyWOqCu90f6MVmKfSWk26E9gui siaZupyeKBfDvhzA8I3C7tEIz13iY0df8 X-Google-Smtp-Source: AGHT+IH+v94Cyhl270OI1uViKqmMS/AHeAo3tQjAVO2qv2eiG2r8Y3AvqE847gmjgo/6xm2yfdhQ9FNY8Yt/Mz+x+3k= X-Received: by 2002:a05:6214:2509:b0:6b5:8442:3511 with SMTP id 6a1803df08f44-6b5a5486a44mr82977756d6.29.1719700937463; Sat, 29 Jun 2024 15:42:17 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 30 Jun 2024 00:42:06 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000007f6141061c0f130f" From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --0000000000007f6141061c0f130f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Larry, Thank you very much for your feedback! I think I have already partially answered some of your questions in my previous email to Niels, but let me answer your other questions below: * I... do not understand the point of having public properties AND > getters/withers. A readonly class with withers, OK, a bit clunky to > implement but it would be your problem in C, not mine, so I don't care. > :-) But why getters AND public properties? If going that far, why not > finish up clone-with and then we don't need the withers, either? :-) I know it's disappointing, but the public modifiers are just a typo which were forgotten there from the very first iteration of the API :) However, I'm fine with having public readonly properties without getters as well, as long as we declare this a policy that we are going to adopt... Withers are indeed a must for now (and their implementation indeed requires some magic in C...). * Making all the parameters to Url required except port makes little sense > to me. User/pass is more likely to be omitted 99% of the time than port. > In practice, most components are optional, in which case it would be > inaccurate to not make them nullable. Empty string wouldn't be quite the > same, as that is still a value and code that knows to skip empty string > when doing something is basically the same as code that knows to skip > nulls. We should assume people are going to instantiate this class > themselves often, not just get it from the parser, so it should be design= ed > to support that. I may have misunderstood what you wrote, but all the parameters - including port - are required. If you really meant "nullable" instead of "required", then you are right. Apart from this, I'm completely fine with making these parameters optional, especially if we decide not to have the UrlParser (my initial assumption was that the Url class is going to be instantiated via UrlParser::parseUrl() calls). * I would not make Url final. "OMG but then people can extend it!" > Exactly. I can absolutely see a case for an HttpUrl subclass that enforc= es > scheme as http/https, or an FtpUrl that enforces a scheme of ftp, etc. O= r > even an InternalUrl that assumes the host is one particular company, or > something. (If this sounds like scope creep, it's because I am confident > that people will want to creep this direction and we should plan ahead fo= r > it.) Without having thought much about its consequences on the implementation, I'm fine with removing the final modifier. * If the intent of the withers is to mimic PSR-7, I don't think it does so > effectively. Without the interface, it couldn't be a drop-in replacement > for UriInterface anyway. And we cannot extend it to add the interface if > it's final. Widening the parameters in PSR-7 interfaces to support both > wouldn't work, as that would be a hard-BC break for any existing > implementations. So I don't really see what the goal is here. I've just answered this to Ben, but let me reiterate: PSR-7's UriInterface is only needed because PHP doesn't have a Url internal class. :) M=C3=A1t=C3=A9 --0000000000007f6141061c0f130f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Larry,

Thank you very much for your feedback! I think I have already partial= ly answered some of your questions in my=C2=A0previous email to Niels,
but let me answer your other questions below:

* I... do not understand the= point of having public properties AND getters/withers.=C2=A0 A readonly cl= ass with withers, OK, a bit clunky to implement but it would be your proble= m in C, not mine, so I don't care. :-)=C2=A0 But why getters AND public= properties?=C2=A0 If going that far, why not finish up clone-with and then= we don't need the withers, either? :-)

I know it's disappointing, but the public modifiers are just a typo wh= ich were forgotten there from the very first iteration of the API :) Howeve= r, I'm fine with having public readonly properties without getters as w= ell, as long as we declare this a policy that we are going to adopt... With= ers are indeed a must for now (and their implementation indeed requires som= e magic in C...).

* Making all the parameters to Url required except port makes = little sense to me. User/pass is more likely to be omitted 99% of the time = than port.=C2=A0 In practice, most components are optional, in which case i= t would be inaccurate to not make them nullable.=C2=A0 Empty string wouldn&= #39;t be quite the same, as that is still a value and code that knows to sk= ip empty string when doing something is basically the same as code that kno= ws to skip nulls.=C2=A0 We should assume people are going to instantiate th= is class themselves often, not just get it from the parser, so it should be= designed to support that.

I may have misun= derstood what you wrote, but all the parameters - including port - are requ= ired. If you really meant "nullable" instead of "required&qu= ot;, then you are right. Apart from this, I'm completely fine with maki= ng these parameters optional, especially if we decide not to have the UrlPa= rser (my initial assumption was that the Url class is going to be instantia= ted via UrlParser::parseUrl() calls).

* I would not make Url final.=C2=A0 "= OMG but then people can extend it!"=C2=A0 Exactly.=C2=A0 I can absolut= ely see a case for an HttpUrl subclass that enforces scheme as http/https, = or an FtpUrl that enforces a scheme of ftp, etc.=C2=A0 Or even an InternalU= rl that assumes the host is one particular company, or something.=C2=A0 (If= this sounds like scope creep, it's because I am confident that people = will want to creep this direction and we should plan ahead for it.)

Without having thought much about its consequences= on the implementation, I'm fine with removing the final modifier.

* If the = intent of the withers is to mimic PSR-7, I don't think it does so effec= tively.=C2=A0 Without the interface, it couldn't be a drop-in replaceme= nt for UriInterface anyway.=C2=A0 And we cannot extend it to add the interf= ace if it's final.=C2=A0 Widening the parameters in PSR-7 interfaces to= support both wouldn't work, as that would be a hard-BC break for any e= xisting implementations.=C2=A0 So I don't really see what the goal is h= ere.

I've just answered this to Ben, bu= t let me reiterate: PSR-7's UriInterface is only needed because PHP=C2= =A0doesn't have a Url internal class. :)

M=C3= =A1t=C3=A9

--0000000000007f6141061c0f130f--