Closed GoogleCodeExporter closed 9 years ago
Here is a proof of concept using var_export().
<?php
class Dumper
{
public static function __set_state($class, $members)
{
$dump = array('__className'=>$class);
foreach( $members as $name => $value ) {
$dump[$name] = $value;
}
return $dump;
}
}
class TestObject
{
var $publicVar = 'Public Var';
protected $protectedVar = 'Protected Var';
private $privateVar = 'PrivateVar';
}
$obj = new TestObject();
$code = var_export($obj, true);
$code = str_replace('TestObject::__set_state(',
'Dumper::__set_state(\'TestObject\',', $code);
echo '<pre>';
echo $code;
echo '</pre>';
eval('$dump = ' . $code . ';');
echo '<pre>';
var_dump($dump);
echo '</pre>';
?>
Original comment by christop...@gmail.com
on 16 Sep 2008 at 8:29
This will be included in the next beta release.
Original comment by christop...@gmail.com
on 6 Oct 2008 at 8:36
hi Cristoph,
I suggest using the parseObject() function in the comments here:
http://es2.php.net/manual/en/function.get-object-vars.php
Original comment by krom...@gmail.com
on 7 Oct 2008 at 9:50
Take a look at:
http://code.google.com/p/firephp/source/browse/trunk/DevApp/application/bootstra
p/plain/LogPrivateObjectMembers.php
That is my planned implementation.
I think it will do the job just fine. I don't quite like parsing the output of
print_r.
Original comment by christop...@gmail.com
on 7 Oct 2008 at 10:42
Original comment by christ...@christophdorn.com
on 7 Oct 2008 at 12:34
Hi Christoph. I just tried the new 0.2.b.2.
You export the object via var_export. Thats fine, but does not work with bigger
vars
and does not handle recursions. Perhaps its possible to parse the ouptut of
serialize()? I think thats the only working solution for every case. Otherwise
it is
not possible to use it with big objects.
Original comment by fritz...@gmail.com
on 8 Oct 2008 at 3:44
I found a better solution using a cast to array. (array)$obj
I'll have an update available ASAP.
Original comment by christ...@christophdorn.com
on 8 Oct 2008 at 8:24
Please try 0.2.b.3
Original comment by christ...@christophdorn.com
on 8 Oct 2008 at 11:15
Using the following code:
<?php
require_once 'FirePHPCore/fb.php';
$obj1 = new stdClass;
$obj2 = new stdClass;
$obj1->p = $obj2;
$obj2->p = $obj1;
FB::log($obj1);
I'm getting a PHP error:
Fatal error: Nesting level too deep - recursive dependency? in
/usr/share/php/FirePHPCore/FirePHP.class.php on line 680
Call Stack
# Time Memory Function Location
1 0.0529 55784 {main}( ) ../test.php:0
2 0.2829 312464 FB::log( ) ../test.php:7
3 0.2829 312800 FB::send( ) ../fb.php:115
4 0.2831 314204 call_user_func_array ( ) ../fb.php:81
5 0.2831 314844 FirePHP->fb( ) ../fb.php:0
6 0.3384 318636 FirePHP->jsonEncode( ) ../FirePHP.class.php:549
7 0.3385 318636 FirePHP->encodeObject( ) ../FirePHP.class.php:657
8 0.3768 319372 FirePHP->encodeObject( ) ../FirePHP.class.php:740
9 0.3768 319720 in_array ( ) ../FirePHP.class.php:680
Original comment by jaap.t...@gmail.com
on 8 Oct 2008 at 11:23
Are you using version 0.2.b.3 of the FirePHPCore library?
Original comment by christ...@christophdorn.com
on 8 Oct 2008 at 11:46
Never mind. I can reproduce it. Working on a fix.
Original comment by christ...@christophdorn.com
on 8 Oct 2008 at 11:50
Please try 0.2.b.4
Original comment by christ...@christophdorn.com
on 9 Oct 2008 at 12:10
Original comment by christ...@christophdorn.com
on 22 Oct 2008 at 5:11
Original issue reported on code.google.com by
christ...@christophdorn.com
on 11 Sep 2008 at 6:01