rfc:new_in_initializers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:new_in_initializers [2021/06/16 07:46] – nikic | rfc:new_in_initializers [2021/07/14 07:19] (current) – nikic | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2021-03-02 | * Date: 2021-03-02 | ||
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
* Proposed Version: PHP 8.1 | * Proposed Version: PHP 8.1 | ||
- | * Implementation: | + | * Implementation: |
===== Introduction ===== | ===== Introduction ===== | ||
Line 85: | Line 85: | ||
New expressions continue to not be supported in (static and non-static) property initializers and class constant initializers. The reasons for this are twofold: | New expressions continue to not be supported in (static and non-static) property initializers and class constant initializers. The reasons for this are twofold: | ||
- | For non-static property initializers, | + | For non-static property initializers, |
Performing the initialization by injecting code in the constructor avoids the issue, but requires that constructor to actually be called. In particular, this would necessitate generating constructors for classes that do not explicitly declare them, and the disciplined invocation of such constructors from potential child constructors. The third option would be to introduce an additional initialization phase between creation and construction. | Performing the initialization by injecting code in the constructor avoids the issue, but requires that constructor to actually be called. In particular, this would necessitate generating constructors for classes that do not explicitly declare them, and the disciplined invocation of such constructors from potential child constructors. The third option would be to introduce an additional initialization phase between creation and construction. | ||
- | For static property initializers and class constant initializers a different evaluation order issue arises. Currently, these initializers are evaluated lazily the first time a class is used in a certain way. Once initializers can contain potentially side-effecting expressions, | + | For static property initializers and class constant initializers a different evaluation order issue arises. Currently, these initializers are evaluated lazily the first time a class is used in a certain way (e.g. instantiated). Once initializers can contain potentially side-effecting expressions, |
As such support in these contexts is delayed until such a time as a consensus on the preferred behavior can be reached. | As such support in these contexts is delayed until such a time as a consensus on the preferred behavior can be reached. | ||
Line 123: | Line 123: | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
- | This RFC is narrow in that it only adds support for '' | + | This RFC omits support for '' |
+ | |||
+ | With the precedent set by '' | ||
===== Vote ===== | ===== Vote ===== | ||
- | Yes/No. | + | Voting opened on 2021-06-30 and closes on 2021-07-14. |
+ | |||
+ | <doodle title=" | ||
+ | | ||
+ | | ||
+ | </ | ||
rfc/new_in_initializers.1623829618.txt.gz · Last modified: 2021/06/16 07:46 by nikic