Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107519 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59989 invoked from network); 11 Oct 2019 20:40:05 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 11 Oct 2019 20:40:05 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 2C3432D203E for ; Fri, 11 Oct 2019 11:23:17 -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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) (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 11:23:16 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id 41so8751383oti.12 for ; Fri, 11 Oct 2019 11:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TleZrH6+eL/cU0zYuJa2/PLVKmSzDIq4EPgQ3CnSogg=; b=Ggy7dXp9VY1OsGOYQV7/DV+6/GcuOQT3eGE1UNly9UgPe+qnH0inAJOR6PdMNh0evl m7CeIjjTQEBk/wJ7SJh3hYHGFHnX1vbX2702B84aeDq2tdOzTHPSMP3hUpaxxYOVIRYk 6Zk9llVq+4VFR4LlcuhoAZzVm7Dv0PCWYuU0v8cTx122B/xNIx8QVTYJErIyiQDrZSYO XVypVdeUbizI8YsHvcpLwlKfKGxrAm/XhL871igEe0cXkdEQ9FTvkXKBbcNk2oYvoU7G wXZ1E8l2M01oZe1kOGy51hwoucn2mS54AslR7s2wmCzkdVyyTAHqki0QGT07Wrrvbhh3 UTFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TleZrH6+eL/cU0zYuJa2/PLVKmSzDIq4EPgQ3CnSogg=; b=WRp8oEisWQL9ytaMC5OIXP7GrorawLEPdla9CcfvPHideoIFrvMLPWpHkRTeA9Njfg FM+GpcUhMfwaPI2vImgU/G6sE55wFY501AZyl0qqohlqJgmBqy97Nz/FcSni9sKGwtF/ AOfxElOR3l7x7e/AwFf5kdq5lb8ITJfGGWzL+K7SZiFuT5UcdsiCeFfmEBP3aCp7vBFM Etu/O2hhEj8IbMnW+JaPDUiIXZ2tUtgzto0i1+TND6ht6qNIN2wcurVzl9fEKgDSdTHR DKn3XtGgVlY5vzGNsei01lXQ4yyPizITGpH6paQ8GxM4hiMlx/mmwz0QU30JFSjmgown Apfg== X-Gm-Message-State: APjAAAVnYqv0sd2d0AQtJR1Aqb9cTOQDv6xbfDQt9dbjgIZJEp1XKt97 3BQPH1TNULOQEHurg3sdTReEuiCmIuayghpWcYp6nQ== X-Google-Smtp-Source: APXvYqw8KcdU+vQOAqLAf+yR3LVq+PXhMMEbLMdm5TDLtCZvYiGGaKItPu9rCcKQ9TJJuYOXphD2wGDrANQjLV1hrkU= X-Received: by 2002:a9d:708e:: with SMTP id l14mr13785006otj.135.1570818195995; Fri, 11 Oct 2019 11:23:15 -0700 (PDT) MIME-Version: 1.0 References: <237dbf6e-cd91-4e6d-8c97-1fbbabcd9f21@www.fastmail.com> In-Reply-To: <237dbf6e-cd91-4e6d-8c97-1fbbabcd9f21@www.fastmail.com> Date: Fri, 11 Oct 2019 19:23:04 +0100 Message-ID: To: Larry Garfield Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000943ff40594a69c5d" X-Envelope-From: Subject: Re: [PHP-DEV] Warning for "confusable" types From: oludonsexy@gmail.com (Olumide Samson) --000000000000943ff40594a69c5d Content-Type: text/plain; charset="UTF-8" On Fri, Oct 11, 2019, 6:47 PM Larry Garfield wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php As a warning I think, seems I've encountered those errors many times ago. The solution Nikita propose is good, it doesn't deal with too much. These errors are there already, only just giving it a properly meaningful description. +1 for the proposed description. --000000000000943ff40594a69c5d--