Re: [RFC][Vote announcement] Arbitrary static variable initializers

From: Date: Fri, 17 Mar 2023 11:32:33 +0000
Subject: Re: [RFC][Vote announcement] Arbitrary static variable initializers
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-119737@lists.php.net to get a copy of this message
Hi Thank you, I've had another read through the RFC. On 3/16/23 12:51, Ilija Tovilo wrote:
Let me know if anything is still unclear.
Isn't the destructor+exception example misleading? In that case the initial value of '$x' is constant, thus it should always be known to reflection, no? Should the example look like this:
function foo($y) {
    $x = new Foo();
    static $x = $y;
} try {
    foo(42);
} catch (Exception) {}
? Side-Note: I find the behavior of static variables that do not overwrite existing variables extremely confusing, even without this RFC: https://3v4l.org/ApIcA. Anyone who doesn't define them at the very top of a function deserves a special place in hell :-) Best regards Tim Düsterhus

« previous php.internals (#119737) next »