Author: ts Date: Tue Feb 19 13:19:00 2008 New Revision: 7411 Log: - Make ezcDebugVariableDumpTool respect $maxDepth parameter.
Modified: trunk/Debug/src/tools/dump.php trunk/Debug/tests/variable_dump_tool_test.php Modified: trunk/Debug/src/tools/dump.php ============================================================================== --- trunk/Debug/src/tools/dump.php [iso-8859-1] (original) +++ trunk/Debug/src/tools/dump.php [iso-8859-1] Tue Feb 19 13:19:00 2008 @@ -81,26 +81,38 @@ */ private static function dumpArray( array $arg, $maxData, $maxChildren, $maxDepth ) { - $max = min( count( $arg ), $maxChildren ); - - $results = array(); - reset( $arg ); - for ( $i = 0; $i < $max; ++$i ) - { - $results[] = - self::dumpVariable( key( $arg ), $maxData, $maxChildren, $maxDepth - 1 ) - . ' => ' - . self::dumpVariable( current( $arg ), $maxData, $maxChildren, $maxDepth - 1 ); - next( $arg ); - } - - if ( $max < count( $arg ) ) - { - $results[] = '...'; - } + $arrayContent = ''; + + if ( $maxDepth != 0 ) + { + $max = min( count( $arg ), $maxChildren ); + + $results = array(); + reset( $arg ); + for ( $i = 0; $i < $max; ++$i ) + { + $results[] = + self::dumpVariable( key( $arg ), $maxData, $maxChildren, $maxDepth - 1 ) + . ' => ' + . self::dumpVariable( current( $arg ), $maxData, $maxChildren, $maxDepth - 1 ); + next( $arg ); + } + + if ( $max < count( $arg ) ) + { + $results[] = '...'; + } + + $arrayContent = implode( ', ', $results ); + } + else + { + $arrayContent = '...'; + } + return sprintf( - 'array (%s)', implode( ', ', $results ) + 'array (%s)', $arrayContent ); } @@ -118,31 +130,42 @@ private static function dumpObject( $arg, $maxData, $maxChildren, $maxDepth ) { $refObj = new ReflectionObject( $arg ); - $refProps = $refObj->getProperties(); - - $max = min( - count( $refProps ), - $maxChildren - ); - - $results = array(); - reset( $refProps ); - for( $i = 0; $i < $max; $i++ ) - { - $refProp = current( $refProps ); - $results[] = sprintf( - '%s $%s = %s', - self::getPropertyVisibility( $refProp ), - $refProp->getName(), - self::getPropertyValue( $refProp, $arg, $maxDepth - 1 ) + + $objectContent = ''; + if ( $maxDepth != 0 ) + { + $refProps = $refObj->getProperties(); + + $max = min( + count( $refProps ), + $maxChildren ); - next( $refProps ); - } + $results = array(); + + reset( $refProps ); + for( $i = 0; $i < $max; $i++ ) + { + $refProp = current( $refProps ); + $results[] = sprintf( + '%s $%s = %s', + self::getPropertyVisibility( $refProp ), + $refProp->getName(), + self::getPropertyValue( $refProp, $arg, $maxDepth - 1 ) + ); + next( $refProps ); + } + $objectContent = implode( '; ', $results ); + } + else + { + $objectContent = '...'; + } + return sprintf( 'class %s { %s }', $refObj->getName(), - implode( '; ', $results ) + $objectContent ); } Modified: trunk/Debug/tests/variable_dump_tool_test.php ============================================================================== --- trunk/Debug/tests/variable_dump_tool_test.php [iso-8859-1] (original) +++ trunk/Debug/tests/variable_dump_tool_test.php [iso-8859-1] Tue Feb 19 13:19:00 2008 @@ -137,7 +137,7 @@ ); $res = <<<EOT -array (0 => 23, 'foo bar' => array (1 => '293', 2 => 234223, 'foo' => array (0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => array (), 8 => 23, 9 => 'foo', 10 => array (0 => 23, 1 => 42))), 1 => 42.23, 'a' => TRUE, 'd' => FALSE, 23 => 'test', 24 => 'foo bar baz') +array (0 => 23, 'foo bar' => array (1 => '293', 2 => 234223, 'foo' => array (0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => array (...), 8 => 23, 9 => 'foo', 10 => array (...))), 1 => 42.23, 'a' => TRUE, 'd' => FALSE, 23 => 'test', 24 => 'foo bar baz') EOT; $this->assertEquals( $res, -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components