Skip to content
Prev Previous commit
Next Next commit
Naming restriction applies (except for integers)
  • Loading branch information
Girgias committed Dec 1, 2023
commit c949efd05e5752398fac7e2242ee18498ef04bf3
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,27 @@ get_object_vars() no-declared/declared discrepancies
class Test {
public $prop;
}

// Using ArrayObject here to get around property name restrictions

$obj = new stdClass;
$ao = new ArrayObject($obj);
$ao["\0A\0b"] = 42;
$ao["\0*\0b"] = 24;
$ao[12] = 6;
var_dump(get_object_vars($obj));

$obj = new Test;
$ao = new ArrayObject($obj);
$ao["\0A\0b"] = 42;
$ao["\0*\0b"] = 24;
$ao[12] = 6;
var_dump(get_object_vars($obj));

?>
--EXPECTF--
array(3) {
["%0A%0b"]=>
int(42)
["%0*%0b"]=>
int(24)
--EXPECT--
array(1) {
[12]=>
int(6)
}
array(4) {
array(2) {
["prop"]=>
NULL
["%0A%0b"]=>
int(42)
["%0*%0b"]=>
int(24)
[12]=>
int(6)
}