Closed
Description
Comparing messages (or repeated fields, etc) in PHP always returns true, regardless of the contents:
$m1 = new TestMessage();
$m2 = new TestMessage();
$m3 = new TestMessage();
$rf1 = new RepeatedField(GPBType::INT32);
$rf2 = new RepeatedField(GPBType::INT32);
$rf1[] = 5;
$m1->setOptionalInt32(1);
$m2->setOptionalInt32(1);
$m3->setOptionalInt32(3);
// These succeed.
$this->assertTrue($m1 == $m2);
$this->assertFalse($m1 == $rf1); // Mixing types
// These fail.
$this->assertFalse($m1 == $m3);
$this->assertFalse($rf1 == $rf2);
This is true for the C extension (haven't tested pure-PHP).
Should we change this? Should equality compare contents? Should it be a deep comparison? We should provide answers to these questions and possibly change/fix the existing behavior.