Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123364 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 DDBE51A009C for ; Sun, 19 May 2024 09:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716111662; bh=ox7ivEVyGiG5AMi+Ktx/KRcYmQv/menHaGi6mMvvvbs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BlPbcjAIPWiiOt66FNXmjUSMCsGVY5k3iymScQo4OEotLucuywU5u42a8BK7/ygM1 5A8+XyiGhNaAsoZ+17tV+8+McxBX1Ln4Fjz5uZqE9hrDoA6L+Du0AaPoTg2BMffw3W qYJQuLTpr5Q07p86bm6hCaVcIjGrylF2AFh8HkCQ6RQcg1eHnmNvagBUcuB7wIsa78 eRSjd2Bksjpq1vyJslfoR58VlnxPm+1p9oKXh9BE23vIh+rHVGcJ09xEU9K/BN4fXd QtB5wPHzywItsZvGeKlv+nfSQn0SVWTk1PPZRSsy9F6BdVekjmUzDIJotncVnF+5El e/KeDZ2z2fh6g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4B4871805DA for ; Sun, 19 May 2024 09:41:01 +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, 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-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 ; Sun, 19 May 2024 09:41:00 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51ffff16400so5450367e87.2 for ; Sun, 19 May 2024 02:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716111605; x=1716716405; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zpY5mX9VGsKr8XDigHl4E+WVWvr5Ph4zDDx3L1GcYE4=; b=WwRbRrBztPJUqS4wsJk9PPntuDIyG7RnlGqsfKaZpPkTPvVvSNfOZgfPrSnX3cX7WV yHnp4Z7Qfrz7IlLsFd7qHupiJh+BKrKdws8mgPEYj+C9WkUZRmZmJQ9zDKa6tIywKLpr HQgf1FYU3gV2AZL2QnWBUlvb82Mq3rj9K9qXCuuQ+ywaxpVunMAcqoZC3puLMXc4/0UO jz3SjzaN86vty++O7bIr3J8WfemIaeY6HkSeGiJEru8M0/FKR04uXoRaPtDdr5i8HyD7 pvxWNOdXILi+vr8JqxpFHFOimTczTziQ/mjc7Pm9Fe6+SHpfFhZzk/LxSGqkinAxwalR 4BKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716111605; x=1716716405; h=content-transfer-encoding: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=zpY5mX9VGsKr8XDigHl4E+WVWvr5Ph4zDDx3L1GcYE4=; b=D+8rherZq4jnzV+VI1yp3Ul5QEKKvgVm5WmKJ2f/v3eEXT9XmgUtLv6aSjiJ7/j5UE 7gn99zOFmj1Cloh+2cyBBhmOyevg30Fjvs/VZmvqCX2JL4s0wWQqajKIUCwRqhVyE0Lh Ps+5kdlL/t3WV3xT9xSo/kGSdTkI3oMe+cyTuRTo1e6UdSVLbXBQIRHKwsEcct0pdpFb O1vbioPGih3Nhm+LIzsNYSYN00I40+q2lC//EkPQcJb4Xvjuy9ixza6QB7jzQIiEOPkb /596idKdrywo0TzNf9k8ZQXKNPnElqjiftUnKTcc9Su/EAKSYzoDFGpR/E46ct8CKcbr 8tlA== X-Gm-Message-State: AOJu0YyX/pHCEp2mwYIKywF+88nVu44XxTSK181D3JLcenyou7yY2Jre UitE+BUP5151SoyVPw2UvHVT6KSvZ/ov47+Ir9w+FBOjqYIfyolX+Pg3JzuB0EVKW50i4640X1L hZ/W8Qx2J7Rd8JuZjXOvztAjDRMc= X-Google-Smtp-Source: AGHT+IH46Fwtyims+Ab6OgePBE49kIf5iCdLaRzKL+ycpJqW3kpHmYpd7VJ8glOQ2PUEQZ0GsUVPsGvEyFivwtBSjFU= X-Received: by 2002:ac2:504c:0:b0:51a:df97:cc8d with SMTP id 2adb3069b0e04-5220fd7cc70mr16765522e87.26.1716111604485; Sun, 19 May 2024 02:40:04 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <407efbd0-2d9c-4bcb-b795-0ee326728415@heigl.org> In-Reply-To: Date: Sun, 19 May 2024 11:39:52 +0200 Message-ID: Subject: Re: [PHP-DEV] [Discussion] "Internal" attribute and warning To: Andreas Heigl Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Sun, May 19, 2024 at 10:52=E2=80=AFAM Andreas Heigl = wrote: > > Hey Robert. > > Am 19.05.24 um 09:38 schrieb Robert Landers: > > On Sat, May 18, 2024 at 9:11=E2=80=AFPM Andreas Heigl wrote: > >> > >> > >> > >> Am 18.05.24 um 19:46 schrieb Robert Landers: > >>> On Sat, May 18, 2024 at 7:38=E2=80=AFPM Andreas Heigl wrote: > >>>> > >>>> Hey all. > >>>> > >>>> Am 18.05.24 um 16:00 schrieb Robert Landers: > [snip] > >>> I guess that depends on what you mean by "break the code." Many peopl= e > >>> turn warnings into exceptions, and for those people this will > >>> effectively break their code. Some people may choose to ignore it one > >>> way or another, but that would be up to them. The idea isn't to break > >>> people's code though, it's to provide a way to mark very-malleable > >>> APIs in libraries. Maybe, "Internal" is a bad name for this, but it's > >>> the most logical. > >> > >> The trouble I see is that there are two kind of people: Those that car= e > >> about such things and those that don't. > >> > >> Those that care about such things will already find these issues durin= g > >> static analysis. > >> > >> Those that don't care will not turn errors into exceptions but instead > >> have error-reporting set to 0 > >> > >> That's why I am hesitant in adding this to the engine but instead woul= d > >> love to see this as part of userland maintained static analyzers. > >> > [snip] > > Hey Andreas, > > > > I don't think this is a useful way to look at it. Otherwise, what is > > the point of making any error or warning? Static analysis is useful, > > but there's a lot of things it misses, especially when dynamic calls > > start happening. > > Probably the most interesting question is about our and the users > expectation when declaring respectively using an internal entity. > > Is it's use something that should just pop up in the logs? And if so: > What does it mean? Is using an internal entity outside it's expected > usage actually an error? After all an error should be used when the > application hits an issue preventing one or more functionalities from > properly functioning. We can not really say that is happening just > because someone uses a function in a place we do not expect it to be > used. It might still work. Indeed! The issue isn't that it works, it's knowing what to check very carefully when updating vendored code. It also sets a reasonable expectation that I can't complain that a maintainer broke something in my code because I was doing something unsupported. When it is only used in static analysis, it won't be noticed by people not using static analysis. > > But from the point of view of the person declaring that internal entity > muich more should happen. The code shouldn't work AT ALL any more. > Someone is using my code in a way that I did not intend it to be used, > so the whole application should break. > > But we can not assert that. I disagree with this stance for many principled reasons. If someone finds a class/method in library code useful, they should be able to use it. Code reuse is important, and since the library code could be licensed under the GPL while the main code is MIT or unlicensed, the developer cannot simply copy the routine into the main code. Further, they can't simply implement themselves now either, because they've seen the licensed code. Another issue I have with this stance is that if there is a major bug in a library, I should be free to work around the issue by calling "internal" code to ensure the state doesn't cause a crash in production. And yet another issue I have is that as a library author, I don't really care how people use my code. It's none of my business. If it works for them, great! I just want to be able to easily communicate that some code may change unexpectedly between library versions. Having something like this can be the difference between making huge refactorings and improvements a patch release or a major release. Code exists to solve problems, not create new ones and artificial barriers because of ego. Having this as part of the engine means that I know it is communicated even if someone isn't using static analysis. > > So by having a look at the expectations of the different parties we can > calibrate our intentions and then see how we can provide the best solutio= n. > > And to me in that case the best solution would not be to enforce this on > the language level but to leave it to static analysis. Because I know > how inventive people can get to use things in ways they are not supposed > to be used. Search for `composer unfinalize`... Off-topic, but sharing this just to show my stance on this: Final is an evil in library code, so I'm not surprised to see people doing something like that, especially if final classes are used as arguments to core library functions. It prevents authors from attaching important metadata to objects, injecting failures during tests, and ensuring application/business behavior is used -- and no, composition cannot always solve this problem. I tend to find alternatives if final gets in my way, or implement an alternative myself. > > Cheers > > Andreas > > > > -- > ,,, > (o o) > +---------------------------------------------------------ooO-(_)-Ooo-+ > | Andreas Heigl | > | mailto:andreas@heigl.org N 50=C2=B022'59.5" E 08=C2=B0= 23'58" | > | https://andreas.heigl.org | > +---------------------------------------------------------------------+ > | https://hei.gl/appointmentwithandreas | > +---------------------------------------------------------------------+ > | GPG-Key: https://hei.gl/keyandreasheiglorg | > +---------------------------------------------------------------------+