Skip to content

Commit

Permalink
Merge pull request #352 from KendallHopkins/master
Browse files Browse the repository at this point in the history
Only prevent serialization of the Closure object.
  • Loading branch information
sebastianbergmann committed Sep 26, 2011
2 parents 0173089 + 304b43e commit 39cb742
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions PHPUnit/Util/GlobalState.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static function backupGlobals(array $blacklist)
if ($key != 'GLOBALS' &&
!in_array($key, $superGlobalArrays) &&
!in_array($key, $blacklist) &&
!is_callable($GLOBALS[$key])) {
!(is_object($GLOBALS[$key]) && $GLOBALS[$key] instanceof Closure)) {
self::$globals['GLOBALS'][$key] = serialize($GLOBALS[$key]);
}
}
Expand Down Expand Up @@ -231,7 +231,7 @@ public static function getGlobalsAsString()
if (isset($GLOBALS[$superGlobalArray]) &&
is_array($GLOBALS[$superGlobalArray])) {
foreach (array_keys($GLOBALS[$superGlobalArray]) as $key) {
if (is_callable($GLOBALS[$superGlobalArray][$key])) {
if (is_object($GLOBALS[$superGlobalArray][$key]) && $GLOBALS[$superGlobalArray][$key] instanceof Closure) {
continue;
}

Expand All @@ -250,7 +250,7 @@ public static function getGlobalsAsString()
$blacklist[] = '_PEAR_Config_instance';

foreach (array_keys($GLOBALS) as $key) {
if (!in_array($key, $blacklist) && !is_callable($GLOBALS[$key])) {
if (!in_array($key, $blacklist) && !(is_object($GLOBALS[$key]) && $GLOBALS[$key] instanceof Closure)) {
$result .= sprintf(
'$GLOBALS[\'%s\'] = %s;' . "\n",
$key,
Expand Down Expand Up @@ -306,7 +306,7 @@ public static function backupStaticAttributes(array $blacklist)
$attribute->setAccessible(TRUE);
$value = $attribute->getValue();

if (!is_callable($value)) {
if (!(is_object($value) && $value instanceof Closure)) {
$backup[$name] = serialize($value);
}
}
Expand Down

0 comments on commit 39cb742

Please sign in to comment.