Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123357 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 EA8B91A009C for ; Sat, 18 May 2024 18:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716056227; bh=UzoFyqBJqwLMQ8PwX3tWUFuJW3c0EyG7luwh9Go5pc4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=W1NQIh7PZBU9VqunSF8vxcIHGiA397H9hKjVvgcNQAIpRyQDLRtnCRkYNhWsBE1ED bBtJ5P9dZKo54CqA79uXfa1ufzcBoJrlt/n9LjivDucjH7IRMcgqPkvI26rfpscdeP OIOfyZFZ5kjTN6fTTSwpffNX6sFD+/7t7HhJ4OSDnugHcmoy2qeFbx7jaWhYifubou yD6G+gLvySMStD2m8OpHshuvuqkPDl1G1IBSFapNlr1tjq8HUqIkdL19zkFgBNH880 j5RUDhKk/Ows35k0OWzH74ey8z3RxLCkIiNEkr/lsvrxMIZYJWV2mOJHEd3agqiNOf pTPwHEgPl3z2g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A165C180A43 for ; Sat, 18 May 2024 18:17:06 +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 ; Sat, 18 May 2024 18:17:06 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51f0f6b613dso3920831e87.1 for ; Sat, 18 May 2024 11:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716056170; x=1716660970; 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=O4ILlAQ6M6KJ+tRtMredfKXLoHzV0z2wdAiYXUwcL1A=; b=eQjprE2dXXC6P2ekVOVPT0h8szkpYt98v4YS18NsvI4momVGySYaw1NSune9SRYe9z nO7N4dq72+FKuyog/jwPAhS1ab3hHMb9vluPBLzyowKO+k4eYKb451T24AUreHNP8P/6 4t0Iy53SlFwHi81JDamLYMj8U6CW/f3yaQqV73KQiSngYJF+EZmGXNRpqpAiXTFfqUhZ iDiUI/AjyZ/birXdYhF5+AW4VFmWfIm1p8r9GK0Gu/x+V3V9guOCGVR9W5CfLv/KoEqj n1yfxUcUryRxR8ExbkStNYO0iunFG/gpmWcHR1wgM5iTw9CpAAF1FQEL+9zVflTdsjqt KDpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716056170; x=1716660970; 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=O4ILlAQ6M6KJ+tRtMredfKXLoHzV0z2wdAiYXUwcL1A=; b=LW4vPCO2NZCQjX09SkaH7JMtdQJf27/xCafezJjr+9ZX/iTSbrf8ftWQP8akWQGxRx VaeysjpNxkzRwfIHEvye5scrooUZOjVZepwxWWcsxiuKAp8MJ5ubGdV6y0U/lbnH/bei ZqbJNAJjmCkIlwfgwu04eZWNX3qvCLHg8IYw5rAT7Yr9ambCuqMZ40pNn7JKCzhk86Db rVOA55N9uBZV+fd2op6t6c9WKR7+YYl3Lqg98I0AG7+W8/uO8Roo4mth9yH/Ddubg4Nr pkmUVNBfCeA4WncxLI3ica8XByxBVLpYn4v0c3lpnDfJgu45dV9rSbc5tWylkYF4d61a uKxg== X-Gm-Message-State: AOJu0Yw8xdlLlZHucGNypUBbVsoBOytEVyVEOWWKl3Ro6D3PG+au0+Vp nH3j3OdnZBLlW90STKK14yew3IJLcCZs1Pl/8EUslkThmjoG3vbYx1BLPg4crN594ARKqgp44Uj SE1ALGEfGoizTwG6pB4hr1ul5v4r5EwHTpOg= X-Google-Smtp-Source: AGHT+IGgHDJbcUl9hLSXe1hZ5cwKaBYi54VYGpbgLV2frAYe2yn4M9GDN2ICjejRvvLDKa3MB5y2pXHNOLN+CuCD5x0= X-Received: by 2002:a05:6512:2149:b0:516:e8b1:9ed5 with SMTP id 2adb3069b0e04-52210279e56mr13540354e87.59.1716056170249; Sat, 18 May 2024 11:16:10 -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> <864f67fb-01a5-49a6-9f81-b54600046652@app.fastmail.com> In-Reply-To: <864f67fb-01a5-49a6-9f81-b54600046652@app.fastmail.com> Date: Sat, 18 May 2024 20:15:59 +0200 Message-ID: Subject: Re: [PHP-DEV] [Discussion] "Internal" attribute and warning To: Larry Garfield Cc: php internals 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 7:58=E2=80=AFPM Larry Garfield wrote: > > On Sat, May 18, 2024, at 11:06 AM, 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 emit > >> a warning if called from outside it's left-most namespace. > >> > >> It might look something like this: > >> > >> namespace MyCompany\PackageA { > >> #[\Internal] function doStuff() {} > >> } > > *snip* > > I think an important question to answer here is what we want to have as o= ur definition of "package". > > 1. Should the package be defined by the namespace? If so, anyone can put = code into any namespace; it's not even hard to add to someone else's namesp= ace. > 2. Should the package be implicit, or explicit? If it's a namespace, is = it auto-implicit or an "empty" package? > 3. Should package be defined/implied by the file system, like many langua= ges? Then we'd need a way to define/declare a package on the file system. = (I have some thoughts there.) But that may run into performance issues, t= hough they could be solved by opcache. This could also make it harder to i= nject code into someone else's namespace. (Whether that's good or bad is a= matter of opinion.) > > The proposed attribute would be going with point 2, implicitly. That may= be a useful approach, I don't know, but it's not something we should do "i= mplicitly", lest it cause issues for us in the future. > > --Larry Garfield Oof, I wasn't trying to open the "what is a package" can of worms, though that may need to happen sooner-or-later. I was mainly trying to be able to mark malleable APIs and set a conservative delimiter (top-level/root namespace) for the warning. I think being able to specify a more local delimiter (working on teams in large codebases) might also be useful. I don't really see an issue with injecting code into other namespaces, though. That's basically the only way to properly implement proxies, afterall. Robert Landers Software Engineer Utrecht NL PS pro-tip: use reply-to-all to email the original author of the email as well. I saw this email almost two hours ago on another email address I'm subscribed with but couldn't reply until now. If you also email the original author, we can communicate faster (for whatever that is worth) while the list plays catch-up.