Skip to content

Conversation

@calebdw
Copy link
Contributor

@calebdw calebdw commented Jan 17, 2026

Hello!

When an object is serialized, all of its properties are recursively walked using reflection to wrap any closures. However, when an object has a property that's typed as Closure this causes a TypeError to be thrown (cannot assign Native to property of type Closure)---even on objects that implement __serialize and explicitly handle the closure.

The fix is to simply check if an object implements __serialize and if so, defer to that method for serialization instead of trying to still walk its properties.

Thanks!

@calebdw calebdw force-pushed the calebdw/push-oyuwvppslusq branch 2 times, most recently from 87e7622 to 6afdf2f Compare January 17, 2026 03:02
@calebdw calebdw force-pushed the calebdw/push-oyuwvppslusq branch from 6afdf2f to 3f34361 Compare January 17, 2026 03:09
@taylorotwell taylorotwell merged commit 5c6952d into laravel:2.x Jan 19, 2026
12 checks passed
@calebdw calebdw deleted the calebdw/push-oyuwvppslusq branch January 19, 2026 15:35
@calebdw
Copy link
Contributor Author

calebdw commented Jan 19, 2026

Thanks!

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.

2 participants