Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000560 [Quercus] major always 12-24-05 10:31 12-27-05 16:32
Reporter bago View Status @0@  
Assigned To
Priority normal Resolution fixed  
Status closed   Product Version
Summary 0000560: === for arrays is implemented like the java == but it should be implemented differently!
Description This took so long to find out!

Here is the definition of === from the manual:
http://www.php.net/manual/en/language.operators.comparison.php [^]
$a === $b
Identical
TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)

Additional Information Doing the same with a non array variable works fine.
Attached Files

- Relationships

- Notes
(0000573)
bago
12-24-05 10:38

I think this test is also interesting:
<?php
$foo = array(2=>'a',1=>'b');
$bar = $foo;
ksort($foo);
if ($bar===$foo) print("true"); else print("false");
flush();
$foo = array('a',1=>'b');
$bar = $foo;
ksort($foo);
if ($bar===$foo) print("true"); else print("false");
flush();
return;
?>

this script in the original php return "falsetrue".
after fixing the above problem you should run this test also!
 
(0000574)
bago
12-24-05 11:24

I changed Value.java:582
from:
    return this == rValue.toValue();
to:
    return this.getType()==rValue.toValue().getType() && this.eq(rValue.toValue());

This seems to work better but the previous "ksort" example does not mimic the original php behaviour either way.
 
(0000575)
bago
12-24-05 11:45

Using the patch described at 0000574:

<?php
$a = array ('bar' => 1, 'foo' => 2,);
$b = array ('foo' => 2, 'bar' => 1,);
print("B ==: ".($b == $a)."
");
print("B ===: ".($b === $a)."
");
ksort($b);
print("A ==: ".($b == $a)."
");
print("A ===: ".($b === $a)."
");
?>

Original php result:
B ==: 1
B ===:
A ==: 1
A ===: 1
Patched quercus result:
B ==: 1
B ===: 1
A ==: 1
A ===: 1

It seems that the php behaviour does not match its own documentation.
The only difference between == and === should be in the type checking, while this prove that php check the sorting, too!

I'm not sure wether quercus should try to mimic this behaviour or follow the documentation.
 
(0000587)
ferg
12-27-05 16:32

php/0360
 

- Issue History
Date Modified Username Field Change
12-24-05 10:31 bago New Issue
12-24-05 10:38 bago Note Added: 0000573
12-24-05 11:24 bago Note Added: 0000574
12-24-05 11:45 bago Note Added: 0000575
12-27-05 16:32 ferg Status new => closed
12-27-05 16:32 ferg Note Added: 0000587
12-27-05 16:32 ferg Resolution open => fixed
12-27-05 16:32 ferg Fixed in Version  => 3.0.18


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
36 total queries executed.
30 unique queries executed.
Powered by Mantis Bugtracker