[php-src] Issue #13826: Strict equality operator overloading for the \GMP class

From: Date: Thu, 28 Mar 2024 10:42:34 +0000
Subject: [php-src] Issue #13826: Strict equality operator overloading for the \GMP class
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246663@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13826 Author: Rafagd ### Description The GMP class already enjoys a lot of privileges in regards to having the language operators being overloaded under the hood to behave in a sensible way: ```php gmp_init(0) + gmp_init(1); // $x = \GMP { 1 } gmp_init(0) + 1; // $x = \GMP { 1 } gmp_init(0xFFFF_FFFF) & 1; // 0x1 gmp_init(0) < 1; // true gmp_init(0) > 1; // false gmp_init(133) == 133; // true ``` This is all good but the strict equality operator is the one that behaves in a weird way. While I do understand it would be bad to have \GMP { 0 } === int { 0 } to be true, I do think it's very odd that gmp_init(0) === gmp_init(0) evaluates to false. While I do understand they are different objects that have different pointers associated to them, but that kinda shuts down a more useful usage [IMO]: these are both the same number with the same type.

« previous php.bugs (#246663) next »