1--TEST-- 2compact() with object context 3--FILE-- 4<?php 5 6var_dump( 7 (new class { 8 function test(){ 9 return compact('this'); 10 } 11 })->test() 12); 13 14var_dump( 15 (new class { 16 function test(){ 17 return compact([['this']]); 18 } 19 })->test() 20); 21 22var_dump( 23 (new class { 24 function test(){ 25 return (function(){ return compact('this'); })(); 26 } 27 })->test() 28); 29 30?> 31--EXPECT-- 32array(1) { 33 ["this"]=> 34 object(class@anonymous)#1 (0) { 35 } 36} 37array(1) { 38 ["this"]=> 39 object(class@anonymous)#1 (0) { 40 } 41} 42array(1) { 43 ["this"]=> 44 object(class@anonymous)#1 (0) { 45 } 46} 47