Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123360 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 B93981A009C for ; Sun, 19 May 2024 07:38:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716104364; bh=bnXSRZpt7pVu7IOaMqTJ+vFsJ7BL8YpGlDI4b9iASVQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HGKG854DVrAImDzdki+oXg3ZkOfwXkU/Imk7CH2xzqGCsqZDjBAjq7zdgZVfUiLyd r1rOSxCfuefoy7YTniW1R7qtrvu6o5RKWUY2YB1OvHQS3eyND4+q4jtxJMfh/NGcDX hhMMk+zQFcYMIva/SD077Wlbfo72ky/xnCZnz9T1TAqY3Lyo5N6xuOZS0uMOvtk4q3 MLEdc9dTsTHb8Xy/IXF/5zD2NBOvx6GyLyvOMFy51krGvEGyV6nTMoaGTxR930JY+0 +1DJpzpX6DICZdUHD8ZoTF4NRPXryvpuUQbSAWhus+RQgFOlgNsr5utCnPTvytKAep ic2o35dH0BTCg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C775D18003C for ; Sun, 19 May 2024 07:39:23 +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-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 07:39:23 +0000 (UTC) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-51f2ebbd8a7so4082101e87.2 for ; Sun, 19 May 2024 00:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716104307; x=1716709107; 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=1Y5zXDJjsQYb0SyrluU6soZ/S3UuCFeZpfNM19uKxNA=; b=F27/TDRo7E85ugAJNp6/oeSe62jqYt1+VadAfxtAiyGtIlYI/XRONzYbcjlPoThEIJ 7MdO6OH52sNb960J3jRZw4s2r5tchl9WzBntRRoBjw3Ja1JXcUnwjTXW3Rlz3qFGE1tR Kutvs2rUmzA4RSqFeWgLAUhh354IqyKJ6LzfdIM6w5x6fyf8XVhw09v0DaXYQFGsnEtM pTdoYmcishqKVNg1UOuJY/96DNyGFZxRZX6/LRc8+YkL3akS4P5HBOgYb0BXalkWCecv g66bbteHAbpVqZXNU10pnoUs7bb+cwvX+cSQPecwJWAjjH5miJZcF/eLZNLHqSweEhbA LnKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716104307; x=1716709107; 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=1Y5zXDJjsQYb0SyrluU6soZ/S3UuCFeZpfNM19uKxNA=; b=b4tvrLDIK8mksysG01xmpHphULOFy183+lwaP1gebxJrj9st40X1TePPx6fKgI4qOu CMcDVCvjSSnqvX7WIsrBWVlHCwqlsb6q5VnFNTz/46y5HtRnQDXfhKNDGv08M7ev2fGk GouPcmpHNoqKReu312ObolPep3YhNiXPGgoifLzY8p58V6FzJ6Vz4pwxHrCOe5PbkRd1 ewiMRaeJSxhoGPH+IYCc2yk9TboDzQ5ERCESUo4ccTy14hXSG8RCf8OyzZ/e2vWtUWDY C2/hLvGBRFvzwoNq7Y94g1ykiLhy4WwPxjlzT8Y5UuE185wUShmwDQKf7u9sYFTiTanT TvVA== X-Gm-Message-State: AOJu0YxDGayuFhe/aTytmtio0wol2MsJu8s5NIjrEGenvJtS+iKVcvSX ATcXwhkWFxRlDug1cJuWMVD2ykcJzOXr9j3HIDQdLO3bWW45V7rc1m4MUTTAAOXPDg3zWLl83kM ocffbhkiRUbo+RNo7grA3TzGAD0X/L6HNOyg= X-Google-Smtp-Source: AGHT+IEzCtJq3r5AIwSFMb+3SfU33ZKk5sgRNiT08I+1gos6hZfixe/UnhZbuivi7ymfOhdOfoXNK9NxrwrSqtJYBP4= X-Received: by 2002:a05:6512:104b:b0:521:f000:5d1a with SMTP id 2adb3069b0e04-5221006cd2dmr19103848e87.59.1716104307034; Sun, 19 May 2024 00:38:27 -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 09:38:14 +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 Sat, May 18, 2024 at 9:11=E2=80=AFPM Andreas Heigl w= rote: > > > > 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: > >>> Hello internals, > >>> > >>> I've been thinking about having an "internal" attribute that will emi= t > >>> a warning if called from outside it's left-most namespace. > >>> > >>> It might look something like this: > >>> > >>> namespace MyCompany\PackageA { > >>> #[\Internal] function doStuff() {} > >>> } > >>> > >>> namespace OtherCompany\PackageB { > >>> \MyCompany\PackageA\doStuff(); // warning emitted > >>> } > >>> > >>> namespace MyCompany\PackageB { > >>> \MyCompany\PackageB\doStuff(); // left-most part of namespace > >>> matches, no warning > >>> } > >>> > >>> This would allow for library maintainers to mark internal constructs > >>> as such and provide users with feedback that they are using code that > >>> may be changed without any notice. > >>> > >>> Any thoughts? > >> I do like the idea in general of being able to mark certain things as > >> internal to a certain namespace. > >> > >> My question is more in the direction of: If we are not enforcing > >> breaking the code but merely emit a warning then that is IMO not > >> something that we need to implement on the language level. People will > >> still be able to use the internal method and just ignore the warning. > > > > I guess that depends on what you mean by "break the code." Many people > > 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 care > about such things and those that don't. > > Those that care about such things will already find these issues during > 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 would > love to see this as part of userland maintained static analyzers. > > 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 | > +---------------------------------------------------------------------+ 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. Robert Landers Software Engineer Utrecht NL