Implement readonly modifier for classes - #138
Merged
Merged
Conversation
thekid
commented
May 6, 2022
| } | ||
|
|
||
| #[Test, Ignore('Until proper error handling facilities exist')] | ||
| public function readonly_classes_cannot_have_static_members() { |
Member
Author
There was a problem hiding this comment.
This proper error handling means any way of raising an exception from within the emitting phase and having it turned into a lang.ast.Error with file and line set.
Member
Author
There was a problem hiding this comment.
Maybe these also need to go into the parser - where, instead of returning lang.ast.Node instances directly, we'd do something like:
// Before
return new PropertyNode(...);
// After
return $this->ast->property(...);...and have two separate ast implementations: checked and unchecked. This would be part of a greater refactoring, thus keeping it for a separate pull request.
Member
Author
|
Released in https://github.com/xp-framework/compiler/releases/tag/v8.4.0 - removing the emulation from PHP 8.2 emitter can be done once the php-src PR is merged, and released in a separate release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See https://wiki.php.net/rfc/readonly_classes and xp-framework/ast#37. The following comes quite close to records, although it doesn't declare getters but uses public readonly fields:
readonlymodifiers on classes to all members and promoted constructor parametersreadonlyon traits, interfaces and enumsreadonlymodifiers do not match#[AllowDynamicProperties]on readonly classes