Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107517 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52141 invoked from network); 11 Oct 2019 20:04:18 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 11 Oct 2019 20:04:18 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id BEF782D2063 for ; Fri, 11 Oct 2019 10:47:09 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 66.111.4.0/24 X-Spam-Virus: No Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Fri, 11 Oct 2019 10:47:09 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 6775D21F92 for ; Fri, 11 Oct 2019 13:47:09 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Fri, 11 Oct 2019 13:47:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=O/trd3 0n5f9upVMFUL+iwLEuApiBXnit3fKvj6ix7VQ=; b=cRVr7Uwini3pVH3LKwfFtb uyrEvOZhgjIfqoOoPi9gU/wVxJCTgaehHFhIcD6gWLxGEIE9AeDGtEIJCNv5RygT ta6YFUX2tzUBKBlm0mqhw7JssqjwPgZZquxaYh7AICkBjWC2ggimbYWD8stYE9uC cbkMKm/eEGvObA2MGFFgZFuz9jHTYhCHC1Q/3nvaZ1wo5s9EmuHaqP7hGqaR5AXP r+zB/U0Bu8N000PX2lcvzeyUMi6WoLs7ickS6/RyBVxZYerwB7n4IfyQSUUC25cX BSsscGFb9NSl4RG+q/rr/0Ypmrxxo+gIKa3oApos41GoOJcX8VUYNk+eUNuWPVDQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrieehgdduudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhenucevlhhushhtvghruf hiiigvpedt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1F08014200A1; Fri, 11 Oct 2019 13:47:09 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-360-g7dda896-fmstable-20191004v2 Mime-Version: 1.0 Message-ID: <237dbf6e-cd91-4e6d-8c97-1fbbabcd9f21@www.fastmail.com> In-Reply-To: References: Date: Fri, 11 Oct 2019 12:46:48 -0500 To: "php internals" Content-Type: text/plain X-Envelope-From: Subject: Re: [PHP-DEV] Warning for "confusable" types From: larry@garfieldtech.com ("Larry Garfield") On Fri, Oct 11, 2019, at 8:54 AM, Nikita Popov wrote: > Hi internals, > > Something I've seen play out a couple of times: Newbies try to use > something like "integer" or "resource" as a type, and then get a confusing > error message along the lines of "must be an instance of resource, resource > given". > > I would like to throw a compiler warning in this case, that looks as one of > the following: > > > Warning: "integer" will be interpreted as a class type. Did you mean > "int"? Use qualified name or "use" to suppress this warning > > > Warning: "resource" is not a supported builtin type and will be > interpreted as a class type. Use qualified name or "use" to suppress this > warning > > This warning only triggers if the type is lowercase (integer but not > Integer), is unqualified (integer but not \integer) and is not imported > (there is no "use integer"). This provides multiple ways to avoid the > warning for code that does legitimately want to use lowercase "integer" as > a class type. > > Implementation: https://github.com/php/php-src/pull/4815 > > Thoughts? > > Nikita Can you clarify where exactly "compiler warning" would be displayed? Is that an E_WARNING? How would I as a user see a message when I write function foo(integer $a) { ... } --Larry Garfield