Debug::export ArrayObject dumps the internal storage variable #191

Merged
merged 4 commits into from Oct 1, 2012

Conversation

Projects
None yet
5 participants
Contributor

Slamdunk commented Sep 27, 2012

Until now, exporting ArrayObject hid the internal storage variable, but print_r and var_dump show it.
This is due to $reflClass->getProperties() doesn't read it.

With this PR the ArrayObject::storage variable is exported too.

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DCOM-115

@stof stof commented on an outdated diff Sep 27, 2012

tests/Doctrine/Tests/Common/Util/DebugTest.php
@@ -24,4 +24,12 @@ public function testExportDateTime()
$var = Debug::export( $obj, 2 );
$this->assertEquals( "DateTime", $var->__CLASS__ );
}
+
+ public function testExportArrayObject()
+ {
+ $obj = new \ArrayObject( array('foobar') );
+
+ $var = Debug::export( $obj, 2 );
@stof

stof Sep 27, 2012

Member

Please remove the extra spaces inside the braces (same on line 30)

@guilhermeblanco guilhermeblanco commented on an outdated diff Sep 27, 2012

lib/Doctrine/Common/Util/Debug.php
@@ -103,6 +103,9 @@ public static function export($var, $maxDepth)
$return->__IS_PROXY__ = true;
$return->__PROXY_INITIALIZED__ = $var->__isInitialized();
}
+ if ($var instanceof \ArrayObject) {
@guilhermeblanco

guilhermeblanco Sep 27, 2012

Owner

Missing line break after close curly braces and if

Contributor

Slamdunk commented Oct 1, 2012

A note on the choosen name for variable, __STORAGE__: if you var_dump a class that extends ArrayObject, that class is allowed to have a $storage variable, although ArrayObject uses a private $storage variable to retain informations.

So, following __CLASS__-taken standard, I chose a different variable name instead of $storage to let $reflClass->getProperties() not overwrite it.

@beberlei beberlei added a commit that referenced this pull request Oct 1, 2012

@beberlei beberlei Merge pull request #191 from Slamdunk/hotfix/debug-export-arrayobject
Debug::export ArrayObject dumps the internal storage variable
9e3bea9

@beberlei beberlei merged commit 9e3bea9 into doctrine:master Oct 1, 2012

1 check passed

default The Travis build passed
Details

Slamdunk deleted the Slamdunk:hotfix/debug-export-arrayobject branch Jul 21, 2016

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