Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108329 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62943 invoked from network); 30 Jan 2020 05:17:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Jan 2020 05:17:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F40BF18050B for ; Wed, 29 Jan 2020 19:28:37 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2089.outbound.protection.outlook.com [40.92.42.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 29 Jan 2020 19:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J82+yoDJUmmHM1rueRYH4YOtQFNR884ORGdY0nPcG1JGdzh9uIguIj17dsEeXBoGV4jkgScnW0lCwdXxCWSZ8Bw/yeVNIG6vVFZ1642buS/8r/6UtynfeRmGxHpPoMAUd2es1IbBZx7kLxkbFqo0R/zHkUbl520WKq8E0JA9KR1vkKcyF6Tgf5VIhJqLkdyNGck0vC9ROLrczEj6biYLjBgliNF92fFLc+FyfeIEToC0sqlL8tCsoJyqouPjsN/KbcRNWwgxTm73hBSOkRebGq0FgmZ14CNegzZ4QuRTLqJd4VuE/LZrM6wEHXdGIUqk9tRHcY5wFr+sybYHXdkXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4p7c2nSYs5zG85OzNlCe1mxoNQ3SoAH0fYMSWOf4ctI=; b=D50FCn5pPCRNsx7zgxmFzvJiQ6fYCQJdeqeVGgPtzB+Wcb06VP8NkGxENSD8rX2bH2fE4iLfx1UI51mm4AI87fkbIR+d7BkdENgxPrL5Gp3H/fl9/CG6MsGMboZ4qEqPYobjt6ShVPWgeD5boT58pLgIzwzUEr7zbJYzeyXe4ZobVTk19xYKz+BfacmETrUYn3efTdaeDCnigeZFcfZPMxmN6KE5TPwBuotS9Mn2nRf7PAQrf4TgYVPVH+X9zXbWDOTlTQWBTu0EFR+VYYX0syog2Sh3ZGBXY47nOHMD4ww2ClL9DLtjVDi7/Lt4bw+5x8Eq0YUeobzT68U6kYHoYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4p7c2nSYs5zG85OzNlCe1mxoNQ3SoAH0fYMSWOf4ctI=; b=jU60hh6jMtht9Y2FTT46UgAOimqeRamTKhFEPBTqW1QAFIUWVbI5q1YGghnXLXBVxNrHPgDO1IF0r2mUdJ9DcYxFun7IwgfZSIePniHWUfSzyUf5Nvgu8qrWLkf4kljszZsyuVOCH6xE3Y1Pp/hRZKvliyYqB6H8NKxgInGxT7otr+m7zcR63dN9i0evClbTQq+wf00uNRrAT0cBjY1onr81fqya6KDyvBtBnnnx65t9YC8Vn1lx5dismBUyPgrCjjHV8fJLOGkHrTpEIDloQ7dwIMMwi96re7/3yFn9FZJxq9Uz7SFqgPjc1pTVb28jzybo5iXDriNYloNXMxFqGg== Received: from DM6NAM10FT062.eop-nam10.prod.protection.outlook.com (10.13.152.51) by DM6NAM10HT098.eop-nam10.prod.protection.outlook.com (10.13.153.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.18; Thu, 30 Jan 2020 03:28:35 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com (10.13.152.60) by DM6NAM10FT062.mail.protection.outlook.com (10.13.153.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.25 via Frontend Transport; Thu, 30 Jan 2020 03:28:35 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::29e3:53bf:163e:5beb]) by DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::29e3:53bf:163e:5beb%3]) with mapi id 15.20.2665.027; Thu, 30 Jan 2020 03:28:35 +0000 To: Bishop Bettini , Marco Pivetta CC: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [VOTE] declare(function_and_const_lookup='global') Thread-Index: AQHV1kkfok/EDBhgHUCIMQks+1sXM6gBeLUAgACCj4CAAJEH5A== Date: Thu, 30 Jan 2020 03:28:35 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:DBC3A998FE409391EC75F8A5CCD71E03A16CAA344D8CBE44F5048C1BD91E8834;UpperCasedChecksum:22FC4D5791A3969823D9BF33F26683B6DA71C9B80DADC16FA6808D952C5117E7;SizeAsReceived:7221;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [HNkHJzApnWC7bCTr1CaFKt0boADvjgCy] x-ms-publictraffictype: Email x-incomingheadercount: 46 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 4a018ae6-3868-4bfe-89fd-08d7a5347d63 x-ms-traffictypediagnostic: DM6NAM10HT098: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZVWA1deHxkz8ZC5stkchfAQWj52l7B1ZJU0maQTHGu+sOE74hWWWQ0G3FEk/O3LSkfvshnNM4Pp3lv1+vyDzQDz6NRv2LtFvq6b8XCnwXBCPAD9wpxBGqQ3yDL/MzpyJ5SYErePEgioAs5Jk/9EHYU+l/qZM6kc27QTru2r2QjAJedbD/nQi+eIkR1+qRr9w x-ms-exchange-antispam-messagedata: DPI9tfufAhJNCczbQu6R2QIa27EjZHGwPPiThZqFCLzU+749kQ8qQZr77ZmKTlwsOn0W8hOSvYXhEf83yi2GCpXzDoRtSMo3MiVciTkvTsMPrtQSg/7Je/iiLRiPeuTDOxdkPC9qC1EE+lYp2fKMTA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 4a018ae6-3868-4bfe-89fd-08d7a5347d63 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jan 2020 03:28:35.0995 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM10HT098 Subject: Re: [PHP-DEV] [VOTE] declare(function_and_const_lookup='global') From: tysonandre775@hotmail.com (tyson andre) > Agreed. I want to force explicit qualifications, and raise error on unqua= lified names:=0A= >=0A= > declare(strict_qualify=3D1);=0A= >=0A= > namespace foo;=0A= >=0A= > use function \{array_diff, var_dump};=0A= > use const \bar\{a, b};=0A= >=0A= > $x =3D array_diff(a, b);=0A= > if (count($x)) { // throw an \Error of some kind, as count is unqualified= =0A= > var_dump($x);=0A= > }=0A= >=0A= > Pros... no bc break; short declare identifier with obvious values; code v= alid even if declare is removed; no lookup performance penalty;=0A= > easy to remember logic; forces enumeration of the "surface area" the code= wants to cover=0A= > (which in turn helps developers think about how much work the code's doin= g); has analogue in other similar languages (perl, python, node);=0A= > makes explicit what functions are being used and where they originate; mi= ght goad an implementation of wildcard use (`use function \{imap_*}`).=0A= =0A= If this is allowing prefixing with backslashes, the "surface area" isn't gu= aranteed to be enumerated in one place.=0A= Forbidding backslashes or namespace aliases for functions/constants would h= ave other objections.=0A= =0A= > I've not done the work to implement this, though I am happy to if there's= interest.=0A= > But, it may not be feasible. I'd hope Tyson would kindly say "STFU not po= ssible" if,=0A= > from their recent experience, it couldn't be done. Apologies if earlier t= hread discussion ruled this out categorically.=0A= >=0A= > But I like that it adds super-strictness for those who want that, while k= eeping the super-flexibility of what we have now. That seems to be the way = we're going with this dual-world of loose- and strict-ness in PHP.=0A= =0A= The issue would be that I'd expect it to be voted against for similar reaso= ns to my RFC, but it's easy to implement.=0A= =0A= `declare(function_and_const_lookup=3D'global')` aimed to make something tha= t was inconvenient to work with=0A= with tooling more convenient in some ways with and without tooling.=0A= =0A= Right now, it's already possible to fail your build if a file uses unqualif= ied names, without code changes.=0A= Tools like `phpcs` and `phan --plugin NotFullyQualifiedUsagePlugin` can be = run in continuous integration or as a check on file save,=0A= and have ways to detect the lack of explicit qualifications.=0A= (If a project could set up `php --syntax-check` on all files, they could li= kely also set `phpcs` checks up).=0A= Having a file `strict_qualify=3D1` throw/exit after a deployment or code re= lease would be undesirable=0A= (emitting a compiler warning when compiling would be safer, but make that s= etting a less useful guarantee of strictness)=0A= =0A= It's possible to implement from a technical standpoint:=0A= the lines that get changed are the same ones you can see in the PR for my R= FC.=0A= (If you mean throw at compile time, not at runtime)=0A=