Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate @ReadOnly annotation in favor of @ReadOnlyProperty #1333

Merged
merged 1 commit into from
Aug 1, 2021
Merged

Deprecate @ReadOnly annotation in favor of @ReadOnlyProperty #1333

merged 1 commit into from
Aug 1, 2021

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Jul 31, 2021

Q A
Bug fix? yes
New feature? yes
Doc updated yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #1331
License MIT

With readonly becoming a keyword in PHP 8.1 thanks to the addition of readonly properties, classes can no longer use it as a name. This means the @ReadOnly annotation can't be used with PHP 8.1. As suggested in the issue, this PR creates a new @ReadOnlyProperty annotation and deprecates the existing @ReadOnly annotation.

* @Annotation
* @Target({"CLASS","PROPERTY"})
*/
/* final */ class ReadOnlyProperty
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purposefully left as not final and only annotated @final to help with B/C and code complexity. Otherwise, there'd have to be a lot of PHP version conditionals and checks for both annotation classes. In 4.0, when the deprecated @ReadOnly annotation is removed the final should be uncommented.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense! i'm ok with it

@goetas goetas merged commit 8a577ec into schmittjoh:master Aug 1, 2021
@goetas goetas linked an issue Aug 1, 2021 that may be closed by this pull request
@mbabker mbabker deleted the readonly-replacement branch August 1, 2021 14:27
kszymukowicz added a commit to sourcebroker/t3api that referenced this pull request Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@ReadOnly annotation incompatible with PHP 8.1
2 participants