Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113268 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31721 invoked from network); 25 Feb 2021 16:03:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Feb 2021 16:03:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C3642180503 for ; Thu, 25 Feb 2021 07:52:02 -0800 (PST) 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, YOU_INHERIT autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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, 25 Feb 2021 07:52:02 -0800 (PST) Received: by mail-lj1-f172.google.com with SMTP id u4so7040042lja.3 for ; Thu, 25 Feb 2021 07:52:02 -0800 (PST) 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=4jTz394u3+nkqX6XnERAJ80h0JeojJ37A5oDkctdUxs=; b=XNg6sb5LYeUK3XYtbgalQpe9DBrPYe+bLusXrwTQY4frsv1ELJCQbEPCwNxr+66pOJ UnURga+mB8aVjeMSpcFxf+4+r4gwwnGnE8p+idUomEvPlSZABjzQ550LlP35xvzeOc15 vNNe47gtuWalxgYxNSwCDaDkdAerzd39ORDeaOFushcdIF1RlbFfRBy4Un405RQCq90i jUshhstIlFhq32Fe/YuOR9sWhZuP3+AWVxqCB2nDvRCLCAMswgi6BHEFEOVWCayEwqMo 6FX4yHsj7NxLF7eU5Ej42KhHYcr6wbCEMCHhx/Qr9tSrA5Wc3TT2nMRDl7BiFBPxlQ/F Uh4A== 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=4jTz394u3+nkqX6XnERAJ80h0JeojJ37A5oDkctdUxs=; b=cClX6iP+6h1jwW2PXCMvTaZsb8yl9dUCY2iOQvI9Bf5/CVZ8VP7b5+uccCT/wEIY+z wZqKFmIku2F+SlL26PByCdHYXtA5gvEDjmvHjguFCG72I2yjQlT1M2B4W6jR1VGKzHTb P3MVl0v37EjCg4WtamatLKVZXeINr2PA3W+hLjI3agBa1iDHNHZE4muUPACdYXbmkF8L XR4A8sXBIIFl6pZr4LPBL+aojMhLuI2RJjAzdddNhowuG4GXxB9IV4EtRoeLS/HMYiLD 8f4uBidNob5Yb443kexgy3suKoveS5qh0qclJpwaS3tssg9cp8CPgrM7jGk8kNlgmTVl tmKQ== X-Gm-Message-State: AOAM531zYGCB+n5UocdPbjKTaNzHhCRqFiq47jzXF6YEGJHT+r6MKe4j 55txq7Hyff+av7YtVqbuCm/cXDOjqV9t7DZtTx8= X-Google-Smtp-Source: ABdhPJxkzGOk31+zI8DUMqwcJXAaIirNsnN6QtBR+cn0CA6mYasRpWzQhraq0b1Rv5EMIlpZd7qZ0cYU74kN/lKCYCs= X-Received: by 2002:a05:651c:3cb:: with SMTP id f11mr1954938ljp.272.1614268320570; Thu, 25 Feb 2021 07:52:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 25 Feb 2021 16:51:44 +0100 Message-ID: To: Glash Gnome Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000d1e17505bc2b21e8" Subject: Re: [PHP-DEV] [RFC] Static variables in inherited methods From: nikita.ppv@gmail.com (Nikita Popov) --000000000000d1e17505bc2b21e8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 25, 2021 at 4:46 PM Glash Gnome wrote: > Dears, > > Let me briefly introduce myself. I have been a C coder for 19 years, > including 12 years with php. And I also do Java, C++, Javascript... from > time to time. > > Nikita, What would the equivalent of this code be after RFC modification? > > > class CXPLeaks > { > static function refCount() { > static $i=3D0; > $i++; > } > function refCountByClass() { > static $i=3D0; > $i++; > } > function __construct() { > self::refCount(); > self::refCountByClass(); > } > } > > > Declaring a static variable in a class or in a function, in terms of > speed/work it's the same. > For me, this is not a bug. It's a misunderstanding > For me, who codes in C, the current behavior is intuitive. > For me, there is no language as agile as PHP. > > Best regards, > Serge > Your example does not contain inheritance, so the RFC has no impact on it. As such, I do not understand your question. Nikita > Le mar. 23 f=C3=A9vr. 2021 =C3=A0 15:02, Nikita Popov a > =C3=A9crit : > >> Hi internals, >> >> While looking into various issues related to static variable handling, >> I've >> become increasingly convinced that our handling of static variables in >> inherited methods is outright buggy. However, it's also long-standing >> behavior, so I've put up an RFC: >> >> https://wiki.php.net/rfc/static_variable_inheritance >> >> Regards, >> Nikita >> > --000000000000d1e17505bc2b21e8--