rfc:arbitrary_static_variable_initializers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:arbitrary_static_variable_initializers [2023/03/16 14:39] – Fix typos theodorejb | rfc:arbitrary_static_variable_initializers [2023/05/24 18:29] (current) – Move to implemented ilutov | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2022-11-06 | * Date: 2022-11-06 | ||
* Author: Ilija Tovilo, tovilo.ilija@gmail.com | * Author: Ilija Tovilo, tovilo.ilija@gmail.com | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.3 | * Target Version: PHP 8.3 | ||
* Implementation: | * Implementation: | ||
Line 70: | Line 70: | ||
</ | </ | ||
- | The static variable is overridden at compile time resulting in both statements | + | The static variable is overridden at compile time, resulting in both statements |
variable initializer. This is not useful or intuitive. The new implementation is not compatible with this behavior but | variable initializer. This is not useful or intuitive. The new implementation is not compatible with this behavior but | ||
would instead result in the first initializer to win. Instead of switching from one dubious behavior to another, | would instead result in the first initializer to win. Instead of switching from one dubious behavior to another, | ||
Line 85: | Line 85: | ||
==== ReflectionFunction:: | ==== ReflectionFunction:: | ||
- | < | + | < |
current values. Currently, PHP automatically evaluates the underlying constant expression and initializes the static | current values. Currently, PHP automatically evaluates the underlying constant expression and initializes the static | ||
variable if the function has never been called. With this RFC this is no longer possible, as static variables may depend | variable if the function has never been called. With this RFC this is no longer possible, as static variables may depend | ||
Line 158: | Line 158: | ||
} | } | ||
- | function foo() { | + | function foo($y) { |
$x = new Foo(); | $x = new Foo(); | ||
- | static $x = 42; | + | static $x = $y; |
} | } | ||
try { | try { | ||
- | foo(); | + | foo(42); |
} catch (Exception) {} | } catch (Exception) {} | ||
Line 225: | Line 225: | ||
===== Vote ===== | ===== Vote ===== | ||
- | Voting starts | + | Voting starts |
As this is a language change, a 2/3 majority is required. | As this is a language change, a 2/3 majority is required. |
rfc/arbitrary_static_variable_initializers.1678977575.txt.gz · Last modified: 2023/03/16 14:39 by theodorejb