Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115284 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5034 invoked from network); 3 Jul 2021 14:47:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jul 2021 14:47:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E38CE180502 for ; Sat, 3 Jul 2021 08:08:06 -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-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 ; Sat, 3 Jul 2021 08:08:06 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id a18so23819547lfs.10 for ; Sat, 03 Jul 2021 08:08:06 -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=UwZ2uD+YAUHe2F6ybfpfAKc6X3Msy1X0bV8plj8Ss/A=; b=TicSibqZIz03nlDHmK13LAMmTPiG4PVPzyDwZvBcv/aJHEHE3mEEzHilQ/i0tmdBZN 6dd8eiWoJwvx8bzne+HtW1bA0H5TJ2uMPqrpVmJZtL1cIBQSo/UjjBGl14fH4SQyApCf WFuYsMCIvQ7Dqu+gDhz0szF1C9GDcabjG+tuJyTe9PwfotIK4iH0ZPSTiNx7bUoDf2/t eO94sEpv9BbxZx64iiMNHVa3L00tbvgaioFZpcuQdUjF5KY//PvjCoDkQnqiHoP1858B MJ0xE8Bb7k1xfCFGrjJQdQCyNX9Aixwk/czzTgCcz+If5odgqnGTvp849iv4DenVyQPJ JvOQ== 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=UwZ2uD+YAUHe2F6ybfpfAKc6X3Msy1X0bV8plj8Ss/A=; b=F6oNuSpDvejdnu6eziyaHhfuly6/HDbdMdWzk6tKdNUdOG0pSYsYoqqK3bu3eq3a+Q yS5OjzYFqaAOuSyP14i2cR8uP0XqmVkbwMz669lwRTydNlSoS43P/pRBAsg//cgE/0P+ cdjM7+Z3XzOkiJYUTgEMHZFpBC9KsxZkxAZkQKl2nusMTjV05aTeHxFP3UiisM6WZ0cG 0ZreAH14tQ47qNav2A8ZpBwM5lnYkcg9flD31AKC2S1HZLp5PEzxEgW1NVZy9X7p01E1 Vgw/bGO2hcAS8m096XCENGriEjCPhShxa4S+TNqPjgCsWiSsVS6g7m0nmMOaJBvo41mm MQ9Q== X-Gm-Message-State: AOAM533Oo/jf640CQq5h7/Qx4FmqfP0Q3wSdV6m47CoKrsgUoR4vdG57 tGR/iUYWU4Vz3BJJak0AhTnzW+LmyeoLI0xOavgzjlZ8tpc= X-Google-Smtp-Source: ABdhPJzjE0N7rPahLczzD+OpOJnIMkIkGJ/tjcXAPZ4W9N6vdmsVMrZAQXJfs9HHz8arukdKzJ2NLYEVQJSF7uF6ww0= X-Received: by 2002:a19:7d05:: with SMTP id y5mr3813016lfc.159.1625324881652; Sat, 03 Jul 2021 08:08:01 -0700 (PDT) MIME-Version: 1.0 References: <802fdb7d-69e5-edfa-de94-70416f9093d0@ralphschindler.com> <7f09e13c-7f35-b771-de4c-94c5a35df497@ralphschindler.com> In-Reply-To: <7f09e13c-7f35-b771-de4c-94c5a35df497@ralphschindler.com> Date: Sat, 3 Jul 2021 17:07:45 +0200 Message-ID: To: Ralph Schindler Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000037309905c6397047" Subject: Re: [PHP-DEV] [VOTE] First-class callable syntax From: nikita.ppv@gmail.com (Nikita Popov) --00000000000037309905c6397047 Content-Type: text/plain; charset="UTF-8" On Sat, Jul 3, 2021 at 3:51 PM Ralph Schindler wrote: > > > It would theoretically be: > > > > $fn = MyController::myAction(...); > > > > It currently errors: > > > >> Fatal error: Uncaught Error: Non-static method MyController::myAction() > cannot be called statically > > > > I would be okay with allowing this, as long as it's bound before it's > called. > > > One other question regarding the current patch. I have not seen this > aspect discussed yet. > > From the list in the first proposal section > (https://wiki.php.net/rfc/first_class_callable_syntax#proposal), I am > focusing this question on the few that are by name (strings).. so: > > strlen(...); > Foo::method(...); > $classStr::$methodStr(...); > self::{$complex . $expression}(...); > 'strlen'(...); > [Foo::class, 'method'](...); > > Do these have to scan the target function and its signature in order to > wrap them? In the cases of classes above, this will trigger the > autoloader. I wonder if it could create a by-name reference that > resolves the signature at just in time / at call time in these situations? > > In context, suppose I am suggesting that something like: > > $routes = [ > '/my-action' => MyController::myAction(...), > '/other-action => [OtherController::class, 'otherAction'](...), > ... > ]; > > would not invoke the autoloader until one of them may be actually > used/called. > > This would be similar in philosophy as to how Foo::class creates a fully > qualified string without confirming a class exists at that name when the > scanner and executor sees ::class. > No, something like this will definitely not be supported as part of this syntax. It is fundamentally at odds with this proposal, which requires that callability is validated at point of creation, rather than at point of call (both of these may differ). Regards, Nikita --00000000000037309905c6397047--