Update: I ran into issues with the ArrayObject solution, as there was
a bug in PHP 5.2.0 (now fixed) with its interaction with empty() and isset()
when used with the ARRAY_AS_PROPS flag. I tried a number of fixes, but
eventually my friend Mike pointed
out something I'd missed: as of PHP 5.1, setting undefined public properties
no longer raises an E_STRICT notice. Knowing this, you can now do the
following without raising any errors:
class Foo
{ public
function __set
($key,
$value) { $this->
$key =
$value;
}}$foo =
new Foo
();
$foo->
bar =
array();
$foo->
bar[] =
42;
This is a much simpler solution, performs better, and solves all the issues
I was presented. Thanks, Mike!