Closed Robertbaelde closed 2 years ago
Hi @Robertbaelde, this is an optimization as the ID does not always need to be computed.
My stance of this is that you should never compare objects by value, as you're making yourself implicitly dependent on class internals, that are not exposed by the public API. This is something IMHO that PHP should forbid, or at least make harder to do than ==
.
You should instead use the API that the library provides, i.e. TimeZone::isEqualTo()
.
But keep an eye on #55, it's not bulletproof yet 😕
In order to compare TimeZone Offset reliably, the id must be set on construction. Otherwise, when objects including timezones are compared, a test would fail because in some cases the id has been set. And in other cases, the id hasn't been set.
Previously this test would fail: