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

3.0.11 breaks internalObject if part of use in the closure #20

Closed
arunpoudel opened this issue Feb 23, 2018 · 1 comment
Closed

3.0.11 breaks internalObject if part of use in the closure #20

arunpoudel opened this issue Feb 23, 2018 · 1 comment

Comments

@arunpoudel
Copy link

Example:

$test = [
    'time' => new \DateTime('2001-10-10')
];

$function_that_will_produce_invalid_closure = function() use($test) {
    return $test;
}

serialize(new SerializableClosure($function_that_will_produce_invalid_closure ));

Expected Result:
C:32:"Opis\Closure\SerializableClosure":324:{a:5:{s:3:"use";a:1:{s:4:"test";a:1:{s:4:"time";O:8:"DateTime":3:{s:4:"date";s:26:"2001-10-10 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}}s:8:"function";s:59:"function() use($test) { return $test; }";s:5:"scope";N;s:4:"this";N;s:4:"self";s:32:"000000003d57f521000000006e745c4b";}}

Actual Result:
C:32:"Opis\Closure\SerializableClosure":229:{a:5:{s:3:"use";a:1:{s:4:"test";a:1:{s:4:"time";O:8:"DateTime":0:{}}}s:8:"function";s:59:"function() use($test) { return $test; }";s:5:"scope";N;s:4:"this";N;s:4:"self";s:32:"00000000535ee1e0000000001c44dfb8";}}

The code at fault seems to be this line. As soon as it finds out that it is an internalObject it doesn't assign any value to $data

if(!$reflection->isUserDefined()) {
    break;
}
@msarca
Copy link
Member

msarca commented Feb 23, 2018

Fixed in v3.0.12

@msarca msarca closed this as completed Feb 23, 2018
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

No branches or pull requests

2 participants