Closed
Conversation
An instance of a locked class may not: - have properties added that were not declared - have properties read that were not declared - have properties unset
IMSoP
commented
Mar 10, 2019
| #define ZEND_ACC_REUSE_GET_ITERATOR (1 << 17) /* X | | | */ | ||
| /* | | | */ | ||
| /* Class is declared "locked" | | | */ | ||
| #define ZEND_ACC_LOCKED (1 << 18) /* X | | | */ |
Contributor
Author
There was a problem hiding this comment.
Since this constant will be exposed to userland (via ReflectionClass::IS_LOCKED), whereas most of these aren't, such a high number might seem surprising to users, but I'm not sure of the impact of rearranging this list.
Member
There was a problem hiding this comment.
We don't make any particularly guarantees about the values of those flags in reflection (in fact, they change between releases). I wouldn't worry about this.
jpmarcotte
reviewed
Mar 11, 2019
| @@ -0,0 +1,40 @@ | |||
| --TEST-- | |||
| A sub-class of a locked class is not locked unless explciitly marked | |||
There was a problem hiding this comment.
Suggested change
| A sub-class of a locked class is not locked unless explciitly marked | |
| A sub-class of a locked class is not locked unless explicitly marked |
Contributor
Author
|
This proposal has been withdrawn. See the RFC for details of why. |
php-pulls
pushed a commit
that referenced
this pull request
Jun 24, 2020
While performing resource -> object migrations, we're adding defensive classes that are final, non-serializable and non-clonable (unless they are, of course). This path adds a ZEND_ACC_NO_DYNAMIC_PROPERTIES flag, that also forbids the creation of dynamic properties on these objects. This is a subset of #3931 and targeted at internal usage only (though may be extended to userland at some point in the future). It's already possible to achieve this (what the removed WeakRef/WeakMap code does), but there's some caveats: First, this simple approach is only possible if the class has no declared properties, otherwise it's necessary to special-case those properties. Second, it's easy to make it overly strict, e.g. by forbidding isset($obj->prop) as well. And finally, it requires a lot of boilerplate code for each class. Closes GH-5572.
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.
Initial implementation of "locked classes", as described in https://wiki.php.net/rfc/locked-classes
Included tests all pass, but there may be situations I have not considered, or other places that will need changing.