|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-01-27 23:37 UTC] jeremeamia at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
Description: ------------ This seems like a very arbitrary restriction from the PHP Developers. I don't know much about the internals of how they work, but serialzing variables used in the use() part is no different than storing instance variables inside objects so that shouldn't pose an issue. The issue, I'm guessing, is the method body. As it's not in a file it cannot be loaded if the variables are serialized, but since a Closure object is an internal class, why can't PHP store the method body in the closure object itself as an instance variable? Then the Closure object could be serialized and when unserialized, essentially just eval the method body to restore it? The closure class would then have a structure something like this: class Closure { private $body; private $args = []; private $bodyText; public function __invoke(...$args) { $this->body(...$args); } public function __wakeUp() { $this->body = eval($this->bodyText); } }