--TEST-- compact() with object context --FILE-- test() ); var_dump( (new class { function test(){ return compact([['this']]); } })->test() ); var_dump( (new class { function test(){ return (function(){ return compact('this'); })(); } })->test() ); ?> --EXPECTF-- array(1) { ["this"]=> object(%s)#1 (0) { } } array(1) { ["this"]=> object(%s)#1 (0) { } } array(1) { ["this"]=> object(%s)#1 (0) { } }