Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114541 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57594 invoked from network); 20 May 2021 17:27:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 May 2021 17:27:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C89BC1804D8 for ; Thu, 20 May 2021 10:37:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 20 May 2021 10:37:18 -0700 (PDT) Received: by mail-vk1-f178.google.com with SMTP id o24so1564775vkf.5 for ; Thu, 20 May 2021 10:37:18 -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=2V23cKxtkAWEHeNQnCUKN3+er2joUY0LMqfBYJkw+eY=; b=PsToB8l/JBS76BRa9G5zt4tkQ4PiYX4O2D7WR8vJBbqyYRr43Xsdx9GwuWRY7w+s6S 4gBmYFhRH43dGhxfurFB91NjnpMzRTqVB+dYVElRxtMtmaGUmjxesisi2RkmS7C0c50W j9816K+EYQfNpiwNpGyb7mhuUZVLrHuoCaUCQUHVFHuVlGBdgRXKc671ruycsS3Wi/Ol bRedVuws6NYFAIj1CRqkA0z8VLkDl6gINQkzyFHXfnLCJfgyKivjyNenvgYhsF7cd9YQ duewu5ZpjJDqC2bdJDJwJ/P0Noi9SyXb+CHmKLm+350YQf1E9x381B1Yi3+VDNXQXTu7 EO1A== 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=2V23cKxtkAWEHeNQnCUKN3+er2joUY0LMqfBYJkw+eY=; b=YojtGnfsJYhqskcRSq8QO8k1RppLWogQU3IipQb0lTDomSStUeRPAliwuFbogfRnN0 lUahqaeE1RDogickr3KsJ9yc9jafGvyRwYYyP4tOtVdLuv5DNvMDA5bKgv/QKa/AaUiT +S2XLsQIpbSHUdclZMJXzAiSNGiSmET5nIgSTqGBNpDYhEDMd+CHzhmgAtl0SHi8e6q/ 8/Nu2K2VcCSceqbO15EWGDC7jkLPBnPq/kTPHb1VG+0xefSJQDXxxtEeN3erUrLm+Fo+ kOpEcKzy7j0bfInG2OETPVvCmTKxRQbIs4MHdBeSy1rOaYv+7XhSNEkDr1neSzduMDBO Kxgw== X-Gm-Message-State: AOAM531vaI/pls2VSUdHtX4gHD1RIAY1TYYGYphn1eS4GdHa+SStB57J oaDxIUJ6bML8KqFc/Vf7zozH4yliCpiB39Uga7Y= X-Google-Smtp-Source: ABdhPJyl0bUMWz2o2CWorqa9OSumEMxfEElAMi4qYx8/mmejajj7Nc4C/aRmngtL8R6/4iLda/QJXTiQl2k18Ic9nTs= X-Received: by 2002:a1f:eec6:: with SMTP id m189mr5292843vkh.5.1621532233353; Thu, 20 May 2021 10:37:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 20 May 2021 13:37:02 -0400 Message-ID: To: =?UTF-8?Q?Ond=C5=99ej_Mirtes?= Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary="000000000000c2cbec05c2c66456" Subject: Re: [PHP-DEV] [RFC] First-class callable syntax From: matthewmatthew@gmail.com (Matthew Brown) --000000000000c2cbec05c2c66456 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 20 May 2021 at 10:17, Ond=C5=99ej Mirtes wrote: > Hi, I=E2=80=99m confused by the syntax, when I read it, I think to myself= =E2=80=9CI know > this, this is just a method call=E2=80=A6 oh wait, it=E2=80=99s actually = a callable=E2=80=9D. It > really makes my head hurt. > I agree with the first point =E2=80=94 slightly confusing initially, but I = can see myself get used to it. I suggested strlen(=3D>) as an alternative, not sure if that would cause parsing difficulties. > Also, static analysers already have to reason about current code, so > PHPStan (and Psalm probably too) already supports referencing to callable= s > as strings (global functions) and arrays (methods): > > $name =3D 'date'; > $name(1); // Parameter #1 $format of callable 'date' expects string, int > given. > I disagree here: while Psalm can understand what's going on in the above code, callables are definitely (in my opinion) the most hairy part of PHP's type system. The RFC gives an example of something not caught by either PHPStan or Psalm= : https://psalm.dev/r/21217fdfb4 https://phpstan.org/r/6cc8cdc2-ecc6-403d-887d-0f12f4813b75 Discouraging this particular formulation would make affected codebases safe from this particular error. Best wishes, Matt --000000000000c2cbec05c2c66456--