Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110333 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33434 invoked from network); 2 Jun 2020 13:44:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Jun 2020 13:44:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C8F321804E4 for ; Tue, 2 Jun 2020 05:26:40 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (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 ; Tue, 2 Jun 2020 05:26:40 -0700 (PDT) Received: by mail-ua1-f43.google.com with SMTP id a10so1165741uan.8 for ; Tue, 02 Jun 2020 05:26:40 -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=vrv/60Ghm7yxqhExAP68d8QjcX2mRFNrn7h9siXA5Cg=; b=GD9QjUYeLStSJBEab+GYd/YDmb4mPZEgl5uDdOd060i4nNtZjD4DakSzoTH26begLy /VGU7jvXx6PG3aZukMYhGMUG96tJ6oPXtQuLsqx9PzuRPEMOsifpAT86I46q6QDauEyc 8FQNz/jxpijCK2pMFSmhEGKQ35Il/q8QvTaqCYyjWwHLH26QFdC5ff+8h9mDU9H8zd81 9ZjIYs9/8nR7eO26K0niFYOHPC55vKnMnh+VH2CGPXgQMCXpVLJACWAtVv3496mMTs9z o9v7aBwBiZRtIM/aum2wrMWawDA3Eb+zAfE7CtujIfOZknGWCjaHKWlgTgVqqlWAwWej 0eNA== 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=vrv/60Ghm7yxqhExAP68d8QjcX2mRFNrn7h9siXA5Cg=; b=fwQD3Zh0cSrqe2CF5LtD9VQAazG4lUDuj7Mel7mAv6xok6kkOvyYkEiteMJ+mBVvdy BimHzlPYsbBRiz/qeRdNW1eZRqXioOzrInN/rozU296y6g4SFKc4CQJ1MhE2OeUDc1y1 yfx9OZ1INON6LoqjbkZCkSQd3v9MprzAE6B4Pq0SeC2DA8CIrrukr7mDMHnGhDpTHr2H cJELiSReio9FEO5RS//Dl9xb0d4FnBBtLyHUlRm5PkTlYADwTHsVguUcbcPjKw8EEhwJ 6kLZyO5SM56vnoxJKIErqxiBPYUy6Ew+i+cSJVneDucJoVJpl43X7QGEOu2uNIf5dc/b hL3w== X-Gm-Message-State: AOAM532d3jJeopQKlNJ6V7voOO85pbhbUpVcuPA2iU+Ya9sjBgSuy6pJ Hp6RqKrSirZSTtxnwgrPSWMFiF3WOAZNUUi27D0= X-Google-Smtp-Source: ABdhPJzWhUacqy3UCQUVsLH8eZzdG0FlHmC3WbUBex6HRV3Gw5qmL+FE9TB8pFrWqANATnPac1G963w10yrow9PfMSw= X-Received: by 2002:ab0:2358:: with SMTP id h24mr16739000uao.82.1591100799619; Tue, 02 Jun 2020 05:26:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 2 Jun 2020 15:26:28 +0300 Message-ID: To: Gabriel Caruso Cc: Nikita Popov , PHP Internals Content-Type: multipart/alternative; boundary="000000000000f699b205a71905c0" Subject: Re: [PHP-DEV] [VOTE] Ensure correct signatures of magic methods From: dmitrystogov@gmail.com (Dmitry Stogov) --000000000000f699b205a71905c0 Content-Type: text/plain; charset="UTF-8" Does this RFC support __get() returning by reference? See https://github.com/php/php-src/blob/master/Zend/tests/overloaded_prop_assign_op_refs.phpt#L11 Thanks. Dmitry. On Mon, Jun 1, 2020 at 12:20 AM Gabriel Caruso wrote: > On Sun, 31 May 2020 at 15:57, Nikita Popov wrote: > > > On Fri, May 29, 2020 at 6:45 PM Gabriel Caruso < > carusogabriel34@gmail.com> > > wrote: > > > >> Hello, internals! > >> > >> I have opened the voting for > >> https://wiki.php.net/rfc/magic-methods-signature. > >> > >> The voting period ends on 2020-06-19 at 18h (CEST). > >> > > > > The RFC is a bit unclear on what is actually being proposed. It says > > > > > This RFC proposes to add parameter and return types checks per the > > following details. > > > > and goes on to list (reasonable looking) magic method signatures, but > does > > not say how exactly those types are going to be checked. Is this going to > > require exactly the same signature, or is this going to be in accordance > > with variance rules? For example, are all of the following signatures > valid > > under this RFC? Only the first two? None of them? > > > > // Narrowed return type from ?array > > public function __debugInfo(): array {} > > > > // Narrowed return type from mixed > > public function __get(string $name): int {] > > > > // Widened argument type from string > > public function __get(string|array $name): mixed {} > > > > > They are going to be checked following the variance rules, not the > *exactly* same as the RFC. I'll mention this, thanks for point it out. > > Assuming this, your examples: > > 1 and 2. Will be valid, following the rules introduced by the `mixed` RFC. > > 3. Is that allowed in PHP? If so, the RFC will compliance with that. > > > > > > Also, is omitting the return type still permitted, even though it would > > nominally violate variance? > > > > public function __debugInfo() {} > > > > Yes, this hasn't changed. The RFC only affects *typed* methods. > > > > > > Finally, if omitting the return type is permitted, will an implicit > return > > type be added, like we do for __toString()? Would the method > automatically > > become > > > > public function __debugInfo(): ?array {} > > > > An implicit return type won't be added for any of the magic methods. I > believe that's a huge BC, and I don't want to debate that for PHP 8 (maybe > PHP 9, yes). > > > > > > and report as such from reflection? > > > > I need more clearance on this one: are you asking how magic methods are > reported via Reflection and if that will be changed? > > > > > > Nikita > > > --000000000000f699b205a71905c0--