Re: Results of testing ZF against PHP 5.4.0RC1
| From: | Rasmus Lerdorf | Date: | Thu, 17 Nov 2011 21:50:26 +0000 |
| Subject: | Re: Results of testing ZF against PHP 5.4.0RC1 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56375@lists.php.net to get a copy of this message | ||
On 11/17/2011 03:10 PM, Stas Malyshev wrote:
> Hi!
>
>> I recall from earlier discussions that Stas was in favor of reverting
>> this change -- what's the status at this time? This single change
>
> I was not and still am not - I think if something warrants notice this
> is exactly the case. Conversion of array to string "Array" IMHO makes no
> sense and not useful in any case, so if you code does that it's most
> probably a bug. I understand that some tests were written without
> accounting for this, but frankly in this case I think the right way
> would be to fix the tests. This is not the feature your code should rely
> on (and I think it should have never existed in PHP in the first place)
> and if we shall guarantee compatibility with every bug and bad decision
> we took in the past we won't be able to advance anywhere. I think in
> this case the inconvenience from fixing the tests is outweighed by the
> advantage of promoting better code and exposing hard-to-find bugs.
I completely agree. If you are seeing a lot of these in unit tests, then
your tests are likely not testing what you think they are.
I am seeing complaints about this notice in tests that do this:
array_diff($a, $b)
Where either $a or $b contains nested arrays. The thing with this is
that this really is not doing what you think it is when you feed it
nested arrays. For example:
$a = [1,2,[3]];
$b = [1,2,[4]];
This ends up comparing [1,2,'Array'] against [1,2,'Array'] and these two
arrays are thus identical as far as array_diff() is concerned. Or even
worse:
$a = [1,2,'Array'];
$b = [1,2,[4,5,6,7,8,9]];
Again, array_diff() is going to tell you that there is no difference
between $a and $b. This seems like an obvious case where we issue a
NOTICE telling the user that the code probably didn't do what they
wanted it to.
-Rasmus