Following the completion of phpstan/phpstan#14288, I think it would make sense for the strict rules to permit the various math-related operations when the types will work as expected.
Supported in core:
BCMath: + - * / % ** <=> == > >= < <= Since 2024 so 8.4? (https://wiki.php.net/rfc/support_object_type_in_bcmath)
GMP: Above plus << >> . | & ^ xor ~ ! Since 5.6 (https://wiki.php.net/rfc/operator_overloading_gmp)
I think the case for bitwise where it's supported is somewhat dubious even where supported, but the stuff allowed with BCMath objects should't violate any "principles of least surprise" when operating on combinations of int, float, GMP, and BCMath types, though not having BCMath on one side and GMP on the other, so I think they should not get flagged by the strict rules extension.
I can try to take this on if folks are OK with it; though it seemed a bit ambiguous when working on the supporting type resolution pieces in phpstan-src.
Following the completion of phpstan/phpstan#14288, I think it would make sense for the strict rules to permit the various math-related operations when the types will work as expected.
Supported in core:
BCMath:
+ - * / % ** <=> == > >= < <=Since 2024 so 8.4? (https://wiki.php.net/rfc/support_object_type_in_bcmath)GMP: Above plus
<< >> . | & ^ xor ~ !Since 5.6 (https://wiki.php.net/rfc/operator_overloading_gmp)I think the case for bitwise where it's supported is somewhat dubious even where supported, but the stuff allowed with BCMath objects should't violate any "principles of least surprise" when operating on combinations of
int,float,GMP, andBCMathtypes, though not havingBCMathon one side andGMPon the other, so I think they should not get flagged by the strict rules extension.I can try to take this on if folks are OK with it; though it seemed a bit ambiguous when working on the supporting type resolution pieces in phpstan-src.