Morten Fangel wrote:
On Thursday 16 February 2006 12:39, Antony Dovgal wrote:
<?php
$a->bar = 1;
var_dump($a);
?>
This code is much simpler, huh?
Yeah, I must have been blinded by the lights. It merely resembles
$foo['bar'] = 'baz';
Where $foo is cast as an array without the need to do $foo = array(); first.
So I guess there is no need for a notice when you apply the same "pattern" to
an object.
if that is the logic being applied in the engine then one might to wonder why a
function such as array_merge() was changed to emit a warning when any of
it's arguments are not arrays (whereas sometime in the past it used to swallow
[and I assume 'autocast'] whatever it was given without a hiccup).
I have been told that such warnings as array_merge() now emits are for my own
good (in not so many words I was told it was "to protect me from my stupid
self"),
if it's good for me when I use array_merge() why not when an object is created
implicitly (as in the example above)? actually my preference would be to drop
the warning
in array_merge() in this case (it seems like a more php way of doing things,
imo)
<!--
unset($a); $a->i = 1; // this is not a problem
$b = 1; $c = 2; $d = array_merge($b, $c); // but this is bad programming?
-->
I'm very interested to learn what people think about this kind of thing in
general -
and obviously if someone knows of material that explains the reasoning behind
the
percieved inconsistency/problem I'd be very grateful.
tar,
jochem
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php