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

Check for readonly properties #89

Closed
RV7PR opened this issue Aug 8, 2024 · 3 comments
Closed

Check for readonly properties #89

RV7PR opened this issue Aug 8, 2024 · 3 comments

Comments

@RV7PR
Copy link

RV7PR commented Aug 8, 2024

In this old issue opis/closure#28 I had a problem with readonly properties so they fixed it with this opis/closure@3.1.5...3.1.6 though this ($property->getDeclaringClass()->isUserDefined()) isn't needed for PHP >= 8.1, you can just skip the readonly properties like #87

@driesvints
Copy link
Member

Thanks @RV7PR. @rust17 could this be an alternative implementation?

@rust17
Copy link
Contributor

rust17 commented Aug 8, 2024

I believe these are two separate issues.

The $property->getDeclaringClass()->isUserDefined() method solves the Cannot write property problem, whereas $property->isReadOnly() deals with the Cannot modify readonly property issue. As you can see, the opis/closure encounters the Cannot modify readonly property issue during unserialization, similar to what was reported in laravel/framework#51877.

Therefore, I don't think this is an alternative solution.

Additionally, this line of code($property->getDeclaringClass()->isUserDefined()) is already present in laravel/serializable-closure: https://github.com/laravel/serializable-closure/blob/master/src/Serializers/Native.php#L371.

@driesvints
Copy link
Member

Thanks @rust17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants